/* =========================================================================
 * WProductFilter — styles neutres, adaptés à la plupart des thèmes.
 * Tout est piloté par des variables CSS (--apf-*) surchargées par :
 *  - le style « Sombre translucide » (réglage Apparence) ;
 *  - la couleur d'accent (réglage Apparence) ;
 *  - votre CSS enfant si besoin (surchargez simplement les variables).
 * ========================================================================= */

.apf-shop-layout,
.apf-mobile-panel {
	/* Palette claire par défaut (neutre, lisible sur la plupart des thèmes). */
	--apf-card-bg: #ffffff;
	--apf-border: rgba(0, 0, 0, .14);
	--apf-text: #1f2937;
	--apf-muted: #6b7280;
	--apf-accent: #2271b1;
	--apf-bg-soft: rgba(0, 0, 0, .03);
	--apf-radius: 10px;
	--apf-loader-bg: rgba(255, 255, 255, .6);
}

.apf-shop-layout {
	display: flex;
	align-items: flex-start;
	gap: 32px;
	width: 100%;
	clear: both; /* sous la ligne pleine largeur compteur + tri */
}

/* ---- Colonne de filtres (desktop) -------------------------------------- */
.apf-filters {
	position: relative;
	flex: 0 0 280px;
	max-width: 280px;
	padding: 22px 22px 24px;
	color: var(--apf-text);
	border-radius: 14px;
	overflow: hidden;
	isolation: isolate;
	background: var(--apf-card-bg);
	border: 1px solid var(--apf-border);
	box-shadow: 0 2px 12px rgba(0, 0, 0, .06);
}

/* ---- Style « Sombre translucide » (liquid glass) ------------------------ */
/* Activable dans Réglages → Apparence. Reprend les variables du thème
   GeneratePress si présentes (--accent, --base-3, --contrast-3). */
