/**
 * Advanced WooCommerce Smart Filters - front-end styles.
 * All selectors are scoped/prefixed with .awc- to avoid theme/plugin conflicts.
 */

:root {
	--awc-primary: #7f54b3;
	--awc-text: #23282d;
	--awc-bg: #ffffff;
	--awc-border: #e2e2e2;
	--awc-radius: 8px;
	--awc-font-size: 14px;
	--awc-sidebar-width: 280px;
	--awc-muted: #767676;
	--awc-danger: #e0455f;
	--awc-hover-bg: rgba(0, 0, 0, 0.04);
	--awc-panel-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.awc-filters-root {
	font-size: var(--awc-font-size);
	color: var(--awc-text);
	--awc-track-bg: #e2e2e2;
}

.awc-filters-root * {
	box-sizing: border-box;
}

/* ---------- Wrapper / Sidebar shell ---------- */

.awc-filters-wrapper {
	background: #ffffff;
	border: 1px solid var(--awc-border);
	border-radius: var(--awc-radius);
	box-shadow: var(--awc-panel-shadow);
	width: 100%;
	max-width: var(--awc-sidebar-width);
	padding: 18px;
}

.awc-filters-wrapper.awc-sticky {
	position: sticky;
	top: 20px;
	/*max-height: calc(100vh - 40px);*/
	overflow-y: auto;
}

.awc-filters-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 12px;
}

.awc-filters-title {
	margin: 0;
	font-size: 1.05em;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.03em;
}

.awc-mobile-close {
	display: none;
	background: none;
	border: none;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	color: #23282d;
}

/* ---------- Mobile toggle button + drawer ---------- */

.awc-mobile-toggle {
	display: none;
	align-items: center;
	gap: 8px;
	padding: 10px 16px;
	background: var(--awc-primary);
	color: #fff;
	border: none;
	border-radius: var(--awc-radius);
	cursor: pointer;
	font-size: var(--awc-font-size);
	font-weight: 600;
	margin-bottom: 16px;
}

.awc-icon-filter {
	width: 16px;
	height: 16px;
	display: inline-block;
	position: relative;
}
.awc-icon-filter::before,
.awc-icon-filter::after {
	content: "";
	position: absolute;
	background: currentColor;
	left: 0;
}
.awc-icon-filter::before {
	top: 2px;
	width: 16px;
	height: 2px;
}
.awc-icon-filter::after {
	top: 10px;
	width: 10px;
	height: 2px;
}

.awc-mobile-overlay {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.5);
	z-index: 100000;
}

.awc-mobile-overlay.is-active {
	display: block;
}

/* ---------- Filters sections ---------- */

.awc-filter-section {
	border-bottom: 1px solid var(--awc-border);
	padding: 10px 0;
}

.awc-filter-section:last-child {
	border-bottom: none;
}

.awc-filter-section-toggle {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	background: none;
	border: none;
	font-size: 0.95em;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	padding: 8px 2px;
	cursor: pointer;
	color: #131117;
}

.awc-toggle-icon {
	width: 10px;
	height: 10px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg);
	transition: transform 0.2s ease;
}

.awc-filter-section-toggle[aria-expanded="true"] .awc-toggle-icon {
	transform: rotate(-135deg);
}

.awc-filter-section-content {
	padding-top: 10px;
	animation: awc-fade-in 0.2s ease;
}

@keyframes awc-fade-in {
	from { opacity: 0; transform: translateY(-4px); }
	to { opacity: 1; transform: translateY(0); }
}

.awc-plain-list,
.awc-swatch-list,
.awc-chip-list,
.awc-category-tree,
.awc-rating-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.awc-plain-list li,
.awc-category-item {
	margin-bottom: 2px;
}

.awc-plain-list label,
.awc-category-item > label,
.awc-rating-item label {
	display: flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	font-size: 0.95em;
	padding: 6px 8px;
	border-radius: calc(var(--awc-radius) / 1.5);
	transition: background-color 0.15s ease;
}

