/* Product Filter Pro - Style */

.pfp-wrapper {
	--pfp-accent: #2c3e50;
	--pfp-accent-dark: #1a252f;
	--pfp-border: #e7e7ea;
	--pfp-bg-soft: #f7f7f9;
	--pfp-radius: 14px;
	--pfp-radius-sm: 8px;
	--pfp-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);

	display: grid;
	grid-template-columns: 270px 1fr;
	gap: 28px;
	align-items: start;
	margin: 20px 0;
	position: relative;
}

/* ---------- Bouton "Filtrer" (mobile uniquement) ---------- */
.pfp-filter-toggle {
	display: none;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	background: #fff;
	border: 1px solid var(--pfp-border);
	color: var(--pfp-accent-dark);
	font-size: 14px;
	font-weight: 600;
	padding: 12px 16px;
	border-radius: var(--pfp-radius-sm);
	box-shadow: var(--pfp-shadow);
	cursor: pointer;
	position: sticky;
	top: 8px;
	z-index: 20;
}

.pfp-filter-toggle:active {
	transform: scale(0.98);
}

/* Verrou explicite : quelle que soit la cascade (cache d'un ancien CSS, etc.),
   ce bouton ne doit jamais apparaître au-delà du seuil mobile/tablette. */
@media (min-width: 769px) {
	.pfp-filter-toggle {
		display: none !important;
	}
}

.pfp-filter-badge {
	background: var(--pfp-accent);
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	min-width: 20px;
	height: 20px;
	line-height: 20px;
	border-radius: 999px;
	padding: 0 6px;
}

.pfp-filters-overlay {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(15, 18, 22, 0.5);
	z-index: 998;
	opacity: 0;
	transition: opacity 0.25s ease;
}

.pfp-filters-close {
	display: none;
	background: none;
	border: none;
	font-size: 24px;
	line-height: 1;
	color: #888;
	cursor: pointer;
	padding: 4px 6px;
	border-radius: 999px;
}

.pfp-filters-close:hover {
	background: var(--pfp-bg-soft);
	color: #333;
}

/* ---------- Sidebar filtres ---------- */
.pfp-filters {
	background: #fff;
	border: 1px solid var(--pfp-border);
	border-radius: var(--pfp-radius);
	box-shadow: var(--pfp-shadow);
	padding: 20px;
	position: sticky;
	top: 20px;
	/* Position figée dans la grille : garantit que le panneau reste dans la colonne
	   de gauche même si d'autres éléments (bouton mobile, overlay) sont présents
	   comme enfants directs de .pfp-wrapper. */
	grid-column: 1;
	grid-row: 1;
}

.pfp-results {
	grid-column: 2;
	grid-row: 1;
}

.pfp-filters-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 14px;
	padding-bottom: 12px;
	border-bottom: 1px solid var(--pfp-border);
}

.pfp-filters-header h3 {
	margin: 0;
	font-size: 16px;
	font-weight: 700;
	color: #1a1a1a;
}

.pfp-reset-btn {
	display: block;
	width: 100%;
	background: var(--pfp-bg-soft);
	border: 1px solid var(--pfp-border);
	color: var(--pfp-accent-dark);
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	padding: 11px;
	border-radius: 999px;
	margin-top: 18px;
	transition: background 0.2s ease, border-color 0.2s ease;
}

.pfp-reset-btn:hover {
	background: #eee;
	border-color: #ccc;
}

.pfp-filter-group {
	margin-bottom: 18px;
	border-bottom: 1px solid #eee;
	padding-bottom: 14px;
}

.pfp-filter-group:last-child {
	border-bottom: none;
	margin-bottom: 0;
	padding-bottom: 0;
}

.pfp-filter-title {
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 13px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #333;
	margin: 0 0 10px 0;
	cursor: pointer;
	user-select: none;
}

.pfp-toggle-icon {
	font-size: 16px;
	font-weight: 400;
	color: #888;
}

.pfp-filter-options {
	display: flex;
	flex-direction: column;
	gap: 4px;
	max-height: 260px;
	overflow-y: auto;
	padding-right: 4px;
}

.pfp-filter-group.pfp-collapsed .pfp-filter-options {
	display: none;
}

.pfp-checkbox {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 14px;
	color: #333;
	cursor: pointer;
	line-height: 1.4;
	padding: 6px 4px;
	border-radius: var(--pfp-radius-sm);
	transition: background 0.15s ease;
}

.pfp-checkbox:hover {
	background: var(--pfp-bg-soft);
}

.pfp-checkbox input[type="checkbox"] {
	margin: 0;
	width: 17px;
	height: 17px;
	accent-color: var(--pfp-accent);
	cursor: pointer;
	flex-shrink: 0;
}

