/*
 * Puentec Filters — Frontend Styles
 * Clean, modern filter UI inspired by YITH Ajax Filters.
 * Encapsulated via CSS @layer for isolation.
 */

@layer puentec-filters {

	/* ── CSS Variables ────────────────────────────────────────── */
	:root {
		--pf-accent: var(--theme-accent-color, #ef8c00);
		--pf-accent-light: #fff7ed;
		--pf-text: #333;
		--pf-text-muted: #888;
		--pf-border: #eee;
		--pf-bg: #fff;
		--pf-radius: 10px;
	}

	/* ── Widget container ────────────────────────────────────── */
	.pf-widget {
		background: var(--pf-bg);
		padding: 16px 20px;
		border-radius: var(--pf-radius);
		border: 1px solid var(--pf-border);
		margin-bottom: 12px;
	}

	/* ── Title — clean, no underline ─────────────────────────── */
	.pf-widget-title {
		font-size: 0.95rem;
		font-weight: 700;
		letter-spacing: 0.01em;
		margin: 0;
		padding: 0;
		border-bottom: none;
		display: flex;
		color: var(--pf-text);
		text-transform: uppercase;
	}

	/* ── Back link ────────────────────────────────────────────── */
	.pf-back-link {
		display: inline-flex;
		align-items: center;
		gap: 4px;
		font-size: 0.82rem;
		color: var(--pf-accent);
		margin-bottom: 8px;
		text-decoration: none;
		font-weight: 600;
		transition: color 0.2s;
	}

	.pf-back-link:hover {
		color: var(--pf-text);
	}

	/* ── Lists ────────────────────────────────────────────────── */
	.pf-list {
		list-style: none;
		padding: 0;
		margin: 0;
	}

	/* ── Items (category / attribute rows) ────────────────────── */
	.pf-item {
		padding: 0;
		border-bottom: none;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.pf-item a {
		color: var(--pf-text);
		font-size: 0.9rem;
		text-decoration: none;
		transition: color 0.2s;
		padding: 6px 0;
		display: flex;
		align-items: center;
		gap: 8px;
		flex: 1;
	}

	.pf-item a:hover {
		color: var(--pf-accent);
	}

	.pf-item.active a {
		color: var(--pf-accent);
		font-weight: 600;
	}

	/* ── Inline count (N) ────────────────────────────────────── */
	.pf-count {
		background: none;
		padding: 0;
		border-radius: 0;
		font-size: 0.82rem;
		color: var(--pf-text-muted);
		flex-shrink: 0;
		font-weight: 400;
	}

	/* ═══════════════════════════════════════════════════════════
	   BRAND FILTER — Checkbox list with logos
	   ═══════════════════════════════════════════════════════════ */

	.pf-brand-list {
		list-style: none !important;
		padding: 0;
		margin: 0;
	}

	.pf-brand-list li {
		list-style: none !important;
	}

	.pf-brand-list li::before {
		display: none !important;
		content: none !important;
	}

	.pf-brand-item {
		position: relative;
	}

	.pf-brand-item a {
		display: flex;
		align-items: center;
		gap: 10px;
		padding: 7px 0;
		text-decoration: none;
		transition: color 0.2s;
		color: var(--pf-text);
		font-size: 0.9rem;
	}

	.pf-brand-item a:hover {
		color: var(--pf-accent);
	}

	.pf-brand-item a:hover .pf-checkbox {
		border-color: var(--pf-accent);
	}

	.pf-brand-item.active a {
		color: var(--pf-accent);
		font-weight: 600;
	}

	.pf-brand-logo {
		width: 28px;
		height: 28px;
		object-fit: contain;
		flex-shrink: 0;
		border-radius: 4px;
	}

	.pf-brand-name {
		font-size: 0.9rem;
		color: inherit;
		flex: 1;
		min-width: 0;
	}

	.pf-brand-item .pf-count {
		margin-left: auto;
		font-size: 0.82rem;
	}

	/* ═══════════════════════════════════════════════════════════
	   PRICE RANGE SLIDER
	   ═══════════════════════════════════════════════════════════ */

	.pf-range-slider {
		position: relative;
		height: 36px;
		margin: 12px 0 4px;
	}

	.pf-range-track {
		position: absolute;
		top: 50%;
		left: 0;
		right: 0;
		height: 4px;
		background: #e8e8e8;
		border-radius: 2px;
		transform: translateY(-50%);
		pointer-events: none;
	}

	.pf-range-fill {
		position: absolute;
		top: 0;
		height: 100%;
		background: var(--pf-accent);
		border-radius: 2px;
	}

	.pf-range-input {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		margin: 0;
		padding: 0;
		-webkit-appearance: none;
		appearance: none;
		background: transparent;
		pointer-events: none;
		outline: none;
	}

	.pf-range-input::-webkit-slider-thumb {
		-webkit-appearance: none;
		width: 18px;
		height: 18px;
		background: #fff;
		border: 2px solid var(--pf-accent);
		border-radius: 50%;
		cursor: pointer;
		pointer-events: all;
		box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
		transition: transform 0.15s, box-shadow 0.15s;
	}

	.pf-range-input::-webkit-slider-thumb:hover {
		transform: scale(1.15);
		box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
	}

	.pf-range-input::-moz-range-thumb {
		width: 18px;
		height: 18px;
		background: #fff;
		border: 2px solid var(--pf-accent);
		border-radius: 50%;
		cursor: pointer;
		pointer-events: all;
		box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
	}

	.pf-price-values {
		display: flex;
		justify-content: space-between;
		margin-top: 8px;
	}

	.pf-price-display {
		background: #f7f7f7;
		border: 1px solid #e8e8e8;
		border-radius: 6px;
		padding: 4px 10px;
		font-size: 0.82rem;
		color: #555;
		min-width: 70px;
		text-align: center;
	}

	/* ═══════════════════════════════════════════════════════════
	   CHECKBOX (shared: stock, brands, attributes)
	   ═══════════════════════════════════════════════════════════ */

	.pf-checkbox {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 18px;
		height: 18px;
		border: 2px solid #ccc;
		border-radius: 4px;
		flex-shrink: 0;
		transition: all 0.15s;
		position: relative;
	}

	.pf-checkbox.checked {
		background: var(--pf-accent);
		border-color: var(--pf-accent);
	}

	.pf-checkbox.checked::after {
		content: '';
		position: absolute;
		top: 1px;
		left: 5px;
		width: 5px;
		height: 9px;
		border: solid #fff;
		border-width: 0 2px 2px 0;
		transform: rotate(45deg);
	}

	/* ── Stock item layout ────────────────────────────────────── */
	.pf-stock-item a {
		display: flex;
		align-items: center;
		gap: 10px;
	}

	.pf-stock-item:hover .pf-checkbox {
		border-color: var(--pf-accent);
	}

	/* ═══════════════════════════════════════════════════════════
	   ACTIVE FILTER CHIPS
	   ═══════════════════════════════════════════════════════════ */

	.pf-active-filters {
		display: flex;
		flex-wrap: wrap;
		gap: 6px;
		margin-bottom: 14px;
		padding: 0;
	}

	.pf-chip {
		display: inline-flex;
		align-items: center;
		gap: 4px;
		background: var(--pf-accent-light);
		border: 1px solid var(--pf-accent);
		border-radius: 20px;
		padding: 4px 10px 4px 12px;
		font-size: 0.78rem;
		color: var(--pf-accent);
		text-decoration: none;
		transition: background 0.15s, color 0.15s;
		cursor: pointer;
		line-height: 1.4;
		font-weight: 600;
	}

	.pf-chip:hover {
		background: var(--pf-accent);
		color: #fff;
	}

	.pf-chip-remove {
		font-size: 1rem;
		font-weight: 700;
		line-height: 1;
		transition: color 0.15s;
	}

	.pf-chip:hover .pf-chip-remove {
		color: #fff;
	}

	.pf-reset-all {
		display: inline-flex;
		align-items: center;
		font-size: 0.78rem;
		color: var(--pf-text-muted);
		text-decoration: underline;
		font-weight: 500;
		padding: 4px 6px;
		transition: color 0.2s;
	}

	.pf-reset-all:hover {
		color: var(--pf-text);
	}

	/* ═══════════════════════════════════════════════════════════
	   COLLAPSIBLE SECTIONS
	   ═══════════════════════════════════════════════════════════ */

	.pf-collapsible {
		cursor: pointer;
		user-select: none;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.pf-collapsible::after {
		content: '';
		display: inline-block;
		width: 7px;
		height: 7px;
		border-right: 2px solid #999;
		border-bottom: 2px solid #999;
		transform: rotate(45deg);
		transition: transform 0.25s ease;
		flex-shrink: 0;
		margin-left: 8px;
	}

	.pf-collapsible[aria-expanded="false"]::after {
		transform: rotate(-45deg);
	}

	.pf-widget-body {
		overflow: hidden;
		transition: none;
		margin-top: 12px;
	}

	.pf-widget-body[hidden] {
		display: none;
	}

	/* ═══════════════════════════════════════════════════════════
	   AJAX LOADING OVERLAY
	   ═══════════════════════════════════════════════════════════ */

	.pf-loading {
		position: relative;
		opacity: 0.35;
		pointer-events: none;
		transition: opacity 0.25s ease;
	}

	.pf-loading::after {
		content: '';
		position: absolute;
		top: 50%;
		left: 50%;
		width: 32px;
		height: 32px;
		margin: -16px 0 0 -16px;
		border: 3px solid #e0e0e0;
		border-top-color: var(--pf-accent);
		border-radius: 50%;
		animation: pf-spin 0.7s linear infinite;
	}

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

} /* end @layer puentec-filters */

/* ═══════════════════════════════════════════════════════════════
   MOBILE DRAWER — OUTSIDE @layer so !important beats theme's
   unlayered !important (CSS layers invert !important priority).
   ═══════════════════════════════════════════════════════════════ */

.pf-mobile-trigger {
	display: none; /* Hidden on desktop */
}

.pf-drawer-header {
	display: none; /* Hidden on desktop */
}

.pf-drawer-footer {
	display: none; /* Hidden on desktop */
}

@media (max-width: 780px) {

	/* ── Trigger button ─────────────────────────────────────── */
	.pf-mobile-trigger {
		display: inline-flex !important;
		align-items: center;
		gap: 6px;
		background: var(--theme-primary-color, #1a1a1a) !important;
		color: #fff !important;
		border: none !important;
		border-radius: 8px !important;
		padding: 10px 18px !important;
		font-size: 0.9rem !important;
		font-weight: 600 !important;
		cursor: pointer !important;
		margin-bottom: 12px !important;
		transition: background 0.2s, transform 0.15s;
		z-index: 1 !important;
		position: relative !important;
	}

	.pf-mobile-trigger:hover {
		filter: brightness(1.15);
		transform: translateY(-1px);
	}

	.pf-mobile-trigger svg {
		flex-shrink: 0;
	}

	/* ── Badge on trigger ──────────────────────────────────── */
	.pf-trigger-badge {
		display: inline-flex !important;
		align-items: center;
		justify-content: center;
		background: var(--theme-accent-color, #ef8c00) !important;
		color: #fff !important;
		font-size: 0.7rem !important;
		font-weight: 700 !important;
		min-width: 18px;
		height: 18px;
		border-radius: 9px;
		padding: 0 5px;
		margin-left: 2px;
	}

	/* ── Sidebar as off-canvas drawer ─────────────────────── */
	#secondary {
		position: fixed !important;
		top: 0 !important;
		left: 0 !important;
		width: 320px !important;
		max-width: 85vw !important;
		height: 100vh !important;
		height: 100dvh !important;
		z-index: 10000 !important;
		background: #fff !important;
		overflow-y: auto !important;
		transform: translateX(-100%) !important;
		transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
		padding: 0 !important;
		margin: 0 !important;
		box-shadow: none !important;
		display: block !important;
	}

	/* ── Drawer open state ────────────────────────────────── */
	body.pf-drawer-open #secondary {
		transform: translateX(0) !important;
		box-shadow: 4px 0 25px rgba(0, 0, 0, 0.12) !important;
	}

	/* ── Backdrop overlay ─────────────────────────────────── */
	body.pf-drawer-open::after {
		content: '' !important;
		position: fixed !important;
		inset: 0 !important;
		background: rgba(0, 0, 0, 0.4) !important;
		z-index: 9999 !important;
		display: block !important;
	}

	body.pf-drawer-open {
		overflow: hidden !important;
	}

	/* ── Drawer inner container ───────────────────────────── */
	.pf-drawer {
		padding: 0 16px 80px !important; /* 80px for sticky footer */
	}

	/* ── Drawer header ────────────────────────────────────── */
	.pf-drawer-header {
		display: flex !important;
		justify-content: space-between;
		align-items: center;
		padding: 14px 16px;
		border-bottom: 1px solid #eee;
		margin: 0 -16px 14px;
		position: sticky;
		top: 0;
		background: #fff;
		z-index: 2;
	}

	.pf-drawer-title {
		font-size: 1.05rem;
		font-weight: 700;
		color: var(--theme-primary-color, #1a1a1a);
		text-transform: uppercase;
		letter-spacing: 0.02em;
	}

	.pf-drawer-close {
		background: none !important;
		border: none !important;
		font-size: 1.5rem !important;
		line-height: 1 !important;
		color: #999 !important;
		cursor: pointer !important;
		padding: 4px 8px !important;
		border-radius: 6px !important;
		transition: background 0.15s, color 0.15s;
	}

	.pf-drawer-close:hover {
		background: #f0f0f0 !important;
		color: #333 !important;
	}

	/* ── Sticky footer — "Ver resultados" button ──────────── */
	.pf-drawer-footer {
		display: block !important;
		position: sticky;
		bottom: 0;
		left: 0;
		right: 0;
		padding: 12px 16px;
		background: #fff;
		border-top: 1px solid #eee;
		margin: 0 -16px;
		z-index: 2;
	}

	.pf-drawer-footer .pf-apply-btn {
		display: block !important;
		width: 100%;
		padding: 12px 16px;
		background: var(--theme-accent-color, #ef8c00) !important;
		color: #fff !important;
		border: none !important;
		border-radius: 8px !important;
		font-size: 0.95rem !important;
		font-weight: 700 !important;
		cursor: pointer !important;
		text-align: center;
		transition: filter 0.15s;
	}

	.pf-drawer-footer .pf-apply-btn:hover {
		filter: brightness(1.1);
	}

	/* ── Widgets inside drawer ────────────────────────────── */
	.pf-drawer .pf-widget {
		border-radius: 8px;
		margin-bottom: 8px;
		padding: 14px 16px;
		border-color: #f0f0f0;
	}

	/* ── Override theme's mobile sidebar stacking ─────────── */
	.archive.woocommerce-page .site-content .col-full #secondary,
	.shop.woocommerce-page .site-content .col-full #secondary {
		position: fixed !important;
	}

	/* Hide any theme-provided filter buttons */
	.grupozc-filter-btn,
	.sidebar-mobile-header {
		display: none !important;
	}
}