.awc-plain-list label:hover,
.awc-category-item > label:hover,
.awc-rating-item label:hover,
.awc-swatch-item label:hover,
.awc-chip-item label:hover {
	background-color: var(--awc-hover-bg);
}

.awc-cat-label,
.awc-plain-list label > span:not(.awc-term-count) {
	flex: 1 1 auto;
	min-width: 0;
	overflow-wrap: break-word;
}

.awc-term-count {
	margin-left: auto;
	color: var(--awc-muted);
	font-size: 0.85em;
	white-space: nowrap;
	flex-shrink: 0;
}

/* ---------- Themed checkboxes (category / stock / rating / brand) ---------- */

.awc-plain-list input[type="checkbox"],
.awc-category-item > label input[type="checkbox"],
.awc-rating-item input[type="checkbox"] {
	-webkit-appearance: none;
	appearance: none;
	width: 18px;
	height: 18px;
	min-width: 18px;
	flex-shrink: 0;
	margin: 0;
	border: 2px solid var(--awc-border);
	border-radius: 4px;
	background-color: transparent;
	cursor: pointer;
	position: relative;
	transition: background-color 0.15s ease, border-color 0.15s ease;
}

.awc-plain-list input[type="checkbox"]:checked,
.awc-category-item > label input[type="checkbox"]:checked,
.awc-rating-item input[type="checkbox"]:checked {
	background-color: var(--awc-primary);
	border-color: var(--awc-primary);
}

.awc-plain-list input[type="checkbox"]:checked::after,
.awc-category-item > label input[type="checkbox"]:checked::after,
.awc-rating-item input[type="checkbox"]:checked::after {
	content: "";
	position: absolute;
	left: 5px;
	top: 1px;
	width: 5px;
	height: 9px;
	border: solid #fff;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}

.awc-scroll-list {
	max-height: 220px;
	overflow-y: auto;
	padding-right: 4px;
}

.awc-inline-search {
	width: 100%;
	padding: 6px 10px;
	border: 1px solid var(--awc-border);
	border-radius: calc(var(--awc-radius) / 1.5);
	margin-bottom: 10px;
	font-size: 0.9em;
	background: var(--awc-bg);
	color: var(--awc-text);
}

/* ---------- Category tree ---------- */

.awc-category-children {
	list-style: none;
	margin: 6px 0 0 20px;
	padding: 0;
}

.awc-cat-label {
	flex: 1 1 auto;
}

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

.awc-swatch-item label {
	display: flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	padding: 4px 2px;
	border-radius: 4px;
}

.awc-swatch-item input[type="checkbox"] {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}

.awc-swatch {
	display: inline-block;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	border: 2px solid var(--awc-border);
	transition: box-shadow 0.15s ease, transform 0.15s ease;
	flex-shrink: 0;
}

.awc-swatch-item input:checked + .awc-swatch {
	box-shadow: 0 0 0 2px var(--awc-bg), 0 0 0 4px #e2e2e2;
	transform: scale(1.05);
}

.awc-swatch-label {
	flex: 1 1 auto;
    	color: #23282d;
}

/* ---------- Size chips ---------- */

.awc-chip-list {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.awc-chip-item input[type="checkbox"] {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}
li.awc-category-item span {
    color: #23282d;
}
ul.awc-plain-list li span {
    color: #23282d;
}

.awc-chip {
	color: #23282d;
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 6px 12px;
	border: 1px solid var(--awc-border);
	border-radius: 999px;
	cursor: pointer;
	font-size: 0.9em;
	transition: all 0.15s ease;
	user-select: none;
}

.awc-chip-item input:checked + .awc-chip {
	background: var(--awc-primary);
	border-color: var(--awc-primary);
	color: #fff;
}

.awc-chip em {
	font-style: normal;
	opacity: 0.75;
	font-size: 0.85em;
}

/* ---------- Price filter ---------- */

.awc-price-slider {
	position: relative;
	height: 36px;
	margin-bottom: 10px;
}

.awc-price-slider-track,
.awc-price-slider-range {
	position: absolute;
	top: 16px;
	height: 4px;
	border-radius: 2px;
}

.awc-price-slider-track {
	left: 0;
	right: 0;
	background: var(--awc-track-bg);
}

.awc-price-slider-range {
	background: var(--awc-primary);
}

.awc-price-range {
	position: absolute;
	top: 10px;
	left: 0;
	width: 100%;
	margin: 0;
	pointer-events: none;
	appearance: none;
	background: none;
	height: 20px;
}

.awc-price-range::-webkit-slider-thumb {
	appearance: none;
	pointer-events: auto;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--awc-primary);
	border: 2px solid #fff;
	box-shadow: 0 0 0 1px var(--awc-primary);
	cursor: pointer;
	margin-top: -7px;
}

.awc-price-range::-moz-range-thumb {
	pointer-events: auto;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--awc-primary);
	border: 2px solid #fff;
	box-shadow: 0 0 0 1px var(--awc-primary);
	cursor: pointer;
}

