/* ==========================================================================
 * Productfilters (VM Attribute Filters) — categorie, merk en prijs
 * Overgenomen van het vlecht-thema, in Tool Trading-huisstijl.
 * Desktop (>= 1200px): vaste kolom links.
 * Mobiel/tablet (< 1200px): schuifpaneel, geopend via de filterknop onderaan.
 * ========================================================================== */

#archive .filter {
	--tt-filter-accent: var(--blauw-color, #004268);
	--tt-filter-slider: var(--oranje-color, #FF7028);
	--tt-filter-rand: var(--tt-rand, #e1e6eb);
	--tt-filter-tekst: var(--tt-tekst, #1f2b3a);
	margin-top: 0;
	padding-right: 10px;
}

/* Titel "Filter op:" */
#archive .filter .sidebar-filter-title {
	margin: 0 0 1rem !important;
	padding-bottom: .75rem;
	border-bottom: 2px solid var(--tt-filter-accent);
	color: var(--tt-filter-tekst);
	font-size: 1.05rem !important;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .03em;
}

/* --------------------------------------------------------------------------
 * Filtergroep
 * ----------------------------------------------------------------------- */
#archive .filter .sidebar-item {
	margin-bottom: .75rem;
	padding-bottom: .75rem;
	border-bottom: 1px solid var(--tt-filter-rand);
}

#archive .filter .sidebar-item h5 {
	display: block;
	width: 100%;
	margin: 0 !important;
	color: var(--tt-filter-tekst);
	font-size: .95rem !important;
	font-weight: 700;
	text-transform: uppercase;
}

#archive .filter .sidebar-item .item-content { display: none; }
#archive .filter .sidebar-item .item-content > *:last-child { margin-bottom: 0; }

#archive .filter .sidebar-item ul.sidebar-attr {
	display: flex;
	flex-direction: column;
	gap: .5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Inklapbaar: chevron omlaag = dicht, omhoog = open */
#archive .filter .sidebar-item.open-item > h5 {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: .5rem;
	padding: .35rem 0;
	cursor: pointer;
	user-select: none;
}
#archive .filter .sidebar-item.open-item > h5::after {
	flex-shrink: 0;
	width: .5rem;
	height: .5rem;
	margin: -.3rem .35rem 0 0;
	border-right: 2px solid var(--tt-filter-tekst);
	border-bottom: 2px solid var(--tt-filter-tekst);
	transform: rotate(45deg);
	content: "";
	transition: transform .2s ease, margin-top .2s ease;
}
#archive .filter .sidebar-item.open-item > h5:focus-visible {
	outline: 2px solid var(--tt-filter-slider);
	outline-offset: 2px;
}
#archive .filter .sidebar-item.open-item.open > h5::after {
	margin-top: .3rem;
	transform: rotate(-135deg);
}
#archive .filter .sidebar-item.open-item.open > .item-content {
	display: block;
	margin-top: .75rem;
}

/* Lange lijsten: eerst een paar opties, de rest via "Lees meer" (filters.js) */
#archive .filter ul.is-collapsed > li.vm-af-over { display: none !important; }

#archive .filter .vm-af-show-more {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-top: .6rem;
	padding: 2px 0;
	border: 0;
	background: none;
	color: var(--tt-filter-accent);
	font-size: 13px;
	font-weight: 700;
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}
#archive .filter .vm-af-show-more::after {
	width: .4rem;
	height: .4rem;
	margin-top: -.2rem;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg);
	content: "";
}
#archive .filter .vm-af-show-more[aria-expanded="true"]::after { margin-top: .2rem; transform: rotate(-135deg); }
#archive .filter .vm-af-show-more:hover { color: var(--tt-filter-slider); }

/* --------------------------------------------------------------------------
 * Checkbox-opties
 * ----------------------------------------------------------------------- */
#archive .filter .sidebar-item.filter ul li {
	display: flex;
	flex-direction: column;
	width: 100%;
	margin: 0;
	padding: 0;
}
#archive .filter .sidebar-item.filter ul li::before,
#archive .filter .sidebar-item.filter ul li::after { display: none; }

