/**
 * NshWeb Filtre Produit — CSS public v1.0.4
 * Option B : panneau sticky sidebar PC/tablette | toggle accordéon mobile
 */

/* =====================================================================
   VARIABLES (remplacées dynamiquement via wp_add_inline_style)
   ===================================================================== */
:root {
    --nshweb-fp-fond:            #ffffff;
    --nshweb-fp-texte:           #333333;
    --nshweb-fp-accent:          #0073aa;
    --nshweb-fp-hover:           #005177;
    --nshweb-fp-bordure-couleur: #e2e2e2;
    --nshweb-fp-radius:          8px;
    --nshweb-fp-bordure-taille:  1px;
    --nshweb-fp-police:          inherit;
    --nshweb-fp-taille-police:   14px;
    --nshweb-fp-padding:         16px;
    --nshweb-fp-largeur:         260px;
    --nshweb-fp-transition:      0.2s ease;
    --nshweb-fp-liste-max-h:     200px;
}

/* =====================================================================
   WRAPPER
   ===================================================================== */
.nshweb-fp-wrapper {
    font-family: var(--nshweb-fp-police);
    font-size: var(--nshweb-fp-taille-police);
    color: var(--nshweb-fp-texte);
    box-sizing: border-box;
}

/* =====================================================================
   BOUTON TOGGLE MOBILE — caché sur PC/tablette
   ===================================================================== */
.nshweb-fp-mobile-toggle {
    display: none;
}

/* =====================================================================
   PANNEAU — PC & TABLETTE (≥ 769px) — OPTION B : sticky sidebar
   ===================================================================== */
@media (min-width: 1200px) {

    .nshweb-fp-filter-panel {
        width: var(--nshweb-fp-largeur);
        min-width: var(--nshweb-fp-largeur);
        background: var(--nshweb-fp-fond);
        border: var(--nshweb-fp-bordure-taille) solid var(--nshweb-fp-bordure-couleur);
        border-radius: var(--nshweb-fp-radius);
        box-shadow: 0 1px 4px rgba(0,0,0,0.07);
        /* Sticky : reste visible pendant le scroll */
        position: sticky;
        top: 24px;
        max-height: calc(100vh - 48px);
        overflow-y: auto;
        overflow-x: hidden;
        scrollbar-width: thin;
        scrollbar-color: var(--nshweb-fp-bordure-couleur) transparent;
    }
    .nshweb-fp-filter-panel::-webkit-scrollbar { width: 3px; }
    .nshweb-fp-filter-panel::-webkit-scrollbar-thumb {
        background: var(--nshweb-fp-bordure-couleur);
        border-radius: 3px;
    }

    /* En-tête collé en haut même quand on scrolle dans le panneau */
    .nshweb-fp-panel-header {
        position: sticky;
        top: 0;
        z-index: 2;
        background: var(--nshweb-fp-fond);
    }

    /* Scroll interne par section */
    .nshweb-fp-section-body {
        max-height: var(--nshweb-fp-liste-max-h);
        overflow-y: auto;
        scrollbar-width: thin;
        scrollbar-color: var(--nshweb-fp-bordure-couleur) transparent;
    }
    .nshweb-fp-section-body::-webkit-scrollbar { width: 3px; }
    .nshweb-fp-section-body::-webkit-scrollbar-thumb {
        background: var(--nshweb-fp-bordure-couleur);
        border-radius: 3px;
    }
    /* Pas de scroll sur la section prix */
    .nshweb-fp-section-body--noscroll {
        max-height: none;
        overflow: visible;
    }
}

/* =====================================================================
   EN-TÊTE DU PANNEAU
   ===================================================================== */
.nshweb-fp-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px var(--nshweb-fp-padding);
    border-bottom: var(--nshweb-fp-bordure-taille) solid var(--nshweb-fp-bordure-couleur);
}

.nshweb-fp-panel-title {
    font-weight: 700;
    font-size: calc(var(--nshweb-fp-taille-police) + 1px);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--nshweb-fp-texte);
}

.nshweb-fp-reset-btn {
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    font-size: calc(var(--nshweb-fp-taille-police) - 1px);
    color: #aaa;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color var(--nshweb-fp-transition);
}
.nshweb-fp-reset-btn:hover { color: var(--nshweb-fp-accent); }
.nshweb-fp-reset-btn:focus-visible {
    outline: 2px solid var(--nshweb-fp-accent);
    outline-offset: 2px;
    border-radius: 2px;
}

