/**
 * Filtres ThemeVolty améliorés.
 *
 * Desktop : filtres intégrés sous la barre de tri.
 * Mobile/tablette : panneau latéral.
 */

:root {
    --ph-filter-text: #161616;
    --ph-filter-muted: #707070;
    --ph-filter-border: #e4e6e8;
    --ph-filter-soft: #f7f8f9;
    --ph-filter-accent: #171717;
    --ph-filter-radius: 8px;
}

.ph-filter-trigger {
    cursor: pointer;
    outline: none;
}

.ph-filter-trigger:focus-visible {
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.16);
}

/* -------------------------------------------------------------------------
 * Affichage intégré sur ordinateur
 * ---------------------------------------------------------------------- */

@media (min-width: 992px) {
    #search_filters_wrapper.ph-filter-desktop {
        display: block !important;
        width: 100%;
        margin: 18px 0 24px;
        padding: 0;
        overflow: hidden;
        border: 1px solid var(--ph-filter-border);
        border-radius: var(--ph-filter-radius);
        background: #fff;
        box-shadow: 0 5px 18px rgba(0, 0, 0, 0.04);
        max-height: 0;
        opacity: 0;
        transform: translateY(-6px);
        visibility: hidden;
        transition:
            max-height 0.32s ease,
            opacity 0.22s ease,
            transform 0.22s ease,
            visibility 0.22s ease;
    }

    #search_filters_wrapper.ph-filter-desktop.ph-filter-open {
        max-height: 2200px;
        opacity: 1;
        transform: translateY(0);
        visibility: visible;
    }

    #search_filters_wrapper.ph-filter-desktop .tv_search_filter_wrapper,
    #search_filters_wrapper.ph-filter-desktop > .block-title,
    #search_filters_wrapper.ph-filter-desktop > .title {
        margin: 0;
        padding: 15px 20px;
        border-bottom: 1px solid var(--ph-filter-border);
        background: #fff;
        color: var(--ph-filter-text);
        font-size: 17px;
        font-weight: 700;
        text-transform: uppercase;
    }

    #search_filters_wrapper.ph-filter-desktop #search_filters {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 14px;
        margin: 0;
        padding: 16px;
        background: var(--ph-filter-soft);
    }
}

/* -------------------------------------------------------------------------
 * Cartes et accordéons de facettes
 * ---------------------------------------------------------------------- */

#search_filters_wrapper.ph-filter-enhanced .facet.ph-facet-card {
    min-width: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--ph-filter-border);
    border-radius: 7px;
    background: #fff;
}

#search_filters_wrapper.ph-filter-enhanced .ph-facet-title {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 46px;
    margin: 0 !important;
    padding: 12px 42px 12px 14px !important;
    border: 0 !important;
    background: #fff;
    color: var(--ph-filter-text);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
}

#search_filters_wrapper.ph-filter-enhanced .ph-facet-title::after {
    position: absolute;
    right: 15px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    content: '';
    transform: translateY(-65%) rotate(45deg);
    transition: transform 0.18s ease;
}

#search_filters_wrapper.ph-filter-enhanced .ph-facet-title.ph-facet-title-open::after {
    transform: translateY(-30%) rotate(225deg);
}

#search_filters_wrapper.ph-filter-enhanced .ph-facet-title:focus-visible {
    outline: 2px solid var(--ph-filter-accent);
    outline-offset: -2px;
}

#search_filters_wrapper.ph-filter-enhanced .ph-facet-body {
    display: block !important;
    margin: 0 !important;
    padding: 2px 13px 13px !important;
    border-top: 1px solid #f0f0f0;
}

#search_filters_wrapper.ph-filter-enhanced .ph-facet-collapsed .ph-facet-body {
    display: none !important;
}

#search_filters_wrapper.ph-filter-enhanced .ph-facet-body > ul,
#search_filters_wrapper.ph-filter-enhanced .ph-facet-body ul {
    max-height: 220px;
    margin: 0;
    padding: 6px 2px;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
}

