/**
 * RP Filtres Produits - barre flottante fixe en haut + panneau déroulant.
 * Couleur principale = celle d'Astra (--ast-global-color-0) si disponible.
 *
 * Réglages rapides (à surcharger dans Apparence > Personnaliser > CSS additionnel) :
 *   .rpf { --rpf-top: 80px; }   -> décale la barre sous un header fixe
 */

.rpf {
	--rpf-accent: var(--ast-global-color-0, #0274be);
	--rpf-border: #e5e5e5;
	--rpf-muted: #8a8a8a;
	--rpf-top: 12px;

	position: fixed;          /* reste en haut de l'écran pendant le défilement */
	top: var(--rpf-top);
	left: 0;
	right: 0;
	margin: 0 auto;           /* centrage sans transform (évite les effets de bord) */
	z-index: 99999;
	width: min(960px, calc(100% - 24px));
	font-size: 15px;
	line-height: 1.4;
}
/* Barre d'administration WordPress */
body.admin-bar .rpf { top: calc(var(--rpf-top) + 32px); }
@media (max-width: 782px) {
	body.admin-bar .rpf { top: calc(var(--rpf-top) + 46px); }
}

/* ---------- Barre flottante ---------- */
.rpf__bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	background: #fff;
	border: 1px solid var(--rpf-border);
	border-radius: 999px;
	box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
	padding: 4px 8px 4px 4px;
}
.rpf__toggle {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 18px;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: #222;
	font-weight: 600;
	font-size: inherit;
	cursor: pointer;
}
.rpf__toggle:hover,
.rpf-open .rpf__toggle { background: #f4f4f4; }
.rpf__badge {
	min-width: 22px;
	padding: 1px 7px;
	border-radius: 999px;
	background: var(--rpf-accent);
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	text-align: center;
}
.rpf__badge[hidden] { display: none; }
.rpf__chevron {
	width: 8px;
	height: 8px;
	margin-left: 2px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg) translateY(-2px);
	transition: transform 0.2s ease;
}
.rpf-open .rpf__chevron { transform: rotate(-135deg) translateY(-2px); }

/* "Effacer" dans la barre : visible seulement s'il y a des filtres actifs */
.rpf-clear--bar { display: none; padding: 0 10px; }
.rpf--active .rpf-clear--bar { display: inline; }

/* ---------- Panneau déroulant ---------- */
.rpf__form {
	display: none;
	margin-top: 8px;
	padding: 8px 20px 20px;
	max-height: calc(100vh - 110px);
	overflow-y: auto;
	background: #fff;
	border: 1px solid var(--rpf-border);
	border-radius: 14px;
	box-shadow: 0 8px 28px rgba(0, 0, 0, 0.15);
}
.rpf-open .rpf__form { display: block; }

/* Groupes affichés en colonnes sur grand écran */
.rpf__form {
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	column-gap: 28px;
}
@media (min-width: 769px) {
	.rpf-open .rpf__form { display: grid; }
	.rpf-actions { grid-column: 1 / -1; }
}

.rpf-group {
	border-bottom: 1px solid var(--rpf-border);
	padding: 12px 0;
}
.rpf-group__title {
	cursor: pointer;
	font-weight: 600;
	margin-bottom: 8px;
	list-style: none;
}
.rpf-group__title::-webkit-details-marker { display: none; }
.rpf-group__title::after { content: "+"; float: right; color: var(--rpf-muted); }
.rpf-group[open] > .rpf-group__title::after { content: "\2212"; }

.rpf-list {
	list-style: none;
	margin: 8px 0 0;
	padding: 0;
	max-height: 240px;
	overflow-y: auto;
}
.rpf-item { margin: 0; padding: 0; }
.rpf-item label {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 5px 0;
	cursor: pointer;
}
.rpf-item input[type="checkbox"] { margin: 0; accent-color: var(--rpf-accent); }
.rpf-name { flex: 1; }
.rpf-count { color: var(--rpf-muted); font-size: 0.9em; }
.rpf-item.is-empty { opacity: 0.45; }

/* Prix */
.rpf-price { display: flex; gap: 10px; margin-top: 8px; }
.rpf-price label {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 4px;
	font-size: 0.9em;
	color: var(--rpf-muted);
}
.rpf-price input {
	width: 100%;
	padding: 8px;
	border: 1px solid var(--rpf-border);
	border-radius: 3px;
	color: #333;
}

/* Actions */
.rpf-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 14px;
	padding-top: 14px;
}
.rpf-apply,
.rpf-close {
	padding: 10px 20px;
	border: 0;
	border-radius: 999px;
	cursor: pointer;
	font-size: inherit;
}
.rpf-apply { background: var(--rpf-accent); color: #fff; }
.rpf-close { background: #f0f0f0; color: #222; margin-left: auto; }
.rpf-js .rpf-apply { display: none; } /* Inutile quand le JS est actif */
.rpf-clear { font-size: 0.9em; text-decoration: underline; color: var(--rpf-muted); }
.rpf-clear:hover { color: var(--rpf-accent); }

/* ---------- Résultats ---------- */
#rpf-results,
.elementor-widget-wc-archive-products,
.elementor-widget-woocommerce-products { transition: opacity 0.2s ease; }
.rpf-loading { opacity: 0.5; pointer-events: none; }
.rpf.rpf-loading { opacity: 1; pointer-events: auto; } /* la barre reste utilisable */
.rpf.rpf-loading .rpf__bar { opacity: 0.85; }

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
	.rpf { width: calc(100% - 16px); }
	.rpf__form { padding: 4px 14px 16px; max-height: calc(100vh - 100px); }
	.rpf-list { max-height: 180px; }
}

/* ---------- Grille (v1.1) ---------- */
ul.products { transition: opacity 0.2s ease; }
ul.products.rpf-loading { opacity: 0.45; pointer-events: none; }
ul.products li.rpf-empty {
	grid-column: 1 / -1;
	width: 100%;
	float: none;
	list-style: none;
	padding: 40px 0;
	text-align: center;
	color: #777;
}