/* =====================================================================
   SECTIONS (accordéon)
   ===================================================================== */
.nshweb-fp-section {
    border-bottom: var(--nshweb-fp-bordure-taille) solid var(--nshweb-fp-bordure-couleur);
}
.nshweb-fp-section:last-child { border-bottom: none; }

.nshweb-fp-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px var(--nshweb-fp-padding);
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: var(--nshweb-fp-taille-police);
    font-weight: 600;
    color: var(--nshweb-fp-texte);
    text-align: left;
    transition: background var(--nshweb-fp-transition);
}
.nshweb-fp-section-toggle:hover { background: rgba(0,0,0,0.025); }
.nshweb-fp-section-toggle:focus-visible {
    outline: 2px solid var(--nshweb-fp-accent);
    outline-offset: -2px;
}

.nshweb-fp-chevron {
    flex-shrink: 0;
    color: #ccc;
    transition: transform var(--nshweb-fp-transition);
}
.nshweb-fp-section-toggle[aria-expanded="false"] .nshweb-fp-chevron {
    transform: rotate(-90deg);
}
.nshweb-fp-section-toggle[aria-expanded="false"] + .nshweb-fp-section-body {
    display: none;
}

.nshweb-fp-section-body {
    padding: 6px var(--nshweb-fp-padding) 14px;
}

/* =====================================================================
   LISTE DE CASES À COCHER
   ===================================================================== */
.nshweb-fp-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nshweb-fp-check-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    padding: 3px 0;
}
.nshweb-fp-check-label:hover .nshweb-fp-term-name {
    color: var(--nshweb-fp-accent);
}

/* Masquer la checkbox native */
.nshweb-fp-check-label input[type="checkbox"],
.nshweb-fp-promo-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* Checkbox stylée */
.nshweb-fp-checkmark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 17px;
    min-width: 17px;
    border: 2px solid var(--nshweb-fp-bordure-couleur);
    border-radius: 4px;
    background: #fff;
    transition:
        background var(--nshweb-fp-transition),
        border-color var(--nshweb-fp-transition);
}
.nshweb-fp-check-label input:checked ~ .nshweb-fp-checkmark,
.nshweb-fp-promo-label input:checked ~ .nshweb-fp-checkmark {
    background: var(--nshweb-fp-accent);
    border-color: var(--nshweb-fp-accent);
}
.nshweb-fp-checkmark::after {
    content: '';
    display: none;
    width: 4px;
    height: 8px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg) translate(-1px, -1px);
}
.nshweb-fp-check-label input:checked ~ .nshweb-fp-checkmark::after,
.nshweb-fp-promo-label input:checked ~ .nshweb-fp-checkmark::after {
    display: block;
}
.nshweb-fp-check-label input:focus-visible ~ .nshweb-fp-checkmark {
    outline: 2px solid var(--nshweb-fp-accent);
    outline-offset: 1px;
}

.nshweb-fp-term-name {
    flex: 1;
    line-height: 1.35;
    transition: color var(--nshweb-fp-transition);
}
.nshweb-fp-term-count {
    font-size: 12px;
    color: #bbb;
}

/* =====================================================================
   NUAGE D'ÉTIQUETTES
   ===================================================================== */
.nshweb-fp-tags-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.nshweb-fp-tag-label {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    padding: 4px 11px;
    border: var(--nshweb-fp-bordure-taille) solid var(--nshweb-fp-bordure-couleur);
    border-radius: 999px;
    font-size: 13px;
    background: #fff;
    user-select: none;
    transition:
        background var(--nshweb-fp-transition),
        border-color var(--nshweb-fp-transition),
        color var(--nshweb-fp-transition);
}
.nshweb-fp-tag-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.nshweb-fp-tag-label:hover {
    border-color: var(--nshweb-fp-accent);
    color: var(--nshweb-fp-accent);
}
.nshweb-fp-tag-label:has(input:checked) {
    background: var(--nshweb-fp-accent);
    border-color: var(--nshweb-fp-accent);
    color: #fff;
}

/* =====================================================================
   DOUBLE RANGE SLIDER PRIX
   ===================================================================== */
