/* ==========================================================================
   BROCANTE.IO - STYLES DES FILTRES AJAX (bf-*)
   ========================================================================== */

/* --- 1. BARRE LATÉRALE (FILTRES) --- */
.bf-sidebar {
    background: #ffffff;
    padding-right: 20px;
}
.bf-sidebar-title {
    margin-top: 0;
    line-height: 40px;
}

/* --- 2. ACCORDÉONS --- */
.bf-accordion-item {
    padding: 20px 0;
    border-top: 1px solid var(--wp--preset--color--accent-6);
}

.bf-accordion-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    padding: 0;

    font-family: var(--wp--preset--font-family--abhaya-libre);
    font-style: normal;
    font-weight: 600;
    letter-spacing: -0.1px;
    line-height: 1.125;
    outline: none;
}

.bf-accordion-toggle:focus {
    color: var(--wp--preset--color--accent-4);
}

.bf-accordion-icon {
    font-size: 10px;
    border: 1px solid var(--wp--preset--color--accent-6);
    padding: 5px;
    color: #000;
}
[aria-expanded="false"] .bf-accordion-icon {
    color: #fff;
    background-color: #000;
}
.bf-accordion-content {
    padding-top: 15px;
}

/* --- 3. INPUTS & CASES À COCHER --- */
.bf-range-group {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 5px;
}
.bf-range-group span {
    color: var(--wp--preset--color--accent-4);
}

.bf-catalogue-range {
    font-size: 0.7em;
    color: var(--wp--preset--color--accent-4);
}

.bf-input-number {
    width: 100%;
    padding: 4px;
    border: 1px solid var(--wp--preset--color--accent-4);
}

.bf-checkbox-list {
    display: flex;
    flex-direction: column;
}

.bf-checkbox-label {
    display: flex;
    align-items: center;
    margin-bottom: 0.6em !important;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.2s ease; /* L'opacité est gérée par Preact */
}

.bf-checkbox-input {
    margin-right: 8px;
}
.bf-checkbox-input[type="checkbox"] {
    accent-color: #000;
    outline: none;
}

.bf-count {
    color: var(--wp--preset--color--accent-4);
    font-size: 12px;
    margin-left: 4px;
}

.bf-btn-show-more {
    order: 9999; /* Toujours en bas de la liste flex */
    background: none;
    border: none;
    padding: 0;
    color: #000;
    text-decoration: underline;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    margin-top: 5px;
}

/* --- 4. GRILLE ET CONTRÔLES --- */
.bf-grid-wrapper {
    position: relative;
}

.bf-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2em;
    color: #000;
    z-index: 10;
    display: none; /* Preact injectera 'display: flex' en inline */
}

.bf-filter-top {
    padding: 0px 0px 20px;
    min-height: 40px;
}

/* --- 5. PASTILLES (PILLS) --- */
.bf-pills-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    min-height: 40px;
}

.bf-icon {
    position: relative;
    text-align: left;
    padding-right: 30px;
    padding: 5px 30px 5px 8px;
    cursor: pointer;
    border: 1px solid #000;
    background-color: #fff;
    color: #000;
    transition: background 0.2s;
}

.bf-icon:hover {
    background-color: #000;
    color: #fff;
}
.bf-icon:hover::after {
    background-color: #fff;
}

.bf-icon::after {
    content: " ";
    position: absolute;
    width: 25px;
    height: 25px;
    top: 0;
    right: 0;
    display: inline-block;
    background-color: #000;
}

.bf-icon.close::after {
    mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"/></svg>');
    mask-size: contain;
    mask-repeat: no-repeat;

    -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"/></svg>');
    -webkit-mask-size: contain;
    -webkit-mask-repeat: no-repeat;
}
.bf-icon.arrow-l::after,
.bf-icon.filter::after {
    mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z"/></svg>');
    mask-size: contain;
    mask-repeat: no-repeat;

    -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z"/></svg>');
    -webkit-mask-size: contain;
    -webkit-mask-repeat: no-repeat;
}
.bf-icon.arrow-l::after,
.bf-icon.arrow-r::after {
    mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m7.502 7.7549v9.1582l9.1875-4.5762z"/></svg>');
    mask-size: contain;
    mask-repeat: no-repeat;

    -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m7.502 7.7549v9.1582l9.1875-4.5762z"/></svg>');
    -webkit-mask-size: contain;
    -webkit-mask-repeat: no-repeat;
}

