/**
 * WooCommerce Smart Product Filter Pro - Frontend Stylesheet
 *
 * Implements clean, modern sidebar design tokens:
 * - Heading blue: #3188D8
 * - Section heading: #3F3F3F
 * - Option text: #777789
 * - Divider: #D9D9D9
 * - Sidebar background: #F8F8F8
 * - Checkbox border: #858585
 */

:root {
	--wspf-heading-blue: #3188D8;
	--wspf-section-heading: #3F3F3F;
	--wspf-option-text: #777789;
	--wspf-divider: #D9D9D9;
	--wspf-sidebar-bg: #F8F8F8;
	--wspf-checkbox-border: #858585;
	--wspf-checkbox-checked-bg: #3188D8;
	--wspf-radius-sm: 4px;
	--wspf-radius-md: 8px;
	--wspf-transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
	--wspf-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Sidebar Wrapper */
.wspf-filter-sidebar-wrapper {
	font-family: var(--wspf-font-family);
	position: relative;
	width: 100%;
	box-sizing: border-box;
}

.wspf-filter-sidebar-wrapper *,
.wspf-filter-sidebar-wrapper *::before,
.wspf-filter-sidebar-wrapper *::after {
	box-sizing: border-box;
}

/* Sidebar Container */
.wspf-sidebar {
	background-color: var(--wspf-sidebar-bg);
	border: 1px solid var(--wspf-divider);
	border-radius: var(--wspf-radius-md);
	padding: 24px 20px;
	position: relative;
	width: 100%;
}

/* Mobile Drawer Header (Hidden on Desktop) */
.wspf-drawer-header {
	display: none;
	align-items: center;
	justify-content: space-between;
	padding-bottom: 16px;
	margin-bottom: 16px;
	border-bottom: 1px solid var(--wspf-divider);
}

.wspf-drawer-title {
	margin: 0;
	font-size: 1.15rem;
	font-weight: 700;
	color: var(--wspf-heading-blue);
}

.wspf-drawer-close-btn {
	background: none;
	border: none;
	font-size: 28px;
	line-height: 1;
	color: var(--wspf-section-heading);
	cursor: pointer;
	padding: 4px 8px;
}

/* Main Sidebar Header */
.wspf-sidebar-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding-bottom: 14px;
	border-bottom: 1px solid var(--wspf-divider);
	margin-bottom: 8px;
}

.wspf-main-title {
	margin: 0;
	font-size: 1.35rem;
	font-weight: 700;
	letter-spacing: -0.01em;
	color: var(--wspf-heading-blue);
}

.wspf-clear-all-btn {
	background: none;
	border: none;
	font-size: 0.85rem;
	font-weight: 600;
	color: #999;
	text-decoration: underline;
	cursor: pointer;
	padding: 0;
	transition: var(--wspf-transition);
}

.wspf-clear-all-btn:hover,
.wspf-clear-all-btn:focus-visible {
	color: #d32f2f;
}

/* Active Chips Container */
.wspf-active-chips-container {
	padding: 12px 0 6px 0;
	border-bottom: 1px solid var(--wspf-divider);
	margin-bottom: 12px;
}