.awc-price-range::-webkit-slider-runnable-track {
	background: transparent;
}

.awc-price-inputs {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 10px;
}

.awc-price-input-group {
	display: flex;
	align-items: center;
	gap: 4px;
	border: 1px solid var(--awc-border);
	border-radius: calc(var(--awc-radius) / 1.5);
	padding: 6px 10px;
	flex: 1 1 90px;
	min-width: 0;
	background-color: #ffffff;
	color: var(--awc-muted);
}

.awc-price-number {
	width: 100%;
	min-width: 0;
	border: none;
	background-color: transparent;
	color: var(--awc-text);
	font-size: 0.9em;
	font-family: inherit;
	-moz-appearance: textfield;
	appearance: textfield;
}

.awc-price-number::-webkit-outer-spin-button,
.awc-price-number::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.awc-price-number:focus {
	outline: none;
}

.awc-price-sep {
	color: var(--awc-muted);
}

/* ---------- Star rating ---------- */

.awc-stars {
	display: inline-flex;
	color: var(--awc-track-bg);
	font-size: 16px;
	letter-spacing: 1px;
}

.awc-star.is-filled {
	color: #f0ad4e;
}

/* ---------- Buttons ---------- */

.awc-btn {
	display: inline-block;
	padding: 10px 16px;
	border-radius: calc(var(--awc-radius) / 1.5);
	border: 1px solid var(--awc-primary);
	background: var(--awc-primary);
	color: #fff;
	cursor: pointer;
	font-size: 0.85em;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	transition: opacity 0.15s ease, transform 0.1s ease;
}

.awc-btn:hover {
	opacity: 0.9;
}

.awc-btn:active {
	transform: scale(0.98);
}

.awc-btn-apply-price {
	width: 100%;
	margin-bottom: 20px;
}

.awc-btn-clear-all {
	width: 100%;
	background: transparent;
	color: var(--awc-danger);
	border: 1.5px solid var(--awc-danger);
	border-radius: 999px;
	padding: 12px 16px;
}

.awc-btn-clear-all:hover {
	background: var(--awc-danger);
	color: #fff;
	opacity: 1;
}

.awc-filters-footer {
	margin-top: 14px;
}

/* ---------- Active filter chips ---------- */

.awc-active-filters {
	margin-bottom: 12px;
}

.awc-active-filters-list {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.awc-active-filters-list:empty {
	display: none;
}

.awc-active-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: var(--awc-track-bg);
	color: var(--awc-text);
	border-radius: 999px;
	padding: 4px 6px 4px 12px;
	font-size: 0.85em;
}