.bf-close-mobile {
    background: #000;
    color: #fff;
    border: none;
    width: 30px;
    height: 30px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bf-mobile-toggle,
.bf-close-mobile,
.bf-btn-reset-all {
    background: #000;
    color: #fff;
}
.bf-mobile-toggle::after,
.bf-close-mobile::after,
.bf-btn-reset-all::after {
    background-color: #fff;
}

.bf-btn-reset-all:hover {
    background: #fff;
    color: #000;
}

.bf-btn-reset-all:hover::after {
    background-color: #000;
}

.bf-icon.bf-btn-page.arrow-r,
.bf-icon.bf-btn-page.arrow-l,
.bf-close-mobile {
    padding: 20px;
    white-space: nowrap;
    text-indent: -9999px;
    overflow: hidden;
}

.bf-icon.bf-btn-page.arrow-r,
.bf-icon.bf-btn-page.arrow-l {
    padding: 10px 20px;
}

.bf-icon.bf-btn-page.arrow-r::after {
    top: 5px;
    right: 5px;
}

.bf-icon.bf-btn-page.arrow-l::after {
    transform: rotate(180deg);
    top: 5px;
    left: 5px;
}

.bf-mobile-toggle.bf-icon {
    padding: 10px 50px 10px 15px;
}

.bf-mobile-toggle::after,
.bf-close-mobile::after {
    width: 30px;
    height: 30px;
    right: 5px;
    top: 5px;
}

.bf-pill-close {
    font-size: 10px;
    color: var(--wp--preset--color--accent-4);
}
.bf-pill-clear-all {
    background: none;
    border: none;
    color: #0075ff;
    text-decoration: underline;
    cursor: pointer;
    font-size: 12px;
    padding: 4px;
}

/* --- 6. BARRE D'OUTILS ET PAGINATION --- */
.bf-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--wp--preset--color--accent-6);
}

@media (min-width: 768px) {
    .bf-toolbar {
        margin-top: 30px;
    }
    .bf-sidebar-wrapper {
        margin-top: 45px;
    }
}

@media (max-width: 768px) {
    .bf-toolbar > span {
        align-self: self-end;
    }
}

.bf-toolbar label {
    margin-bottom: 0;
}
.bf-toolbar > span {
    font-size: 1.5em;
}
.bf-toolbar select {
    width: 100%;
}
.bf-select,
.bf-btn-page {
    padding: 10px 14px;
    border: 1px solid #000;
    background: #ffffff;
    cursor: pointer;
    white-space: nowrap;
}

button.bf-btn-page:disabled {
    opacity: 0.33;
    cursor: initial;
}
button.bf-btn-page:disabled::after {
    opacity: 0.5;
}
button.bf-btn-page:disabled:hover {
    background: #fff;
}
button.bf-btn-page:disabled:hover::after {
    background: #000;
}
.bf-pages-number {
    display: flex;
    gap: 10px;
}
.bf-pagination {
    margin-top: 40px;
    margin-bottom: 40px;
    display: flex;
    align-items: self-end;
    justify-content: space-between;
    gap: 15px;
    padding-top: 20px;
}

@media (max-width: 768px) {
    .bf-pages-number {
        display: flex;
        gap: 4px;
    }
    .bf-pagination {
        gap: 4px;
        font-size: 0.7rem;
    }

    .bf-icon.bf-btn-page.arrow-r,
    .bf-icon.bf-btn-page.arrow-l {
        padding: 10px 15px;
    }
    .bf-btn-page {
        padding: 10px;
        font-size: 0.7rem;
    }
}

/* --- 7. PRODUITS CUSTOM WOOCOMMERCE --- */
.bf-products-grid {
    display: grid;
    grid-template-columns: repeat(
        auto-fill,
        minmax(max(150px, calc(25% - 0.9375em)), 1fr)
    );
    grid-gap: 1.25em;
    list-style: none;
    padding: 0;
    margin: 0;
}

.bf-product-card {
    position: relative;
}

.bf-product-card a::after {
    position: absolute;
    right: -10px;
    bottom: -10px;
    left: -10px;
    top: -10px;
    content: " ";
    width: calc(100% + 20px);
    height: calc(100% + 20px);
}

.bf-product-card a:hover::after {
    border: 1px solid #000;
    pointer-events: none;
    user-select: none;
}