.nshweb-fp-price-display {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    font-size: 13px;
    font-weight: 500;
}
.nshweb-fp-price-label {
    background: #f5f5f5;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid #eee;
}
.nshweb-fp-price-sep { color: #ccc; }

.nshweb-fp-range-wrapper {
    position: relative;
    height: 34px;
    display: flex;
    align-items: center;
}
.nshweb-fp-range-track {
    position: absolute;
    width: 100%;
    height: 3px;
    background: #e5e5e5;
    border-radius: 3px;
    pointer-events: none;
}
.nshweb-fp-range-fill {
    position: absolute;
    height: 100%;
    background: var(--nshweb-fp-accent);
    border-radius: 3px;
}
.nshweb-fp-range {
    position: absolute;
    width: 100%;
    height: 3px;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    pointer-events: none;
    z-index: 2;
}
.nshweb-fp-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--nshweb-fp-accent);
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    cursor: pointer;
    pointer-events: all;
    transition: transform var(--nshweb-fp-transition);
}
.nshweb-fp-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--nshweb-fp-accent);
    cursor: pointer;
    pointer-events: all;
}
.nshweb-fp-range::-webkit-slider-thumb:hover,
.nshweb-fp-range::-webkit-slider-thumb:active {
    transform: scale(1.2);
    background: var(--nshweb-fp-accent);
}

.nshweb-fp-promo-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    cursor: pointer;
    font-size: 13px;
    user-select: none;
}

/* =====================================================================
   OVERLAY DE CHARGEMENT
   ===================================================================== */
.nshweb-fp-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.75);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 80px;
    z-index: 200;
}
.nshweb-fp-spinner {
    width: 34px;
    height: 34px;
    border: 3px solid #e5e5e5;
    border-top-color: var(--nshweb-fp-accent);
    border-radius: 50%;
    animation: nshweb-spin 0.6s linear infinite;
}
@keyframes nshweb-spin { to { transform: rotate(360deg); } }




/* =====================================================================
   MOBILE (≤ 768px) — toggle accordéon
   ===================================================================== */
@media (max-width: 1199px) {

    /* Bouton toggle visible */
    .nshweb-fp-mobile-toggle {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        padding: 12px var(--nshweb-fp-padding);
        background: var(--nshweb-fp-fond);
        border: var(--nshweb-fp-bordure-taille) solid var(--nshweb-fp-bordure-couleur);
        border-radius: var(--nshweb-fp-radius);
        font-family: inherit;
        font-size: var(--nshweb-fp-taille-police);
        font-weight: 600;
        color: var(--nshweb-fp-texte);
        cursor: pointer;
        text-align: left;
        transition: background var(--nshweb-fp-transition);
    }
    .nshweb-fp-mobile-toggle:hover { background: #fafafa; }

    .nshweb-fp-toggle-label { flex: 1; }

    .nshweb-fp-toggle-chevron {
        color: #bbb;
        transition: transform var(--nshweb-fp-transition);
        margin-left: auto;
    }
    .nshweb-fp-mobile-toggle[aria-expanded="true"] .nshweb-fp-toggle-chevron {
        transform: rotate(180deg);
    }

    /* Badge nombre de filtres actifs */
    .nshweb-fp-badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 20px;
        height: 20px;
        padding: 0 5px;
        background: var(--nshweb-fp-accent);
        color: #fff;
        border-radius: 999px;
        font-size: 11px;
        font-weight: 700;
        line-height: 1;
    }

    /* Panneau replié par défaut */
    .nshweb-fp-filter-panel {
        display: none;
        width: 100%;
        max-width: 100%;
        border: var(--nshweb-fp-bordure-taille) solid var(--nshweb-fp-bordure-couleur);
        border-top: none;
        border-radius: 0 0 var(--nshweb-fp-radius) var(--nshweb-fp-radius);
        background: var(--nshweb-fp-fond);
        overflow: hidden;
    }
    .nshweb-fp-filter-panel.is-open {
        display: block;
    }

    /* En-tête masqué sur mobile (le toggle externe suffit) */
    .nshweb-fp-panel-header { display: none; }

    /* Scroll interne des listes sur mobile */
    .nshweb-fp-section-body {
        max-height: 180px;
        overflow-y: auto;
        scrollbar-width: thin;
    }
    .nshweb-fp-section-body--noscroll {
        max-height: none;
        overflow: visible;
    }
}