.pfp-checkbox em {
	font-style: normal;
	color: #999;
	font-size: 12px;
	margin-left: auto;
}

/* ---------- Arbre catégories (grandes catégories + sous-catégories imbriquées) ---------- */
.pfp-cat-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.pfp-cat-item {
	margin-bottom: 2px;
}

/* Sous-catégories : indentées et légèrement plus petites, avec un liseré pour marquer l'imbrication. */
.pfp-cat-item .pfp-cat-list {
	margin: 2px 0 2px 18px;
	padding-left: 10px;
	border-left: 2px solid #eee;
}

.pfp-cat-item .pfp-cat-list .pfp-checkbox {
	font-size: 13px;
	color: #555;
}

/* Une grande catégorie qui a des sous-catégories est mise en avant (gras). */
.pfp-cat-item:has(> .pfp-cat-list) > .pfp-checkbox {
	font-weight: 600;
}

/* ---------- Prix (slider double curseur) ---------- */
.pfp-price-slider {
	position: relative;
	height: 4px;
	background: var(--pfp-border);
	border-radius: 2px;
	margin: 32px 4px 16px;
}

.pfp-price-track {
	position: absolute;
	top: 0;
	bottom: 0;
	background: var(--pfp-accent);
	border-radius: 2px;
}

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

.pfp-price-range::-webkit-slider-thumb {
	pointer-events: all;
	-webkit-appearance: none;
	appearance: none;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: var(--pfp-accent);
	border: 3px solid #fff;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
	cursor: pointer;
}

.pfp-price-range::-moz-range-thumb {
	pointer-events: all;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: var(--pfp-accent);
	border: 3px solid #fff;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
	cursor: pointer;
}

.pfp-price-range::-webkit-slider-runnable-track,
.pfp-price-range::-moz-range-track {
	background: transparent;
}

.pfp-price-values {
	display: flex;
	justify-content: space-between;
	font-size: 13px;
	font-weight: 600;
	color: #333;
}

/* ---------- Résultats ---------- */
.pfp-results-bar {
	min-height: 20px;
	margin-bottom: 14px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 8px;
}

.pfp-count {
	font-size: 14px;
	color: #333;
	font-weight: 600;
}

.pfp-active-filters {
	font-size: 13px;
	color: #666;
}

.pfp-products-grid {
	position: relative;
	min-height: 120px;
}

.pfp-products-grid.pfp-loading {
	opacity: 0.45;
	pointer-events: none;
	transition: opacity 0.2s ease;
}

.pfp-products-grid ul.products {
	display: grid !important;
	gap: 24px;
	list-style: none;
	margin: 0;
	padding: 0;
}

/*
 * De nombreux thèmes ajoutent un clearfix (::before/::after avec content:"" et
 * display:table ou block) sur "ul.products", pensé pour l'ancien système en float.
 * Une fois le parent passé en display:grid, ce pseudo-élément invisible devient
 * lui-même un item de la grille et consomme la 1ère case (tout le reste est alors
 * décalé d'une case). On le désactive explicitement pour qu'il ne participe plus
 * à la grille.
 */
.pfp-products-grid ul.products::before,
.pfp-products-grid ul.products::after {
	content: none !important;
	display: none !important;
}

/*
 * De nombreux thèmes stylent les produits WooCommerce avec une largeur en pourcentage
 * (ex: "width: 33%" pour 3 colonnes) pensée pour une grille en float, pas en CSS Grid.
 * Combinée à notre display:grid, cette largeur s'applique EN PLUS de la colonne déjà
 * dimensionnée par la grille, ce qui réduit les produits à une fraction de leur cellule.
 * On neutralise ces propriétés pour laisser uniquement notre grille gérer les dimensions.
 */
.pfp-products-grid ul.products li.product {
	width: auto !important;
	margin: 0 !important;
	padding: 0 !important;
	border-radius: var(--pfp-radius-sm);
	transition: transform 0.2s ease;
}

/* Cartes produit un peu plus compactes : image légèrement réduite et centrée, texte un peu plus petit. */
.pfp-products-grid ul.products li.product img {
	max-width: 85% !important;
	margin-left: auto !important;
	margin-right: auto !important;
	border-radius: var(--pfp-radius-sm);
}

.pfp-products-grid ul.products li.product .woocommerce-loop-product__title,
.pfp-products-grid ul.products li.product h2 {
	font-size: 14px !important;
}

.pfp-products-grid ul.products li.product .price {
	font-size: 13px !important;
}

/* !important : la page boutique charge de nombreuses feuilles de style (thème, Elementor,
   autres extensions) ; on garantit que le nombre de colonnes choisi n'est jamais écrasé. */
