/**
 * WBS Elasticsearch Filters — Styles
 *
 * BEM naming, CSS custom properties for theming.
 * ~3KB minified.
 */

:root {
	--wesf-primary: #333;
	--wesf-accent: #c9a96e;
	--wesf-bg: #fff;
	--wesf-border: #e0e0e0;
	--wesf-text: #333;
	--wesf-text-muted: #888;
	--wesf-radius: 4px;
	--wesf-swatch-size: 28px;
	--wesf-sidebar-width: 260px;
	--wesf-transition: 0.2s ease;
}

/* --- Sidebar layout --- */

.wesf-sidebar {
	width: var(--wesf-sidebar-width);
	flex-shrink: 0;
	font-size: 14px;
	color: var(--wesf-text);
}

.wesf-sidebar__toggle {
	display: none;
}

.wesf-sidebar__header {
	display: none;
}

.wesf-sidebar__overlay {
	display: none;
}

/* --- Filter group --- */

.wesf-group {
	border-bottom: 1px solid var(--wesf-border);
	padding: 12px 0;
}

.wesf-group:first-child {
	padding-top: 0;
}

.wesf-group__title {
	margin: 0 0 8px;
	font-size: 14px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	cursor: pointer;
	display: flex;
	justify-content: space-between;
	align-items: center;
	user-select: none;
}

.wesf-group__toggle {
	font-size: 10px;
	transition: transform var(--wesf-transition);
}

.wesf-group--collapsed .wesf-group__toggle {
	transform: rotate(-90deg);
}

.wesf-group--collapsed .wesf-group__content {
	display: none;
}

/* --- Checkbox list --- */

.wesf-checkbox-list {
	list-style: none;
	margin: 0;
	padding: 0;
	max-height: 220px;
	overflow-y: auto;
}

.wesf-checkbox-item {
	margin: 0;
	padding: 2px 0;
}

.wesf-checkbox-item label {
	display: flex;
	align-items: center;
	gap: 6px;
	cursor: pointer;
	font-size: 13px;
	line-height: 1.4;
}

.wesf-checkbox-item input[type="checkbox"] {
	width: 16px;
	height: 16px;
	margin: 0;
	flex-shrink: 0;
	accent-color: var(--wesf-accent);
}

.wesf-checkbox-item__count {
	color: var(--wesf-text-muted);
	font-size: 12px;
	margin-left: auto;
}

.wesf-checkbox-item--active .wesf-checkbox-item__label {
	font-weight: 600;
}

/* --- Color swatches --- */

.wesf-swatches {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 4px 0;
}

.wesf-swatch {
	width: var(--wesf-swatch-size);
	height: var(--wesf-swatch-size);
	border-radius: 50%;
	border: 2px solid var(--wesf-border);
	cursor: pointer;
	position: relative;
	padding: 0;
	transition: border-color var(--wesf-transition), box-shadow var(--wesf-transition);
}