#search_filters_wrapper.ph-filter-enhanced .ph-facet-body li {
    margin: 0;
    padding: 0;
}

#search_filters_wrapper.ph-filter-enhanced .facet-label {
    display: flex !important;
    align-items: center;
    width: 100%;
    min-height: 34px;
    margin: 0 !important;
    padding: 5px 2px !important;
    color: var(--ph-filter-text);
    cursor: pointer;
}

#search_filters_wrapper.ph-filter-enhanced .facet-label:hover {
    color: #000;
}

#search_filters_wrapper.ph-filter-enhanced .facet-label > a,
#search_filters_wrapper.ph-filter-enhanced .facet-label .search-link {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
    margin-left: 9px;
    color: inherit;
    font-size: 13px;
    line-height: 1.35;
    text-decoration: none;
}

#search_filters_wrapper.ph-filter-enhanced .facet-label .magnitude {
    flex: 0 0 auto;
    margin-left: auto;
    padding-left: 10px;
    color: var(--ph-filter-muted);
    font-size: 12px;
}

/* Cases à cocher : neutralise les styles ThemeVolty qui créaient des barres. */
#search_filters_wrapper.ph-filter-enhanced .custom-checkbox {
    position: relative;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex: 0 0 18px;
    width: 18px !important;
    height: 18px !important;
    margin: 0 !important;
}

#search_filters_wrapper.ph-filter-enhanced .custom-checkbox input[type='checkbox'] {
    position: absolute !important;
    inset: 0;
    z-index: 2;
    width: 18px !important;
    height: 18px !important;
    margin: 0 !important;
    padding: 0 !important;
    opacity: 0 !important;
    cursor: pointer;
}

#search_filters_wrapper.ph-filter-enhanced .custom-checkbox > .ps-shown-by-js {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 18px !important;
    height: 18px !important;
    min-width: 18px;
    padding: 0 !important;
    border: 1px solid #8a8a8a;
    border-radius: 4px;
    background: #fff;
    box-shadow: none !important;
}

#search_filters_wrapper.ph-filter-enhanced .custom-checkbox .checkbox-checked {
    display: none;
    margin: 0;
    color: #fff;
    font-size: 14px;
    line-height: 1;
}

#search_filters_wrapper.ph-filter-enhanced .custom-checkbox input[type='checkbox']:checked + .ps-shown-by-js {
    border-color: var(--ph-filter-accent);
    background: var(--ph-filter-accent);
}

#search_filters_wrapper.ph-filter-enhanced .custom-checkbox input[type='checkbox']:checked + .ps-shown-by-js .checkbox-checked {
    display: block;
}

#search_filters_wrapper.ph-filter-enhanced .custom-checkbox input[type='checkbox']:focus-visible + .ps-shown-by-js {
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.15) !important;
}

/* Boutons radio natifs éventuels. */
#search_filters_wrapper.ph-filter-enhanced input[type='radio'] {
    width: 18px;
    height: 18px;
    margin: 0 9px 0 0;
    accent-color: var(--ph-filter-accent);
}

/* Sélecteurs, champs et curseurs de prix. */
#search_filters_wrapper.ph-filter-enhanced select,
#search_filters_wrapper.ph-filter-enhanced input[type='text'],
#search_filters_wrapper.ph-filter-enhanced input[type='number'] {
    width: 100%;
    min-height: 38px;
    border: 1px solid #d7d9dc;
    border-radius: 5px;
    background: #fff;
}

#search_filters_wrapper.ph-filter-enhanced .faceted-slider,
#search_filters_wrapper.ph-filter-enhanced .facet-range,
#search_filters_wrapper.ph-filter-enhanced [id^='slider-range'] {
    width: auto !important;
    margin: 16px 6px 10px !important;
}

#search_filters_wrapper.ph-filter-enhanced .ui-slider {
    height: 5px;
    border: 0;
    border-radius: 10px;
    background: #d9dadd;
}

#search_filters_wrapper.ph-filter-enhanced .ui-slider-range {
    background: var(--ph-filter-accent);
}