.awc-active-chip button {
	background: none;
	border: none;
	cursor: pointer;
	color: var(--awc-text);
	font-size: 14px;
	line-height: 1;
	border-radius: 50%;
	width: 18px;
	height: 18px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.awc-active-chip button:hover {
	background: rgba(0, 0, 0, 0.1);
}

/* ---------- Skeleton loading ---------- */

.awc-filters-skeleton {
	display: none;
}

.awc-filters-skeleton.is-active {
	display: block;
}

.awc-filters-sections.is-loading {
	display: none;
}

.awc-skeleton-block {
	margin-bottom: 18px;
}

.awc-skeleton-line {
	height: 12px;
	border-radius: 4px;
	margin-bottom: 8px;
	background: linear-gradient(90deg, var(--awc-track-bg) 25%, rgba(255,255,255,0.6) 37%, var(--awc-track-bg) 63%);
	background-size: 400% 100%;
	animation: awc-shimmer 1.4s ease infinite;
}

.awc-skeleton-title {
	width: 40%;
	height: 14px;
}

@keyframes awc-shimmer {
	0% { background-position: 100% 50%; }
	100% { background-position: 0 50%; }
}

/* ---------- Product grid loading state (target container) ---------- */

.awc-products-target-wrapper {
	position: relative;
}

.awc-products-target.is-loading {
	opacity: 0.4;
	pointer-events: none;
	transition: opacity 0.2s ease;
}

.awc-result-count {
	font-size: 0.9em;
	color: var(--awc-muted);
	margin-bottom: 12px;
}

.awc-pagination-target ul {
	display: flex;
	list-style: none;
	gap: 6px;
	padding: 0;
	margin: 20px 0 0;
	flex-wrap: wrap;
}

.awc-pagination-target .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 34px;
	height: 34px;
	padding: 0 8px;
	border: 1px solid var(--awc-border);
	border-radius: calc(var(--awc-radius) / 1.5);
	text-decoration: none;
	color: var(--awc-text);
}

.awc-pagination-target .page-numbers.current {
	background: var(--awc-primary);
	border-color: var(--awc-primary);
	color: #fff;
}

/* ---------- Responsive: mobile drawer ---------- */

@media (max-width: 768px) {
	.awc-mobile-toggle {
		display: inline-flex;
		position: fixed;
		bottom: 0px;
		left: 0px;
		z-index: 99998;
		margin: 0;
		box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
		border-radius: 999px;
		padding: 10px 18px;
	}

	.awc-filters-wrapper {
		position: fixed;
		top: 0;
		left: 0;
		bottom: 0;
		max-width: 85vw;
		width: 320px;
		height: 100vh;
		overflow-y: auto;
		z-index: 100001;
		transform: translateX(-105%);
		transition: transform 0.28s ease;
		border-radius: 0;
		margin: 0;
	}

	.awc-filters-wrapper.is-open {
		transform: translateX(0);
	}

	.awc-mobile-close {
		display: inline-block;
	}
}

/* ---------- Dark mode ---------- */

@media (prefers-color-scheme: dark) {
	.awc-filters-root:not(.awc-force-light) {
		--awc-text: #f2f2f4;
		--awc-bg: #18181b;
		--awc-border: #333338;
		--awc-track-bg: #3a3a42;
		--awc-muted: #9a9aa2;
		--awc-hover-bg: rgba(255, 255, 255, 0.06);
		--awc-panel-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
		color-scheme: dark;
	}
}

.awc-filters-root.awc-force-dark {
	--awc-text: #f2f2f4;
	--awc-bg: #18181b;
	--awc-border: #333338;
	--awc-track-bg: #3a3a42;
	--awc-muted: #9a9aa2;
	--awc-hover-bg: rgba(255, 255, 255, 0.06);
	--awc-panel-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
	color-scheme: dark;
}

/* ---------- Accessibility ---------- */

.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	white-space: nowrap;
}

.awc-filters-wrapper a:focus,
.awc-filters-wrapper button:focus,
.awc-filters-wrapper input:focus {
	outline: 2px solid var(--awc-primary);
	outline-offset: 2px;
}