#archive .filter .sidebar-item.filter ul li a {
	position: relative;
	display: flex;
	align-items: center;
	gap: .55rem;
	padding: 2px 0;
	color: var(--tt-filter-tekst);
	font-size: 14px;
	line-height: 1.35;
	text-decoration: none;
}
/* Leeg vakje */
#archive .filter .sidebar-item.filter ul li a::before {
	flex-shrink: 0;
	display: inline-block;
	width: 18px;
	height: 18px;
	border: 1.5px solid #b9c3cd;
	border-radius: 3px;
	background: #fff;
	content: "";
	transition: background .15s ease, border-color .15s ease;
}
/* Wit vinkje, zichtbaar als gekozen */
#archive .filter .sidebar-item.filter ul li a::after {
	position: absolute;
	top: 50%;
	left: 6px;
	width: 6px;
	height: 10px;
	border-right: 2px solid #fff;
	border-bottom: 2px solid #fff;
	transform: translateY(-60%) rotate(45deg);
	opacity: 0;
	content: "";
	transition: opacity .15s ease;
}
#archive .filter .sidebar-item.filter ul li a:hover { color: var(--tt-filter-accent); }
#archive .filter .sidebar-item.filter ul li a:hover::before { border-color: var(--tt-filter-accent); }

#archive .filter .sidebar-item.filter ul li.chosen > a,
#archive .filter .sidebar-item.filter ul li.chosen > .cat-filter-row > a {
	color: var(--tt-filter-accent);
	font-weight: 700;
}
#archive .filter .sidebar-item.filter ul li.chosen > a::before,
#archive .filter .sidebar-item.filter ul li.chosen > .cat-filter-row > a::before {
	border-color: var(--tt-filter-accent);
	background: var(--tt-filter-accent);
}
#archive .filter .sidebar-item.filter ul li.chosen > a::after,
#archive .filter .sidebar-item.filter ul li.chosen > .cat-filter-row > a::after { opacity: 1; }

#archive .filter .filter-count { opacity: .55; font-size: .8em; }

/* --------------------------------------------------------------------------
 * Categorieboom
 * ----------------------------------------------------------------------- */
#archive .filter .sidebar-attr-hierarchical .cat-filter-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: .5rem;
}
#archive .filter .sidebar-attr-hierarchical .cat-tree-toggle {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	padding: 0;
	border: 1px solid var(--tt-filter-rand);
	border-radius: 3px;
	background: #fff;
	color: var(--tt-filter-tekst);
	font-size: 15px;
	line-height: 1;
	cursor: pointer;
	transition: background-color .2s ease, border-color .2s ease;
}
#archive .filter .sidebar-attr-hierarchical .cat-tree-toggle:hover {
	border-color: var(--tt-filter-slider);
	color: var(--tt-filter-slider);
}
#archive .filter .sidebar-attr-children {
	display: none;
	flex-direction: column;
	gap: .4rem;
	margin: .4rem 0 0 .6rem;
	padding: 0 0 0 .75rem;
	border-left: 1px solid var(--tt-filter-rand);
	list-style: none;
}
#archive .filter .sidebar-attr-hierarchical li.open > .sidebar-attr-children { display: flex; }

/* --------------------------------------------------------------------------
 * Prijs-slider
 * ----------------------------------------------------------------------- */
#archive .filter .price-filter-wrap { padding: .25rem 4px; user-select: none; }

#archive .filter .price-slider-track {
	position: relative;
	height: 4px;
	margin: 1.25rem 0 1rem;
	border-radius: 2px;
	background: #d8d8d8;
}
#archive .filter .price-slider-fill {
	position: absolute;
	top: 0;
	bottom: 0;
	border-radius: 2px;
	background: var(--tt-filter-slider);
}
#archive .filter .price-slider-inputs {
	position: relative;
	height: 20px;
	margin-top: -28px;
}
#archive .filter .price-slider-inputs input[type=range] {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 20px;
	margin: 0;
	padding: 0;
	border: 0;
	outline: none;
	background: transparent;
	pointer-events: none;
	-webkit-appearance: none;
	appearance: none;
}
#archive .filter .price-slider-inputs input[type=range]::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 20px;
	height: 20px;
	border: 3px solid #fff;
	border-radius: 50%;
	background: var(--tt-filter-slider);
	box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
	cursor: grab;
	pointer-events: all;
}
#archive .filter .price-slider-inputs input[type=range]::-moz-range-thumb {
	width: 14px;
	height: 14px;
	border: 3px solid #fff;
	border-radius: 50%;
	background: var(--tt-filter-slider);
	box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
	cursor: grab;
	pointer-events: all;
}
#archive .filter .price-slider-inputs input[type=range]::-moz-range-track { background: transparent; }

#archive .filter .price-display {
	display: flex;
	justify-content: space-between;
	margin-top: 1rem;
	color: var(--tt-filter-tekst);
	font-size: 14px;
	font-weight: 700;
}

/* --------------------------------------------------------------------------
 * Actieve filters (pills boven de producten)
 * ----------------------------------------------------------------------- */