.pfp-products-grid ul.products.pfp-columns-2 { grid-template-columns: repeat(2, 1fr) !important; }
.pfp-products-grid ul.products.pfp-columns-3 { grid-template-columns: repeat(3, 1fr) !important; }
.pfp-products-grid ul.products.pfp-columns-4 { grid-template-columns: repeat(4, 1fr) !important; }
.pfp-products-grid ul.products.pfp-columns-5 { grid-template-columns: repeat(5, 1fr) !important; }

@media (max-width: 992px) {
	.pfp-products-grid ul.products.pfp-columns-4,
	.pfp-products-grid ul.products.pfp-columns-5 {
		grid-template-columns: repeat(3, 1fr) !important;
	}
}

/* Mobile : 1 produit par ligne, quel que soit le nombre de colonnes choisi dans le
   shortcode (les sélecteurs ".pfp-columns-X" doivent être répétés ici pour avoir une
   spécificité au moins égale à leurs règles de base ci-dessus, sinon celles-ci gagnent
   même dans une media query plus étroite). */
@media (max-width: 600px) {
	.pfp-products-grid ul.products,
	.pfp-products-grid ul.products.pfp-columns-2,
	.pfp-products-grid ul.products.pfp-columns-3,
	.pfp-products-grid ul.products.pfp-columns-4,
	.pfp-products-grid ul.products.pfp-columns-5 {
		grid-template-columns: repeat(1, 1fr) !important;
		gap: 16px;
	}
}

.pfp-no-products-item {
	grid-column: 1 / -1;
	text-align: center;
	padding: 40px 0;
	color: #777;
	list-style: none;
}

/* ---------- Pagination numérotée ---------- */
.pfp-pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 30px;
}

.pfp-page-btn {
	min-width: 38px;
	height: 38px;
	padding: 0 8px;
	background: #fff;
	border: 1px solid var(--pfp-border);
	border-radius: 999px;
	font-size: 14px;
	font-weight: 600;
	color: #333;
	cursor: pointer;
	transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.pfp-page-btn:hover:not(:disabled):not(.pfp-page-current) {
	background: var(--pfp-bg-soft);
	border-color: #ccc;
}

.pfp-page-btn.pfp-page-current {
	background: var(--pfp-accent);
	border-color: var(--pfp-accent);
	color: #fff;
	cursor: default;
}

.pfp-page-btn:disabled {
	opacity: 0.35;
	cursor: default;
}

.pfp-page-dots {
	color: #999;
	padding: 0 4px;
}

/* ---------- Spinner ---------- */
.pfp-spinner {
	position: absolute;
	top: 40px;
	left: 50%;
	transform: translateX(-50%);
	width: 34px;
	height: 34px;
	border: 3px solid var(--pfp-border);
	border-top-color: var(--pfp-accent);
	border-radius: 50%;
	animation: pfp-spin 0.7s linear infinite;
	display: none;
	z-index: 5;
}

.pfp-products-grid.pfp-loading .pfp-spinner {
	display: block;
}

@keyframes pfp-spin {
	to { transform: translateX(-50%) rotate(360deg); }
}

/* =====================================================================
   Mobile/tablette (< 768px) : le bouton "Filtrer" ouvre le panneau de
   filtres en tiroir plein écran (drawer) au-dessus des produits.
   Seuil volontairement sous les largeurs de fenêtre PC habituelles pour
   que ce bouton ne s'affiche jamais en version bureau.
   ===================================================================== */
@media (max-width: 768px) {
	.pfp-wrapper {
		grid-template-columns: 1fr;
		gap: 16px;
	}

	.pfp-filters,
	.pfp-results {
		grid-column: 1;
		grid-row: auto;
	}

	.pfp-filter-toggle {
		display: flex;
	}

	.pfp-filters-close {
		display: inline-flex;
		align-items: center;
		justify-content: center;
	}

	.pfp-filters {
		position: fixed;
		top: 0;
		bottom: 0;
		left: 0;
		width: min(85vw, 340px);
		max-width: 340px;
		border-radius: 0;
		box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
		z-index: 999;
		overflow-y: auto;
		transform: translateX(-105%);
		transition: transform 0.28s ease;
		padding: 18px 18px 24px;
	}

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

	.pfp-wrapper.pfp-filters-open .pfp-filters-overlay {
		display: block;
		opacity: 1;
	}

	.pfp-filter-options {
		max-height: none;
	}

	.pfp-checkbox {
		font-size: 15px;
		padding: 9px 4px;
	}

	.pfp-checkbox input[type="checkbox"] {
		width: 19px;
		height: 19px;
	}

	.pfp-price-range::-webkit-slider-thumb,
	.pfp-price-range::-moz-range-thumb {
		width: 26px;
		height: 26px;
	}

	.pfp-reset-btn {
		padding: 13px;
		font-size: 14px;
	}
}

body.pfp-no-scroll {
	overflow: hidden;
}