.wesf-swatch:hover {
	border-color: var(--wesf-primary);
	box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.wesf-swatch--active {
	border-color: var(--wesf-accent);
	box-shadow: 0 0 0 2px var(--wesf-accent);
}

.wesf-swatch__check {
	display: none;
}

.wesf-swatch--active .wesf-swatch__check {
	display: block;
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 12px;
	height: 12px;
}

.wesf-swatch--active .wesf-swatch__check::after {
	content: '✓';
	color: #fff;
	font-size: 11px;
	text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

.wesf-swatch--no-color {
	background: linear-gradient(135deg, #eee 45%, #ccc 55%);
}

/* --- Price range slider --- */

.wesf-price-range {
	padding: 8px 0;
}

.wesf-price-range__track {
	position: relative;
	height: 2px;
	background: transparent;
	border-radius: 1px;
	margin: 16px 0;
}

.wesf-price-range__fill {
	position: absolute;
	top: 0;
	height: 100%;
	background: #c6c6c6;
	border-radius: 1px;
}

.wesf-price-range__input {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 2px;
	-webkit-appearance: none !important;
	appearance: none !important;
	background: transparent !important;
	pointer-events: none;
	margin: 0;
	outline: none;
	z-index: 2;
}

.wesf-price-range__input::-webkit-slider-runnable-track {
	-webkit-appearance: none !important;
	appearance: none !important;
	background: transparent !important;
	border: none !important;
	border-color: transparent !important;
	box-shadow: none !important;
	height: 0 !important;
}

.wesf-price-range__input::-moz-range-track {
	background: transparent !important;
	border: none !important;
	border-color: transparent !important;
	box-shadow: none !important;
	height: 0 !important;
}

.wesf-price-range__input::-ms-track {
	background: transparent !important;
	border: none !important;
	color: transparent !important;
	height: 0 !important;
}

.wesf-price-range__input::-webkit-slider-thumb {
	-webkit-appearance: none !important;
	appearance: none !important;
	width: 16px !important;
	height: 16px !important;
	border-radius: 50% !important;
	background: #c6c6c6 !important;
	border: none !important;
	box-shadow: none !important;
	cursor: pointer;
	pointer-events: all;
	margin-top: -7px;
}

.wesf-price-range__input::-moz-range-thumb {
	width: 16px !important;
	height: 16px !important;
	border-radius: 50% !important;
	background: #c6c6c6 !important;
	border: none !important;
	box-shadow: none !important;
	cursor: pointer;
	pointer-events: all;
}

.wesf-price-range__labels {
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-size: 13px;
}

.wesf-price-range__separator {
	color: var(--wesf-text-muted);
}

/* --- Active filters --- */

.wesf-active-filters {
	padding: 8px 0 12px;
	border-bottom: 1px solid var(--wesf-border);
	margin-bottom: 4px;
}

.wesf-active-filters__list {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.wesf-active-filters__chip {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 4px 8px;
	background: #f5f5f5 !important;
	color: #333 !important;
	border: 1px solid var(--wesf-border) !important;
	border-radius: 20px;
	font-size: 12px !important;
	cursor: pointer;
	transition: background var(--wesf-transition);
	line-height: 1.4;
}

.wesf-active-filters__chip span {
	color: #333 !important;
}

.wesf-active-filters__chip:hover {
	background: #eee !important;
}

.wesf-active-filters__remove {
	font-size: 14px;
	font-weight: bold;
	line-height: 1;
	color: var(--wesf-text-muted) !important;
}

.wesf-active-filters__clear {
	font-size: 12px;
	color: var(--wesf-accent) !important;
	background: none !important;
	border: none !important;
	cursor: pointer;
	text-decoration: underline;
	padding: 4px 0;
}

/* --- Loading state --- */

.wesf-loading {
	opacity: 0.5;
	pointer-events: none;
	transition: opacity 0.15s;
}

/* --- Select search --- */

.wesf-select-search {
	position: relative;
}

.wesf-select-search__trigger {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 8px 12px;
	background: var(--wesf-bg);
	border: 1px solid var(--wesf-border);
	border-radius: var(--wesf-radius);
	font-size: 13px;
	cursor: pointer;
	color: var(--wesf-text);
	transition: border-color var(--wesf-transition);
}

.wesf-select-search__trigger:hover {
	border-color: var(--wesf-accent);
	background: var(--wesf-bg) !important;
	color: var(--wesf-text) !important;
}

.wesf-select-search__label {
	flex: 1;
	text-align: left;
	color: var(--wesf-text-muted);
}

.wesf-select-search__label--has-selection {
	color: var(--wesf-text);
	font-weight: 600;
}

.wesf-select-search__arrow {
	font-size: 10px;
	margin-left: 8px;
	transition: transform var(--wesf-transition);
}

.wesf-select-search[aria-expanded="true"] .wesf-select-search__arrow {
	transform: rotate(180deg);
}

.wesf-select-search__dropdown {
	position: absolute;
	top: calc(100% + 4px);
	left: 0;
	right: 0;
	background: var(--wesf-bg);
	border: 1px solid var(--wesf-border);
	border-radius: var(--wesf-radius);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
	z-index: 100;
	max-height: 300px;
	display: flex;
	flex-direction: column;
}

.wesf-select-search__dropdown[hidden] {
	display: none;
}

.wesf-select-search__search-wrap {
	padding: 8px;
	border-bottom: 1px solid var(--wesf-border);
	flex-shrink: 0;
}

.wesf-select-search__search {
	width: 100%;
	padding: 6px 8px;
	border: 1px solid var(--wesf-border);
	border-radius: var(--wesf-radius);
	font-size: 13px;
	outline: none;
	box-sizing: border-box;
}

.wesf-select-search__search:focus {
	border-color: var(--wesf-accent);
}

.wesf-select-search__options {
	list-style: none;
	margin: 0;
	padding: 4px 0;
	overflow-y: auto;
	flex: 1;
}

.wesf-select-search__option {
	padding: 0;
}

.wesf-select-search__option[hidden] {
	display: none;
}

.wesf-select-search__option label {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	cursor: pointer;
	font-size: 13px;
	transition: background 0.1s;
}

.wesf-select-search__option label:hover {
	background: #f8f8f8;
}

.wesf-select-search__option input[type="checkbox"] {
	width: 16px;
	height: 16px;
	margin: 0;
	flex-shrink: 0;
	accent-color: var(--wesf-accent);
}

.wesf-select-search__option-count {
	color: var(--wesf-text-muted);
	font-size: 12px;
	margin-left: auto;
}

/* --- Mobile responsive --- */

@media (max-width: 768px) {
	.wesf-sidebar {
		width: 100%;
	}

	.wesf-sidebar__toggle {
		display: flex;
		align-items: center;
		gap: 8px;
		width: 100%;
		padding: 10px 16px;
		background: var(--wesf-bg);
		border: 1px solid var(--wesf-border);
		border-radius: var(--wesf-radius);
		font-size: 14px;
		font-weight: 600;
		cursor: pointer;
		margin-bottom: 12px;
	}

	.wesf-sidebar__badge {
		background: var(--wesf-accent);
		color: #fff;
		font-size: 11px;
		padding: 2px 6px;
		border-radius: 10px;
		margin-left: auto;
	}

	.wesf-sidebar__panel {
		position: fixed;
		top: 0;
		left: -100%;
		width: 85%;
		max-width: 320px;
		height: 100vh;
		background: var(--wesf-bg);
		z-index: 99999;
		overflow-y: auto;
		padding: 16px;
		transition: left 0.3s ease;
		box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
	}

	.wesf-sidebar__panel--open {
		left: 0;
	}

	.wesf-sidebar__header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding-bottom: 12px;
		border-bottom: 1px solid var(--wesf-border);
		margin-bottom: 12px;
	}

	.wesf-sidebar__title {
		font-size: 18px;
		font-weight: 600;
	}

	.wesf-sidebar__close {
		font-size: 24px;
		background: none;
		border: none;
		cursor: pointer;
		padding: 4px 8px;
		line-height: 1;
	}

	.wesf-sidebar__overlay {
		display: none;
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background: rgba(0, 0, 0, 0.4);
		z-index: 99998;
	}

	.wesf-sidebar__overlay--visible {
		display: block;
	}

	body.wesf-drawer-open {
		overflow: hidden;
	}
}