.wspf-chips-list {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.wspf-chip-item {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: #ffffff;
	border: 1px solid var(--wspf-divider);
	border-radius: 14px;
	padding: 4px 10px;
	font-size: 0.78rem;
	color: var(--wspf-section-heading);
	font-weight: 500;
	transition: var(--wspf-transition);
}

.wspf-chip-item:hover {
	border-color: #b0b0b0;
}

.wspf-chip-remove {
	cursor: pointer;
	color: #999;
	font-size: 14px;
	font-weight: 700;
	line-height: 1;
}

.wspf-chip-remove:hover {
	color: #d32f2f;
}

/* Accordion Section */
.wspf-accordion-group {
	border-bottom: 1px solid var(--wspf-divider);
	padding: 16px 0;
}

.wspf-accordion-group:last-child {
	border-bottom: none;
	padding-bottom: 0;
}

.wspf-accordion-header {
	margin: 0;
}

.wspf-accordion-trigger {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	background: none;
	border: none;
	padding: 4px 0;
	text-align: left;
	font-family: inherit;
	cursor: pointer;
	user-select: none;
	outline: none;
}

.wspf-accordion-trigger:focus-visible {
	outline: 2px solid var(--wspf-heading-blue);
	outline-offset: 3px;
	border-radius: 2px;
}

.wspf-accordion-label {
	font-size: 1.05rem;
	font-weight: 700;
	color: var(--wspf-section-heading);
	letter-spacing: -0.01em;
	transition: var(--wspf-transition);
}

.wspf-accordion-trigger:hover .wspf-accordion-label {
	color: #000000;
}

.wspf-accordion-chevron {
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--wspf-section-heading);
	transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.wspf-accordion-group.is-expanded .wspf-accordion-chevron {
	transform: rotate(180deg);
}

/* Accordion Content */
.wspf-accordion-content {
	padding-top: 14px;
	padding-bottom: 4px;
}

/* Search input inside group */
.wspf-search-box {
	margin-bottom: 12px;
}

.wspf-option-search-input {
	width: 100%;
	padding: 6px 10px;
	border: 1px solid var(--wspf-divider);
	border-radius: var(--wspf-radius-sm);
	font-size: 0.85rem;
	background: #ffffff;
	color: var(--wspf-section-heading);
	outline: none;
	transition: var(--wspf-transition);
}

.wspf-option-search-input:focus {
	border-color: var(--wspf-heading-blue);
	box-shadow: 0 0 0 1px var(--wspf-heading-blue);
}

/* Options List */
.wspf-options-list {
	display: flex;
	flex-direction: column;
	gap: 12px;
	max-height: 280px;
	overflow-y: auto;
	scrollbar-width: thin;
	scrollbar-color: var(--wspf-divider) transparent;
}

.wspf-options-list::-webkit-scrollbar {
	width: 4px;
}

.wspf-options-list::-webkit-scrollbar-thumb {
	background-color: var(--wspf-divider);
	border-radius: 4px;
}

/* Checkbox Option Item */
.wspf-checkbox-item {
	display: flex;
	align-items: center;
	cursor: pointer;
	user-select: none;
	position: relative;
	font-size: 0.92rem;
	line-height: 1.4;
	color: var(--wspf-option-text);
	transition: var(--wspf-transition);
}

.wspf-checkbox-item:hover {
	color: #222222;
}

/* Indented depth for hierarchical terms */
.wspf-checkbox-item.wspf-depth-1 {
	padding-left: 16px;
}
.wspf-checkbox-item.wspf-depth-2 {
	padding-left: 32px;
}
.wspf-checkbox-item.wspf-depth-3 {
	padding-left: 48px;
}

/* Native Hidden Checkbox */
.wspf-checkbox-input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
	margin: 0;
	pointer-events: none;
}

/* Custom Checkbox Box */
.wspf-checkbox-custom {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 17px;
	height: 17px;
	min-width: 17px;
	border: 1.5px solid var(--wspf-checkbox-border);
	border-radius: 3px;
	background-color: #ffffff;
	margin-right: 11px;
	transition: var(--wspf-transition);
}

.wspf-check-icon {
	width: 11px;
	height: 11px;
	opacity: 0;
	transform: scale(0.5);
	transition: var(--wspf-transition);
}

/* Checked State */
.wspf-checkbox-input:checked + .wspf-checkbox-custom {
	background-color: var(--wspf-checkbox-checked-bg);
	border-color: var(--wspf-checkbox-checked-bg);
}

.wspf-checkbox-input:checked + .wspf-checkbox-custom .wspf-check-icon {
	opacity: 1;
	transform: scale(1);
}

/* Checked Text highlight */
.wspf-checkbox-input:checked ~ .wspf-option-label {
	color: #111111;
	font-weight: 600;
}

/* Focus Visible */
.wspf-checkbox-input:focus-visible + .wspf-checkbox-custom {
	outline: 2px solid var(--wspf-heading-blue);
	outline-offset: 2px;
}

/* Option Label & Product Count Badge */
.wspf-option-label {
	flex-grow: 1;
	transition: color 0.15s ease;
}

.wspf-option-count {
	font-size: 0.82rem;
	color: #888899;
	margin-left: 6px;
	font-variant-numeric: tabular-nums;
}

/* Manual Apply Button (if enabled) */
.wspf-filter-actions {
	margin-top: 18px;
	padding-top: 14px;
	border-top: 1px solid var(--wspf-divider);
}

.wspf-btn-apply-filters {
	width: 100%;
	padding: 10px 16px;
	background-color: var(--wspf-heading-blue);
	color: #ffffff;
	border: none;
	border-radius: var(--wspf-radius-sm);
	font-weight: 600;
	font-size: 0.95rem;
	cursor: pointer;
	transition: var(--wspf-transition);
}

.wspf-btn-apply-filters:hover {
	background-color: #2672b8;
}

/* Loading Overlay */
.wspf-loading-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(248, 248, 248, 0.65);
	backdrop-filter: blur(1px);
	display: none;
	align-items: center;
	justify-content: center;
	border-radius: var(--wspf-radius-md);
	z-index: 20;
}

.wspf-filter-sidebar-wrapper.is-loading .wspf-loading-overlay {
	display: flex;
}