.bf-product-title {
    font-size: 1.1em;
    font-weight: bold;
    margin: 10px 0 5px 0;
    min-height: 44px;
}

/* 🛡️ FORCE LA DISPARITION DES ÉLÉMENTS CACHÉS PAR PREACT */
[data-wp-interactive="brocanteFiltres"] [hidden] {
    display: none !important;
}

.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product {
    width: 100% !important;
    margin: auto !important;
}

.woocommerce .products ul::after,
.woocommerce .products ul::before,
.woocommerce ul.products::after,
.woocommerce ul.products::before {
    display: none !important;
}

/* --- 8. SLIDER DE PRIX (DUAL RANGE) --- */
.bf-price-slider-container {
    position: relative;
    height: 5px;
    background: #e2e2e2;
    border-radius: 5px;
    margin: 20px 0 15px 0;
}

.bf-slider-progress {
    position: absolute;
    height: 100%;
    background: #222222; /* La couleur de la barre entre les deux poignées */
    border-radius: 5px;
    z-index: 1;
}

.bf-range-input {
    position: absolute;
    top: -10px; /* Pour centrer la poignée sur la barre */
    left: 0;
    width: 100%;
    background: transparent;
    pointer-events: none; /* On rend la piste native incliquable... */
    -webkit-appearance: none;
    z-index: 2;
    margin: 0;
    outline: none;
}

/* ...Mais on garde les poignées cliquables ! */
.bf-range-input::-webkit-slider-thumb {
    pointer-events: auto;
    -webkit-appearance: none;
    width: 25px;
    height: 25px;
    background-color: #fff;
    border: 2px solid #000;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

.bf-range-input::-moz-range-thumb {
    pointer-events: auto;
    width: 25px;
    height: 25px;
    background-color: #fff;
    border: 2px solid #000;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   8. MODE MOBILE (TIROIR OFF-CANVAS)
   ========================================================================== */

/* Bouton d'ouverture caché par défaut sur Desktop */
.bf-mobile-toggle {
    display: none;
}

/* En-tête du menu mobile caché par défaut sur Desktop */
.bf-sidebar-footer-mobile,
.bf-sidebar-header-mobile {
    display: none;
}

/* 📱 RÈGLES POUR LES ÉCRANS MOBILES ET TABLETTES (Max 768px) */
@media (max-width: 768px) {
    /* 1. On affiche le bouton d'ouverture au-dessus de la grille */

    .bf-mobile-toggle > span {
        border: 1px solid #fff;
        background-color: #fff;
        color: #000;
        border-radius: 50%;
        min-width: 22px;
        height: 22px;
        text-align: center;
        line-height: 20px;
        font-weight: bold;
        font-size: 12px;
    }

    .bf-mobile-toggle {
        display: block;
        width: 100%;
        padding: 10px;
        background: #000;
        color: #ffffff;
        border: none;
        margin-bottom: 0;
        cursor: pointer;
        text-transform: uppercase;
        display: flex;
        justify-content: space-between;
        line-height: 24px;
    }

    /* 2. Le conteneur invisible qui prend tout l'écran */
    .bf-sidebar-wrapper {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 99999;
        pointer-events: none; /* Laisse passer les clics quand c'est fermé */
        visibility: hidden;
    }
    .bf-sidebar-wrapper.is-open {
        pointer-events: auto;
        visibility: visible;
    }

    /* 3. Le voile sombre semi-transparent */
    .bf-mobile-overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.6);
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    .bf-sidebar-wrapper.is-open .bf-mobile-overlay {
        opacity: 1;
    }

    /* 4. Le tiroir qui glisse depuis la droite */
    .bf-sidebar {
        position: absolute;
        top: 0;
        right: -100%; /* Caché hors de l'écran à droite */
        width: 85%;
        max-width: 350px;
        background: #ffffff;
        padding: 20px 20px 100px 20px;
        height: calc(
            100% - 120px
        ); /* Phauteur du bouton appliquer les filtres +padding-top*/
        overflow-y: auto; /* Permet le scroll interne */
        transition: right 0.3s ease; /* L'animation de glissement */
        border: none;
    }
    .bf-sidebar-wrapper.is-open .bf-sidebar {
        right: 0; /* Arrive sur l'écran */
    }

    /* 5. L'en-tête du menu mobile avec la croix de fermeture */
    .bf-sidebar-header-mobile {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
    }

    .bf-close-mobile-footer {
        width: 100%;
        position: fixed;
        bottom: 0;
        right: 0;
        z-index: 9999;
        padding: 20px;
        border: none;
        background-color: #000;
        color: #fff;
    }

    /* On cache le titre classique pour utiliser celui du header mobile */
    .bf-sidebar > .bf-sidebar-title {
        display: none;
        margin-bottom: 24px;
    }

    .bf-sidebar-footer-mobile {
        display: block;
        position: fixed;
        bottom: 0;
        width: 85%;
        max-width: 350px;
        padding: 20px;
        background: #fff;
        right: -100%;
        transition: right 0.3s ease;
    }

    .bf-sidebar-wrapper.is-open .bf-sidebar-footer-mobile {
        right: 0; /* Arrive sur l'écran */
    }

    .bf-footer-close-mobile {
        background-color: #000;
        color: #fff;
        padding: 20px;
        width: 100%;
    }
}

/* ==========================================================================
   🔍 BARRE DE RECHERCHE HEADLESS
   ========================================================================== */
.bf-search-container {
    position: relative;
}

h1.bf-catalog-title {
    margin-top: 20px;
}

.bf-search-form {
    display: flex;
    border: 1px solid #000;
    border-bottom: 0 none;
}
.bf-search-form:focus-within {
    box-shadow: -10px -5px 25px 0px rgba(0, 0, 0, 0.15);
}

.bf-search-input {
    flex-grow: 1;
    border: none;
    padding: 12px 15px;
    font-size: 16px; /* 16px min sur mobile pour éviter le zoom auto iOS */
    outline: none;
    padding-left: 1.5625rem;
    padding-right: 1.5625rem;
    line-height: 1.6;
    height: 56px;
    font-weight: lighter;
    color: #000;
    background-color: #fff;
}

.bf-search-input::placeholder {
    color: var(--text-light);
}

.bf-search-input:focus::placeholder {
    color: #aaa;
}

.bf-search-btn {
    background: #000;
    color: #fff;
    border: none;
    padding: 0 20px;
    cursor: pointer;
}
.bf-search-btn svg {
    fill: currentColor;
    height: 1.25em;
    min-height: 24px;
    min-width: 24px;
    vertical-align: text-bottom;
    width: 1.25em;
}

/* --- LE MENU DÉROULANT --- */
.bf-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #fff;
    border: 1px solid #ddd;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    z-index: 99999;
    overflow: hidden;
}