#search_filters_wrapper.ph-filter-enhanced .ui-slider-handle {
    top: 50%;
    width: 18px;
    height: 18px;
    margin-top: -9px;
    border: 2px solid var(--ph-filter-accent);
    border-radius: 50%;
    background: #fff;
    cursor: grab;
}

/* Filtres actifs sous forme de pastilles. */
#js-active-search-filters:not(.hide) {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
    padding: 10px 12px;
    border: 1px solid var(--ph-filter-border);
    border-radius: var(--ph-filter-radius);
    background: var(--ph-filter-soft);
}

#js-active-search-filters .filter-block {
    margin: 0 !important;
    padding: 7px 10px !important;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

/* -------------------------------------------------------------------------
 * Panneau mobile/tablette
 * ---------------------------------------------------------------------- */

.ph-facet-panel {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10002;
    display: flex;
    flex-direction: column;
    width: min(420px, 94vw);
    height: 100vh;
    overflow: hidden;
    background: #fff;
    box-shadow: 8px 0 28px rgba(0, 0, 0, 0.24);
    transform: translateX(-105%);
    transition: transform 0.25s ease;
}

.ph-facet-panel.open {
    transform: translateX(0);
}

.ph-facet-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
    min-height: 58px;
    padding: 10px 14px 10px 18px;
    border-bottom: 1px solid var(--ph-filter-border);
}

.ph-facet-panel-title {
    color: var(--ph-filter-text);
    font-size: 18px;
    font-weight: 700;
}

.ph-facet-panel-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #222;
    font-size: 31px;
    line-height: 1;
    cursor: pointer;
}

.ph-facet-panel-close:hover,
.ph-facet-panel-close:focus {
    background: var(--ph-filter-soft);
}

.ph-facet-panel-content {
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px;
    overflow-y: auto;
}

.ph-facet-panel-content #search_filters_wrapper.ph-filter-mobile,
.ph-facet-panel-content #search_filters_wrapper.ph-filter-mobile #search_filters {
    display: block !important;
    width: 100%;
    margin: 0;
    padding: 0;
    visibility: visible !important;
    opacity: 1 !important;
}

.ph-facet-panel-content #search_filters_wrapper .tv_search_filter_wrapper,
.ph-facet-panel-content #search_filters_wrapper > .block-title,
.ph-facet-panel-content #search_filters_wrapper > .title {
    display: none !important;
}

.ph-facet-panel-content #search_filters.ph-filter-grid {
    display: block !important;
}

.ph-facet-panel-content .ph-facet-card {
    margin-bottom: 10px !important;
}

.ph-facet-panel-footer {
    flex: 0 0 auto;
    padding: 12px;
    border-top: 1px solid var(--ph-filter-border);
    background: #fff;
}

.ph-facet-show-products {
    width: 100%;
    min-height: 44px;
    padding: 10px 16px;
    border: 1px solid var(--ph-filter-accent);
    border-radius: 6px;
    background: var(--ph-filter-accent);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.ph-facet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: rgba(0, 0, 0, 0.48);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.ph-facet-backdrop.open {
    opacity: 1;
    visibility: visible;
}

body.ph-facet-panel-open {
    overflow: hidden;
}

@media (max-width: 991px) {
    #search_filters_wrapper.ph-filter-mobile {
        display: block !important;
    }
}

@media (min-width: 992px) and (max-width: 1199px) {
    #search_filters_wrapper.ph-filter-desktop #search_filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 575px) {
    .ph-facet-panel {
        width: 100vw;
    }
}

@media (prefers-reduced-motion: reduce) {
    #search_filters_wrapper.ph-filter-desktop,
    .ph-facet-panel,
    .ph-facet-backdrop,
    #search_filters_wrapper.ph-filter-enhanced .ph-facet-title::after {
        transition: none;
    }
}

/* Zone dédiée aux filtres dans la colonne principale. */
.ph-filter-desktop-host {
    display: block;
    width: 100%;
    min-width: 0;
    clear: both;
}