.wspf-spinner {
	width: 32px;
	height: 32px;
	border: 3px solid rgba(49, 136, 216, 0.2);
	border-top-color: var(--wspf-heading-blue);
	border-radius: 50%;
	animation: wspf-spin 0.75s linear infinite;
}

@keyframes wspf-spin {
	to { transform: rotate(360deg); }
}

/* Empty Results Message */
.wspf-no-products-found {
	text-align: center;
	padding: 48px 24px;
	background: #fdfdfd;
	border: 1px dashed var(--wspf-divider);
	border-radius: var(--wspf-radius-md);
	margin: 20px 0;
}

.wspf-empty-icon {
	margin-bottom: 12px;
}

.wspf-empty-text {
	font-size: 1.05rem;
	color: var(--wspf-section-heading);
	margin: 0 0 16px 0;
}

.wspf-btn-reset-filters {
	display: inline-block;
	background: var(--wspf-heading-blue);
	color: #ffffff;
	border: none;
	border-radius: var(--wspf-radius-sm);
	padding: 8px 18px;
	font-size: 0.9rem;
	font-weight: 600;
	cursor: pointer;
	transition: var(--wspf-transition);
}

.wspf-btn-reset-filters:hover {
	background: #2672b8;
}

/* Mobile Toggle Button */
.wspf-mobile-toggle-btn {
	display: none;
	width: 100%;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 12px 18px;
	margin-bottom: 16px;
	background: #ffffff;
	border: 1.5px solid var(--wspf-heading-blue);
	color: var(--wspf-heading-blue);
	border-radius: var(--wspf-radius-sm);
	font-size: 1rem;
	font-weight: 700;
	cursor: pointer;
	transition: var(--wspf-transition);
}

.wspf-mobile-toggle-btn:hover {
	background: var(--wspf-heading-blue);
	color: #ffffff;
}

/* Results Container AJAX Loading State */
.wspf-results-container,
.elementor-widget-wc-archive-products,
.elementor-widget-woocommerce-products,
.elementor-widget-loop-grid,
ul.products {
	position: relative;
	transition: opacity 0.2s ease;
}

.wspf-results-container.is-loading,
.elementor-widget-wc-archive-products.is-loading,
.elementor-widget-woocommerce-products.is-loading,
.elementor-widget-loop-grid.is-loading,
ul.products.is-loading {
	opacity: 0.55;
	pointer-events: none;
}

/* Results Header & Counter */
.wspf-results-header {
	margin-bottom: 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.wspf-result-count {
	font-size: 0.92rem;
	color: var(--wspf-option-text);
}

/* Pagination Links Styling */
.wspf-pagination ul.page-numbers {
	display: flex;
	list-style: none;
	padding: 0;
	margin: 28px 0;
	gap: 6px;
	justify-content: center;
}

.wspf-pagination ul.page-numbers li {
	margin: 0;
}

.wspf-pagination ul.page-numbers a,
.wspf-pagination ul.page-numbers span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 36px;
	height: 36px;
	padding: 0 10px;
	border: 1px solid var(--wspf-divider);
	border-radius: var(--wspf-radius-sm);
	font-size: 0.88rem;
	color: var(--wspf-section-heading);
	text-decoration: none;
	transition: var(--wspf-transition);
	cursor: pointer;
}

.wspf-pagination ul.page-numbers a:hover {
	border-color: var(--wspf-heading-blue);
	color: var(--wspf-heading-blue);
}

.wspf-pagination ul.page-numbers span.current {
	background: var(--wspf-heading-blue);
	color: #ffffff;
	border-color: var(--wspf-heading-blue);
	font-weight: 600;
}

/* ==========================================================================
   Responsive & Mobile Drawer Styles (Max Width: 768px)
   ========================================================================== */
@media (max-width: 768px) {
	.wspf-mobile-toggle-btn {
		display: flex;
	}

	.wspf-sidebar {
		position: fixed;
		top: 0;
		left: 0;
		bottom: 0;
		width: 82%;
		max-width: 340px;
		height: 100vh;
		z-index: 999999;
		background: #ffffff;
		border-radius: 0;
		border: none;
		box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
		overflow-y: auto;
		transform: translateX(-105%);
		transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
		visibility: hidden;
	}

	.wspf-filter-sidebar-wrapper.drawer-open .wspf-sidebar {
		transform: translateX(0);
		visibility: visible;
	}

	.wspf-drawer-header {
		display: flex;
	}

	/* Backdrop Overlay */
	.wspf-filter-sidebar-wrapper.drawer-open::before {
		content: "";
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background: rgba(0, 0, 0, 0.4);
		backdrop-filter: blur(2px);
		z-index: 999998;
	}
}

/* Reduced Motion Preference */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}