.bf-search-no-results {
    padding: 20px;
    text-align: center;
    color: #666;
}

.bf-search-results {
    list-style: none;
    margin: 0;
    padding: 0;
}

.bf-search-item {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.bf-search-item:hover {
    background: #f9f9f9;
}

.bf-search-item img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    margin-right: 15px;
}

.bf-search-item-info {
    display: flex;
    flex-direction: column;
}

.bf-search-item-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bf-search-item-price {
    font-size: 13px;
    color: var(--wp--preset--color--accent-4, #d32f2f);
    font-family: monospace;
    cursor: pointer;
}

.bf-search-all-link {
    display: block;
    text-align: center;
    padding: 12px;
    background: #f5f5f5;
    color: #000;
    text-decoration: none;
    font-weight: bold;
    font-size: 14px;
    border-top: 1px solid var(--wp--preset--color--accent-6);
}

.bf-search-all-link:hover {
    text-decoration: underline;
}
.search-column {
    border-bottom: 1px solid #000 !important;
}
/* CLS */
.bf-grid-wrapper {
    min-height: 80vh;
    position: relative;
}

.bf-products-grid {
    transition:
        opacity 0.2s ease-in-out,
        filter 0.2s ease-in-out;
}

[aria-busy="true"] .bf-products-grid {
    opacity: 0.5;
    filter: blur(2px);
    pointer-events: none;
}

@media (max-width: 768px) {
    .bf-search-dropdown {
        position: fixed; /* Se détache de l'input */
        left: 0;
        width: 100vw; /* Prend toute la largeur */
        border: none;
        border-radius: 0;
        overflow-y: auto; /* Permet de scroller les résultats */
        height: calc(100vh - 56px);
        top: 56px;
        border-top: 1px solid #000;
    }

    .bf-search-form.is-open {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 99999;
        border: 0;
        background-color: #fff;
    }
}
