/* Jungleaf Filters. Uses the theme's --jl-* tokens when present. */
.jlf-panel,
.jlf-toolbar,
.jlf-subcats {
	--jlf-text: var(--jl-text, #141a16);
	--jlf-muted: var(--jl-muted, #575c56);
	--jlf-line: var(--jl-line, #cfc9bc);
	--jlf-surface: var(--jl-surface, #fff);
	--jlf-bg: var(--jl-bg, #ebe8e1);
	--jlf-accent: var(--jl-cta, #00a651);
	--jlf-accent-text: var(--jl-cta-text, #fff);
	--jlf-accent-soft: var(--jl-brand-soft, #dcecd3);
	--jlf-radius: var(--jl-radius-sm, 12px);
	--jlf-sm: var(--jl-text-sm, 16px);
	--jlf-xs: var(--jl-text-xs, 14px);
	font-family: var(--jl-font, inherit);
}

/* Sub-category chips ------------------------------------------------- */
.jlf-subcats { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 8px; }
.jlf-subcats a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 0 18px;
	border: 1.5px solid var(--jlf-line);
	border-radius: 999px;
	background: var(--jlf-surface);
	color: var(--jlf-text) !important;
	font-size: var(--jlf-sm);
	font-weight: 500;
	text-decoration: none !important;
}
.jlf-subcats a:hover { border-color: var(--jlf-text); }
.jlf-subcats a[aria-current="page"] { border-color: var(--jlf-text); background: var(--jlf-text); color: var(--jlf-surface) !important; }

/* Wider filter column next to the product grid (Shoptimizer floats) */
@media (min-width: 993px) {
	body:has(.jlf-sidebar) #secondary { width: 24%; }
	body:has(.jlf-sidebar) #primary { width: 73%; }
	.jlf-sidebar #secondary { position: sticky; top: calc(var(--jl-admin-bar, 0px) + var(--jl-header-h, 76px) + 40px); max-height: calc(100vh - var(--jl-admin-bar, 0px) - var(--jl-header-h, 76px) - 60px); overflow-x: hidden; overflow-y: auto; padding-right: 8px; scrollbar-width: thin; }
}
.jlf-subcats { margin-top: 0; }

/* Toolbar --------------------------------------------------------------- */
.jlf-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin: 0 0 24px; }
.jlf-count { margin: 0; color: var(--jlf-muted); font-size: var(--jlf-sm); }
.jlf-active { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.jlf-active li { margin: 0; }
.jlf-active a {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 38px;
	padding: 0 14px;
	border-radius: 999px;
	background: var(--jlf-accent-soft);
	color: var(--jlf-text) !important;
	font-size: var(--jlf-xs);
	font-weight: 500;
	text-decoration: none !important;
}
.jlf-active a span[aria-hidden] { font-size: 1.2em; line-height: 1; }
.jlf-active a.jlf-clear { background: transparent; text-decoration: underline !important; }
.jlf-sort { display: flex; align-items: center; gap: 10px; margin: 0 0 0 auto; font-size: var(--jlf-sm); color: var(--jlf-muted); }
.jlf-sort select {
	min-height: 46px;
	padding: 0 40px 0 14px;
	border: 1.5px solid var(--jlf-line);
	border-radius: var(--jlf-radius);
	background: var(--jlf-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23141a16' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
	color: var(--jlf-text);
	font-size: var(--jlf-sm);
	-webkit-appearance: none;
	appearance: none;
}
.jlf-open {
	display: none;
	align-items: center;
	gap: 8px;
	min-height: 46px;
	padding: 0 18px;
	border: 1.5px solid var(--jlf-text);
	border-radius: var(--jlf-radius);
	background: var(--jlf-surface);
	color: var(--jlf-text);
	font-size: var(--jlf-sm);
	font-weight: 600;
	cursor: pointer;
}
.jlf-badge {
	display: inline-grid;
	place-items: center;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border-radius: 999px;
	background: var(--jlf-accent);
	color: var(--jlf-accent-text);
	font-size: 12px;
}

/* Panel --------------------------------------------------------------- */
.jlf-panel { font-size: var(--jlf-sm); color: var(--jlf-text); }
.jlf-panel__head { display: none; }
.jlf-group { margin: 0 0 26px; padding: 0 0 22px; border: 0; border-bottom: 1px solid var(--jlf-line); min-width: 0; }
.jlf-group legend { float: left; width: 100%; margin: 0 0 12px; padding: 0; font-size: var(--jl-text-base, 18px); font-weight: 600; }
.jlf-options { clear: both; display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.jlf-options li { margin: 0; max-width: 100%; }
.jlf-options li[hidden] { display: none; }
.jlf-option {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 40px;
	padding: 0 14px;
	border: 1.5px solid var(--jlf-line);
	border-radius: 20px;
	background: var(--jlf-surface);
	max-width: 100%;
	padding-top: 8px;
	padding-bottom: 8px;
	cursor: pointer;
	line-height: 1.25;
	transition: border-color .15s ease, background-color .15s ease;
}
.jlf-option:hover { border-color: var(--jlf-text); }
.jlf-option input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.jlf-option:has(input:checked) { border-color: var(--jlf-text); background: var(--jlf-text); color: var(--jlf-surface); }
.jlf-option:has(input:checked) .jlf-option__count { color: inherit; opacity: .7; }
.jlf-option:has(input:focus-visible) { outline: 2px solid var(--jlf-text); outline-offset: 2px; }
.jlf-option.is-disabled { opacity: .4; cursor: default; }
.jlf-option.is-disabled:hover { border-color: var(--jlf-line); }
.jlf-option__count { color: var(--jlf-muted); font-size: 12px; }

/* Colour swatches: compact two-column list */
.jlf-group--color .jlf-options { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; }
.jlf-group--color .jlf-option { display: flex; min-height: 38px; padding: 4px 8px 4px 4px; border-color: transparent; background: transparent; }
.jlf-group--color .jlf-option:hover { border-color: var(--jlf-line); }
.jlf-group--color .jlf-option:has(input:checked) { border-color: var(--jlf-text); background: var(--jlf-surface); color: var(--jlf-text); }
.jlf-group--color .jlf-option:has(input:checked) .jlf-swatch { box-shadow: 0 0 0 2px var(--jlf-surface), 0 0 0 4px var(--jlf-text); }
.jlf-group--color .jlf-option__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jlf-swatch { width: 24px; height: 24px; border-radius: 50%; background: var(--jlf-color); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); flex: none; }

.jlf-toggle-more { margin-top: 12px; padding: 0; border: 0; background: none; color: var(--jlf-text); font-size: var(--jlf-xs); font-weight: 600; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }

/* Price */
.jlf-range { clear: both; position: relative; height: 28px; margin: 6px 4px 14px; }
.jlf-range__track { position: absolute; left: 0; right: 0; top: 12px; height: 4px; border-radius: 4px; background: var(--jlf-line); }
.jlf-range__fill { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: var(--jlf-text); }
.jlf-range input[type="range"] {
	position: absolute;
	left: -4px;
	right: -4px;
	top: 0;
	width: calc(100% + 8px);
	height: 28px;
	margin: 0;
	background: none;
	pointer-events: none;
	-webkit-appearance: none;
	appearance: none;
}
.jlf-range input[type="range"]::-webkit-slider-thumb { width: 24px; height: 24px; border: 2px solid var(--jlf-text); border-radius: 50%; background: var(--jlf-surface); pointer-events: auto; cursor: pointer; -webkit-appearance: none; }
.jlf-range input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border: 2px solid var(--jlf-text); border-radius: 50%; background: var(--jlf-surface); pointer-events: auto; cursor: pointer; }
.jlf-range input[type="range"]::-webkit-slider-runnable-track { background: none; }
.jlf-price { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.jlf-price label { display: flex; flex-direction: column; gap: 4px; margin: 0; color: var(--jlf-muted); font-size: var(--jlf-xs); }
.jlf-price input { width: 100%; min-height: 46px; padding: 0 12px; border: 1.5px solid var(--jlf-line); border-radius: var(--jlf-radius); background: var(--jlf-surface); color: var(--jlf-text); font-size: var(--jlf-sm); box-shadow: none; }

.jlf-panel__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.jlf-reset { color: var(--jlf-text) !important; font-size: var(--jlf-sm); text-decoration: underline; }
.jlf-apply {
	min-height: 50px;
	padding: 0 22px;
	border: 0;
	border-radius: var(--jl-radius-btn, 14px);
	background: var(--jlf-accent);
	color: var(--jlf-accent-text);
	font-size: var(--jlf-sm);
	font-weight: 600;
	cursor: pointer;
}
/* The list updates instantly, so the apply button is only needed in the mobile drawer (and without JS, see <noscript>). */
.jlf-panel__foot .jlf-apply { display: none; }
.jlf-empty { color: var(--jlf-muted); }

/* Loading state */
.jlf-loading #primary { opacity: .5; transition: opacity .15s ease; pointer-events: none; }

/* Mobile / tablet: drawer ------------------------------------------- */
@media (max-width: 992px) {
	.jlf-open { display: inline-flex; }
	.jlf-sort span { display: none; }
	.jlf-panel {
		position: fixed;
		inset: 0 0 0 auto;
		z-index: 9999;
		display: flex;
		flex-direction: column;
		width: min(420px, 92vw);
		background: var(--jlf-surface);
		box-shadow: -10px 0 40px rgba(0, 0, 0, .15);
		transform: translateX(100%);
		visibility: hidden;
		transition: transform .25s ease, visibility .25s;
	}
	.jlf-drawer-open .jlf-panel { transform: none; visibility: visible; }
	.jlf-drawer-open { overflow: hidden; }
	.jlf-panel__head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--jlf-line); }
	.jlf-panel__title { margin: 0; font-size: var(--jl-text-lg, 20px); font-weight: 600; }
	.jlf-close { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; background: none; color: var(--jlf-text); cursor: pointer; }
	.jlf-form { flex: 1; overflow-y: auto; padding: 20px 18px 0; }
	.jlf-panel__foot { position: sticky; bottom: 0; margin: 0 -18px; padding: 14px 18px; border-top: 1px solid var(--jlf-line); background: var(--jlf-surface); }
	.jlf-panel__foot .jlf-apply { display: inline-block; flex: 1; }
	.jlf-overlay { position: fixed; inset: 0; z-index: 9998; background: rgba(10, 18, 13, .45); }
	.jlf-overlay[hidden] { display: none; }
}

/* Themes with their own mobile filter drawer (Shoptimizer): neutralise it,
   our panel is the drawer. */
@media (max-width: 992px) {
	.jlf-sidebar #secondary,
	.jlf-sidebar.secondary-wrapper {
		position: static !important;
		left: auto !important;
		width: auto !important;
		height: auto !important;
		padding: 0 !important;
		visibility: visible !important;
		opacity: 1 !important;
		transform: none !important;
		transition: none !important;
		background: none !important;
		overflow: visible !important;
	}
	body:has(.jlf-sidebar) .mobile-filter,
	body:has(.jlf-sidebar) .shoptimizer-mobile-toggle,
	body:has(.jlf-sidebar) .filters.close-drawer { display: none !important; }
}

/* Never wider than the column (no horizontal scroll) */
.jlf-panel, .jlf-form, .jlf-group, .jlf-options { min-width: 0; max-width: 100%; }
.jlf-option__name { min-width: 0; overflow-wrap: anywhere; }
.jlf-price { min-width: 0; }
.jlf-price label, .jlf-price input { min-width: 0; }
.jlf-range { margin-left: 12px; margin-right: 12px; }
.jlf-group--color .jlf-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.jlf-group--color .jlf-options li { min-width: 0; }
.jlf-group--color .jlf-option { width: 100%; min-width: 0; box-sizing: border-box; }

/* Toolbar layout: [Filtrid] [count] ........ [sort] / active filters row */
.jlf-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin: 0 0 24px; }
.jlf-count { margin: 0; color: var(--jlf-text); font-size: var(--jl-text-base, 18px); font-weight: 600; }
.jlf-sort { margin-left: auto; }
.jlf-active-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 12px;
	width: 100%;
	padding: 12px 16px;
	border-radius: var(--jl-radius-sm, 12px);
	background: var(--jlf-surface);
}
.jlf-active-row__label { color: var(--jlf-muted); font-size: var(--jlf-sm); }
.jlf-active-row .jlf-active a { background: var(--jlf-accent-soft); }
a.jlf-clear { margin-left: auto; color: var(--jlf-text) !important; font-size: var(--jlf-sm); font-weight: 600; text-decoration: underline !important; text-underline-offset: 4px; }
@media (max-width: 640px) {
	.jlf-active-row { padding: 10px 12px; }
	a.jlf-clear { margin-left: 0; }
}