.apf-style-dark.apf-shop-layout,
.apf-style-dark.apf-mobile-panel {
	--apf-card-bg: var(--vdark-blue, #0F1024);
	--apf-border: rgba(255, 255, 255, .14);
	--apf-text: var(--base-3, #ffffff);
	--apf-muted: var(--contrast-3, #b2b2be);
	--apf-accent: var(--accent, #2271b1);
	--apf-bg-soft: rgba(255, 255, 255, .05);
	--apf-loader-bg: rgba(15, 16, 36, .55);
}

.apf-style-dark .apf-filters {
	border-radius: 18px;

	/* Fond verre translucide + dégradé liquide. */
	background:
		linear-gradient(135deg, rgba(255, 255, 255, .10), rgba(255, 255, 255, .02) 45%, rgba(120, 120, 255, .06)),
		rgba(15, 16, 36, .55);

	/* Flou d'arrière-plan (le cœur du liquid glass). */
	-webkit-backdrop-filter: blur(18px) saturate(160%);
	backdrop-filter: blur(18px) saturate(160%);

	border: 1px solid rgba(255, 255, 255, .18);

	/* Reflet interne + ombre portée douce pour la profondeur. */
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, .25),
		inset 0 0 24px rgba(255, 255, 255, .04),
		0 8px 32px rgba(0, 0, 0, .35);
}

/* Halo lumineux animé qui « coule » derrière le verre (style sombre). */
.apf-style-dark .apf-filters::before {
	content: "";
	position: absolute;
	inset: -40%;
	z-index: -1;
	background:
		radial-gradient(40% 40% at 25% 20%, color-mix(in srgb, var(--apf-accent) 35%, transparent), transparent 70%),
		radial-gradient(45% 45% at 80% 75%, rgba(80, 140, 255, .28), transparent 70%);
	filter: blur(28px);
	opacity: .9;
	animation: apf-liquid 14s ease-in-out infinite alternate;
	pointer-events: none;
}

@keyframes apf-liquid {
	0%   { transform: translate(0, 0) scale(1); }
	50%  { transform: translate(6%, -5%) scale(1.12); }
	100% { transform: translate(-5%, 6%) scale(1.05); }
}

@media (prefers-reduced-motion: reduce) {
	.apf-style-dark .apf-filters::before { animation: none; }
}

.apf-shop-main {
	flex: 1 1 auto;
	min-width: 0; /* évite le débordement de la grille en flex */
}

.apf-filters-title {
	font-size: 1.2rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .06em;
	margin: 0 0 16px;
	padding-bottom: 14px;
	border-bottom: 1px solid var(--apf-border);
	color: var(--apf-text);
}

/* ---- Accordéons -------------------------------------------------------- */
.apf-accordion {
	border-bottom: 1px solid var(--apf-border);
}

/* On neutralise le style bouton du thème (fond gris au survol/focus). */
.apf-accordion-header,
.apf-accordion-header:hover,
.apf-accordion-header:focus,
.apf-accordion-header:active {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 12px 2px;
	background: transparent !important;
	background-color: transparent !important;
	background-image: none !important;
	border: 0 !important;
	border-radius: 0 !important;
	box-shadow: none !important;
	margin: 0;
	font-size: .95em;
	font-weight: 600;
	color: var(--apf-text);
	cursor: pointer;
	text-align: left;
	line-height: 1.3;
	text-transform: none;
	letter-spacing: normal;
}

.apf-accordion-header:hover,
.apf-accordion-header:hover .apf-accordion-label { color: var(--apf-accent); }
.apf-accordion-header:focus-visible { outline: 2px solid var(--apf-accent); outline-offset: 2px; }

/* Icône +/- en pur CSS */
.apf-accordion-icon {
	position: relative;
	flex: 0 0 auto;
	width: 16px;
	height: 16px;
	margin-left: 10px;
}
.apf-accordion-icon::before,
.apf-accordion-icon::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 12px;
	height: 2px;
	background: currentColor;
	transform: translate(-50%, -50%);
	transition: transform .2s ease, opacity .2s ease;
}
.apf-accordion-icon::after { transform: translate(-50%, -50%) rotate(90deg); }
.apf-accordion-header[aria-expanded="true"] .apf-accordion-icon::after { opacity: 0; transform: translate(-50%, -50%) rotate(0deg); }

.apf-accordion-panel { padding: 2px 2px 14px; }
.apf-accordion-panel[hidden] { display: none; }

/* ---- Listes d'options -------------------------------------------------- */
.apf-options { list-style: none; margin: 0; padding: 0; }
.apf-options li { margin: 0; }

.apf-option {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 5px 0;
	font-size: .9em;
	color: var(--apf-text);
	cursor: pointer;
}
.apf-option input[type="checkbox"] { margin: 0; flex: 0 0 auto; width: 16px; height: 16px; accent-color: var(--apf-accent); }
.apf-option-label { flex: 1 1 auto; }
.apf-option-count { color: var(--apf-muted); font-size: .85em; }

/* ---- Filtre prix ------------------------------------------------------- */
.apf-price-slider { position: relative; height: 30px; margin: 6px 4px 14px; }

.apf-slider-track {
	position: absolute;
	top: 50%;
	left: 0;
	right: 0;
	height: 4px;
	transform: translateY(-50%);
	background: var(--apf-border);
	border-radius: 4px;
}
.apf-slider-range {
	position: absolute;
	height: 100%;
	background: var(--apf-accent);
	border-radius: 4px;
}

/* Deux input range superposés ; seuls les thumbs captent les events */
.apf-range {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 30px;
	margin: 0;
	background: none;
	pointer-events: none;
	-webkit-appearance: none;
	appearance: none;
}
.apf-range::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #fff;
	border: 2px solid var(--apf-accent);
	cursor: pointer;
	pointer-events: auto;
	margin-top: -1px;
}
.apf-range::-moz-range-thumb {
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #fff;
	border: 2px solid var(--apf-accent);
	cursor: pointer;
	pointer-events: auto;
}
.apf-range::-webkit-slider-runnable-track { background: none; }
.apf-range::-moz-range-track { background: none; }

.apf-price-inputs { display: flex; align-items: flex-end; gap: 8px; }
.apf-price-field { display: flex; flex-direction: column; gap: 3px; font-size: .8em; color: var(--apf-muted); flex: 1 1 0; }
.apf-price-field input {
	width: 100%;
	padding: 6px 8px;
	border: 1px solid var(--apf-border);
	border-radius: 6px;
	background: var(--apf-bg-soft);
	color: var(--apf-text);
	font-size: .95em;
}
.apf-price-field input:focus { outline: 1px solid var(--apf-accent); border-color: var(--apf-accent); }
.apf-price-dash { padding-bottom: 8px; color: var(--apf-muted); }

/* ---- Barre / bouton mobile -------------------------------------------- */
.apf-mobile-bar { display: none; margin: 0 0 16px; }
.apf-open-filters {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	justify-content: center;
	padding: 12px 16px;
	border: 1px solid var(--apf-border);
	background: var(--apf-card-bg);
	color: var(--apf-text);
	font-weight: 600;
	border-radius: 8px;
	cursor: pointer;
}

/* ---- Panneau mobile plein écran --------------------------------------- */
.apf-mobile-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, .45);
	z-index: 99998;
}
.apf-mobile-overlay[hidden] { display: none; }

.apf-mobile-panel {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	flex-direction: column;
	background: var(--apf-card-bg);
	color: var(--apf-text);
	width: 100%;
	height: 100%;
}
.apf-mobile-panel[hidden] { display: none; }

.apf-panel-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 18px;
	flex: 0 0 auto;
}
.apf-panel-title { font-size: 1.15em; font-weight: 700; }
.apf-close-filters { background: none; border: 0; padding: 4px; cursor: pointer; color: var(--apf-text); line-height: 0; }
.apf-panel-sep { margin: 0; border: 0; border-top: 1px solid var(--apf-border); flex: 0 0 auto; }