#vm-active-filters-bar {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin: 0 0 1rem;
}
#vm-active-filters-bar .pill {
	display: inline-flex;
	align-items: center;
	gap: .4rem;
	padding: 6px 12px;
	border: 1px solid var(--blauw-color, #004268);
	border-radius: 999px;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.3;
	text-decoration: none;
	transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
#vm-active-filters-bar .active-filter-pill { background: var(--blauw-color, #004268); color: #fff; }
#vm-active-filters-bar .active-filter-pill::after { content: "×"; font-size: 15px; line-height: 1; opacity: .8; }
#vm-active-filters-bar .active-filter-pill:hover { border-color: var(--oranje-color); background: var(--oranje-color); color: #fff; }
#vm-active-filters-bar .active-filter-clear { background: #fff; color: var(--blauw-color, #004268); }
#vm-active-filters-bar .active-filter-clear:hover { border-color: var(--oranje-color); color: var(--oranje-color); }

/* Laadstatus tijdens filteren */
#product-loop-container { transition: opacity .2s ease; min-height: 200px; }

/* Panelknoppen alleen mobiel */
#archive .filter .vm-af-panel-close { display: none; }

/* --------------------------------------------------------------------------
 * Filterknop onderaan (mobiel/tablet)
 * ----------------------------------------------------------------------- */
.mobile-filters #filterBtn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	margin: 0;
	padding: 13px 0;
	border: 0;
	background: transparent;
	color: #fff;
	font-weight: 700;
	letter-spacing: .04em;
	text-transform: uppercase;
	cursor: pointer;
}

/* --------------------------------------------------------------------------
 * Mobiel/tablet: schuifpaneel
 * ----------------------------------------------------------------------- */
@media (max-width: 1199px) {
	body.no-scroll { overflow: hidden; }

	#archive .filter.filter-wrapper {
		position: fixed;
		top: 0;
		left: 0;
		z-index: 9990; /* boven de pagina, onder menu- en winkelmandlade */
		display: flex;
		flex-direction: column;
		width: 88%;
		max-width: 360px;
		height: 100vh;
		height: 100dvh;
		margin: 0;
		padding: 18px 20px 0;
		overflow-y: auto;
		background: #fff;
		box-shadow: 4px 0 18px rgba(0, 0, 0, .15);
		transform: translateX(-100%);
		visibility: hidden;
		transition: transform .3s ease, visibility 0s linear .3s;
		overscroll-behavior: contain;
	}
	#archive .filter.filter-wrapper.is-open {
		transform: translateX(0);
		visibility: visible;
		transition: transform .3s ease;
	}

	#archive .filter .vm-af-show-more { padding: 8px 0; font-size: 14px; }

	#archive .filter .sidebar-filter-title { padding-right: 40px; }

	/* Grotere tikvlakken */
	#archive .filter .sidebar-item.filter ul li a { padding: 6px 0; font-size: 15px; }
	#archive .filter .sidebar-item.open-item > h5 { padding: .6rem 0; }
	#archive .filter .sidebar-attr-hierarchical .cat-tree-toggle { width: 32px; height: 32px; font-size: 18px; }

	#archive .filter .vm-af-panel-close:not(.vm-af-panel-apply) {
		position: absolute;
		top: 8px;
		right: 10px;
		display: block;
		width: 40px;
		height: 40px;
		padding: 0;
		border: 0;
		background: transparent;
		color: var(--tt-filter-tekst);
		font-size: 2rem;
		line-height: 1;
		cursor: pointer;
	}

	/* "Toon resultaten" blijft onderaan in beeld */
	#archive .filter .vm-af-panel-apply {
		position: sticky;
		bottom: 0;
		display: block;
		width: calc(100% + 40px);
		margin: auto -20px 0;
		padding: 15px 20px calc(15px + env(safe-area-inset-bottom));
		border: 0;
		background: var(--oranje-color, #FF7028);
		color: #fff;
		font-weight: 700;
		letter-spacing: .04em;
		text-transform: uppercase;
		box-shadow: 0 -4px 12px rgba(0, 0, 0, .08);
	}

	.filter-overlay {
		position: fixed;
		inset: 0;
		z-index: 9980;
		background: rgba(0, 0, 0, .45);
		opacity: 0;
		visibility: hidden;
		transition: opacity .3s ease, visibility 0s linear .3s;
	}
	.filter-overlay.is-active {
		opacity: 1;
		visibility: visible;
		transition: opacity .3s ease;
	}

	/* Ingelogd: paneel onder de WordPress-adminbalk */
	body.admin-bar #archive .filter.filter-wrapper { top: 32px; height: calc(100dvh - 32px); }

	/* Ruimte zodat de vaste filterknop geen producten/paginering afdekt */
	#archive { padding-bottom: 56px; }
}
@media (max-width: 782px) {
	body.admin-bar #archive .filter.filter-wrapper { top: 46px; height: calc(100dvh - 46px); }
}
