/**
 * Advanced WooCommerce Product Filters — theme-aware sidebar.
 *
 * Colors: --apf-* (from Elementor kit / theme via PHP), then Elementor globals, then defaults.
 */

.apf-shop-wrapper {
	display: grid;
	grid-template-columns: minmax(260px, 320px) 1fr;
	gap: 2rem;
	align-items: start;
	width: 100%;
}

.apf-shop-sidebar {
	min-width: 0;
}

.apf-shop-content {
	min-width: 0;
}

@media (max-width: 768px) {
	.apf-shop-wrapper {
		grid-template-columns: 1fr;
	}
}

.apf-filters-wrap,
.apf-filters {
	width: 100%;
	max-width: 320px;
}

.apf-filters {
	--apf-text: var(--e-global-color-text, #222222);
	--apf-heading: var(--e-global-color-text, #111111);
	--apf-primary: var(--e-global-color-primary, #2271b1);
	--apf-accent: var(--e-global-color-secondary, #111111);
	--apf-border: #d8d8d8;
	--apf-surface: #ffffff;
	--apf-muted: #777777;
	--apf-hover: #f5f5f5;

	background: var(--apf-surface);
	border: 1px solid var(--apf-border);
	border-radius: 0;
	padding: 0;
	position: relative;
	box-sizing: border-box;
	font-family: 'Inter';
	font-size: 14px;
	color: var(--apf-text);
}

.apf-filters__header {
	padding: 18px 20px 14px;
	border-bottom: 1px solid var(--apf-border);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
}

.apf-filters__title {
	margin: 0;
	font-size: 18px;
	font-weight: 700;
	line-height: 1.2;
	color: var(--apf-heading);
	letter-spacing: 0.01em;
}

.apf-filters__clear {
	background: transparent;
	border: 0;
	color: var(--apf-muted);
	cursor: pointer;
	font-size: 12px;
	padding: 0;
	text-decoration: underline;
}

.apf-filters__clear:hover {
	color: var(--apf-primary);
}

.apf-filters__form {
	padding: 0;
}

.apf-filter-group {
	border-bottom: 1px solid var(--apf-border);
}

.apf-filter-group:last-child {
	border-bottom: 0;
}

.apf-filter-group__toggle {
	align-items: center;
	background: transparent;
	border: 0;
	cursor: pointer;
	display: flex;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 20px;
	width: 100%;
	text-align: left;
	color: var(--apf-text);
	font-size: 14px;
	font-weight: 600;
	line-height: 1.3;
}

.apf-filter-group__toggle:hover {
	background: var(--apf-hover);
}

.apf-filter-group__label {
	flex: 1;
}

.apf-filter-group__chevron {
	border-right: 2px solid var(--apf-muted);
	border-bottom: 2px solid var(--apf-muted);
	display: inline-block;
	height: 7px;
	margin-top: 2px;
	transform: rotate(45deg);
	transition: transform 0.2s ease;
	width: 7px;
	flex-shrink: 0;
}

.apf-filter-group:not(.apf-filter-group--open) .apf-filter-group__chevron {
	transform: rotate(-45deg);
	margin-top: 6px;
}

.apf-filter-group__panel {
	display: none;
	padding: 0 20px 16px;
}

.apf-filter-group--open .apf-filter-group__panel {
	display: block;
}

.apf-filter-item--disabled .apf-filter-label {
	opacity: 0.4;
	cursor: not-allowed;
}

.apf-filter-item--disabled .apf-filter-checkbox:disabled + .apf-filter-checkbox-ui {
	border-color: var(--apf-border);
	background: var(--apf-hover);
}

.apf-filter-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.apf-filter-item {
	margin: 0 0 10px;
}

.apf-filter-item:last-child {
	margin-bottom: 0;
}

.apf-filter-label {
	align-items: flex-start;
	cursor: pointer;
	display: flex;
	gap: 10px;
	font-size: 14px;
	font-weight: 400;
	line-height: 1.35;
	color: var(--apf-text);
	position: relative;
}

.apf-filter-checkbox {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
	margin: 0;
}

.apf-filter-checkbox-ui {
	border: 1px solid var(--apf-muted);
	display: inline-block;
	flex-shrink: 0;
	height: 14px;
	margin-top: 2px;
	width: 14px;
	background: var(--apf-surface);
}

.apf-filter-checkbox:checked + .apf-filter-checkbox-ui {
	background: var(--apf-primary);
	border-color: var(--apf-primary);
	box-shadow: inset 0 0 0 2px var(--apf-surface);
}

.apf-filter-checkbox:focus-visible + .apf-filter-checkbox-ui {
	outline: 2px solid var(--apf-primary);
	outline-offset: 2px;
}

.apf-filter-name {
	flex: 1;
}

.apf-filter-count {
	color: var(--apf-muted);
	font-size: 12px;
}

/* —— Loading overlay —— */

.apf-filters__loading {
	align-items: center;
	background: rgba(255, 255, 255, 0.82);
	display: none;
	inset: 0;
	justify-content: center;
	position: absolute;
	z-index: 50;
}

.apf-filters__loading.is-visible {
	display: flex;
}

.apf-products-overlay {
	align-items: center;
	background: rgba(255, 255, 255, 0.78);
	box-sizing: border-box;
	display: none;
	justify-content: center;
	pointer-events: none;
	position: fixed;
	z-index: 999999;
}

.apf-products-overlay.is-visible {
	display: flex;
	pointer-events: auto;
}

.apf-loader {
	align-items: center;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.apf-loader--compact {
	gap: 8px;
}

.apf-loader__spinner {
	animation: apf-spin 0.8s linear infinite;
	border: 2px solid var(--apf-border);
	border-radius: 50%;
	border-top-color: var(--apf-primary);
	box-sizing: border-box;
	display: block;
	height: 28px;
	width: 28px;
}

.apf-loader--compact .apf-loader__spinner {
	height: 22px;
	width: 22px;
}

.apf-loader__text {
	color: var(--apf-muted);
	font-size: 13px;
	font-weight: 500;
	line-height: 1.3;
}

.apf-loader--compact .apf-loader__text {
	font-size: 12px;
}

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

.apf-is-loading {
	opacity: 0.55;
	pointer-events: none;
	transition: opacity 0.15s ease;
}

.apf-products.woocommerce ul.products {
	margin: 0;
}

.apf-pagination-wrap {
	margin-top: 2rem;
}

.apf-pagination.woocommerce-pagination ul {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
	list-style: none;
	margin: 0;
	padding: 0;
}

.elementor-widget-shortcode .apf-shop-wrapper,
.elementor-widget-shortcode .apf-filters-wrap {
	width: 100%;
	max-width: none;
}

.elementor-widget-loop-grid.apf-is-loading,
.elementor-widget-wc-archive-products.apf-is-loading {
	opacity: 0.55;
	pointer-events: none;
	transition: opacity 0.15s ease;
}