.apf-panel-body { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px 18px; }
.apf-panel-footer {
	flex: 0 0 auto;
	display: flex;
	gap: 10px;
	padding: 14px 18px;
	border-top: 1px solid var(--apf-border);
}

.apf-reset,
.apf-apply {
	flex: 1 1 0;
	padding: 13px 12px;
	font-weight: 600;
	border-radius: 8px;
	cursor: pointer;
	font-size: .95em;
}
.apf-reset {
	background: none;
	border: 1px solid var(--apf-border);
	color: var(--apf-text);
}
.apf-reset:hover { border-color: var(--apf-accent); color: var(--apf-accent); }

/* Bouton principal « Voir les résultats » */
.apf-apply {
	background: var(--apf-accent);
	border: 1px solid var(--apf-accent);
	color: #fff;
}
.apf-apply:hover { filter: brightness(1.08); }

/* Blocage du scroll de fond quand le panneau est ouvert */
body.apf-no-scroll { overflow: hidden; }

/* ---- Loader discret ---------------------------------------------------- */
.apf-shop-main { position: relative; }
.apf-loading .apf-loader { opacity: 1; pointer-events: auto; }
.apf-loader {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding-top: 60px;
	background: var(--apf-loader-bg);
	opacity: 0;
	pointer-events: none;
	transition: opacity .15s ease;
	z-index: 5;
}
.apf-loader::after {
	content: "";
	width: 34px;
	height: 34px;
	border: 3px solid var(--apf-border);
	border-top-color: var(--apf-accent);
	border-radius: 50%;
	animation: apf-spin .7s linear infinite;
}
@keyframes apf-spin { to { transform: rotate(360deg); } }

/* ---- Grille produits : 3 / 2 / 1 colonnes ----------------------------- */
.apf-shop-layout .apf-shop-main ul.products {
	display: grid !important;
	grid-template-columns: repeat(var(--apf-cols-d, 3), 1fr) !important;
	gap: 24px;
	margin: 0;
	padding: 0;
}
.apf-shop-layout .apf-shop-main ul.products::before,
.apf-shop-layout .apf-shop-main ul.products::after { content: none; display: none; } /* neutralise les clearfix WooCommerce */
.apf-shop-layout .apf-shop-main ul.products li.product {
	width: 100%;
	margin: 0;
	float: none;
	clear: none;
}

/* ---- Pagination : on corrige UNIQUEMENT le positionnement -------------- */
/* (pleine largeur, centrée, sous la grille). L'apparence reste celle du thème. */
.apf-shop-main .woocommerce-pagination {
	clear: both !important;
	float: none !important;
	width: 100% !important;
	margin-top: 30px;
}

/* ---- Responsive -------------------------------------------------------- */
/* Desktop intermédiaire : on resserre la sidebar et on réduit la gouttière. */
@media (max-width: 1200px) {
	.apf-filters { flex-basis: 240px; max-width: 240px; }
	.apf-shop-layout { gap: 24px; }
}

/* Tablette : la sidebar reste visible mais on passe la grille à 2 colonnes.
   (Sinon 3 colonnes + sidebar donnent des cartes beaucoup trop étroites ~170px.) */
@media (max-width: 1024px) {
	.apf-filters { flex-basis: 220px; max-width: 220px; }
	.apf-shop-layout .apf-shop-main ul.products { grid-template-columns: repeat(2, 1fr) !important; gap: 20px; }
}

@media (max-width: 768px) {
	/* La sidebar desktop est masquée ; les filtres passent dans le panneau mobile. */
	.apf-shop-layout { display: block; }
	.apf-filters { display: none; }

	/* Barre mobile : bouton « Filtrer » + tri WooCommerce côte à côte (50/50). */
	.apf-mobile-bar { display: flex; gap: 10px; align-items: stretch; }
	.apf-mobile-bar .apf-open-filters { flex: 1 1 0; width: auto; margin: 0; }
	.apf-mobile-bar .woocommerce-ordering { flex: 1 1 0; margin: 0; float: none; }
	.apf-mobile-bar .woocommerce-ordering select {
		width: 100%;
		height: 100%;
		min-height: 100%;
		max-width: none;
		box-sizing: border-box;
	}

	.apf-shop-layout .apf-shop-main ul.products { grid-template-columns: repeat(var(--apf-cols-m, 2), 1fr) !important; gap: 16px; }
}

/* Petit mobile : une seule colonne, cartes pleinement lisibles. */
@media (max-width: 480px) {
	.apf-shop-layout .apf-shop-main ul.products { grid-template-columns: 1fr !important; }
}

/* Quand les filtres sont déplacés dans le panneau mobile : on neutralise le titre dupliqué */
.apf-mobile-panel .apf-filters-title { display: none; }
