/* ==========================================================
   RESET STRUTTURA SIDEBAR
========================================================== */

#af-sidebar {
    background: #f5f5f5;
    overscroll-behavior: auto;
    overscroll-behavior-y: auto;
    box-sizing: border-box;
    max-height: 1000px;      
    overflow-y: auto;       
    overflow-x: hidden;
    z-index: 380;
    position: relative;
    /* --af-header-offset: 64px; */
    scrollbar-width: thin;
}


/* HEADER */
.af-header {
    padding: 18px 20px;
    display: flex;
    /* justify-content: space-between; */
    gap: 170px;
    align-items: center;
    position: sticky;
    top: 0;
    background: #242424;
    z-index: 30;
    color: #fff;
}

.af-title {
    font-size: 22px;
    font-weight: bold;
    color: #fff;
}

.af-header .af-close {
    margin-left: auto;
    background: none;
    border: 1px solid #fff;
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
    background-color: #242424;
    border-radius: 8px;
    color: #fff;
    width: 42px;
    height: 42px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}


/* ==========================================================
   MOBILE MODE (OFF-CANVAS)
========================================================== */

@media (max-width: 767px) {
    #af-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: auto;
        width: 100%;
        height: 100%;
        transform: translateX(-100%);
        transition: transform 0.35s ease;
        display: flex;
        flex-direction: column;
        z-index: 390;
    }

    #af-sidebar.af-open {
        transform: translateX(0);
    }

    #af-sidebar .af-inner {
        flex: 1 1 auto;
        padding-bottom: 90px;
    }

    body.af-sidebar-open {
        position: fixed;
        width: 100%;
        overflow: hidden;
    }

    #af-sidebar .af-filter-group h4 {
        cursor: pointer;
        position: relative;
        padding-right: 54px;
    }

    #af-sidebar .af-filter-group h4:after {
        content: "›";
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        color: #777;
        font-size: 30px;
    }

    #af-sidebar .af-filter-group h4 .af-controls-count {
        position: absolute;
        right: 28px;
        top: 50%;
        transform: translateY(-50%);
        min-width: 22px;
        height: 22px;
        padding: 0 6px;
        border-radius: 5px;
        background: #e30513;
        color: #fff;
        font-size: 15px;
        font-weight: 700;
        line-height: 22px;
        text-align: center;
    }
}

@media (min-width: 768px) {
    .af-controls-count {
        display: none;
    }
}

@media (max-width: 767px) {
    #af-sidebar .af-filter-group h4 .af-controls-count--hidden {
        display: none;
    }

    #af-sidebar .af-filter-scroll {
        display: none;
    }

    #af-sidebar .af-filter-group {
        padding: 0px 20px;
        margin-bottom: 6px;
    }

    #af-sidebar .af-filter-group h4 {
        margin-bottom: 0;
        border-bottom: none;
        padding: 20px 0px;
    }

    #af-sidebar .af-filter-group h4 .af-attr-clear-mini {
        position: absolute;
        right: 58px;
        top: 50%;
        transform: translateY(-50%);
        padding: 0px 12px;
        font-size: 11px;
        border: 1px solid #cfcfcf;
        border-radius: 6px;
        background: #dbdbdb;
        color: #333;
        cursor: pointer;
        margin-right: 6px;
    }
}

@media (min-width: 768px) {
    #af-sidebar .af-filter-group h4 {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    #af-sidebar .af-filter-group h4 .af-attr-clear-mini {
        position: static;
        margin-left: auto;
        padding: 2px 6px;
        font-size: 11px;
        border: 1px solid #cfcfcf;
        border-radius: 6px;
        background: #f2f2f2;
        color: #333;
        cursor: pointer;
    }
}

.af-attr-panel {
    position: fixed;
    inset: 0;
    height: 100dvh;
    background: #f5f5f5;
    transform: translateX(-100%);
    transition: transform 0.35s ease;
    will-change: transform;
    z-index: 400;   /* l'header di woodmart ha uno z-index di 390 */
    display: flex;
    flex-direction: column;
}

.af-attr-panel.af-open {
    transform: translateX(0);
}

body.af-panel-open #af-sidebar {
    z-index: 390;
}

body.af-panel-open .af-sidebar-overlay {
    display: none !important;
}

.af-attr-panel-header {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    background: #242424;
    z-index: 10;
    border-bottom: 1px solid #1a1a1a;
    color: #fff;
}

.af-attr-panel-header .af-attr-back {
    background: #242424;
    padding: 0;
    cursor: pointer;
    color: #fff;
    font-size: 32px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.af-attr-panel-header .af-attr-title {
    font-size: 22px;
    font-weight: 700;
    padding-left: 12px;
}

.af-attr-panel-header .af-attr-close {
    margin-left: auto;
    background: #242424;
    border: 1px solid #fff;
    border-radius: 8px;
    width: 42px;
    height: 42px;
    padding: 0;
    cursor: pointer;
    color: #fff;
    font-size: 32px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.af-attr-panel-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 16px 20px 80px;
    overflow-y: auto;
}

.af-attr-panel-footer {
    margin-top: auto;
    position: relative;
    padding: 12px 20px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    background: #f5f5f5;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    z-index: 15;
}

.af-attr-panel-footer .af-attr-save,
.af-attr-panel-footer .af-attr-clear-current {
    flex: 1 1 50%;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.af-attr-panel-footer .af-attr-clear-current {
    background: #ddd;
}

.af-attr-panel-footer .af-attr-save {
    background: #333;
    color: #fff;
}

.af-panel-loading {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
}

.af-panel-spinner {
    width: 34px;
    height: 34px;
    border: 3px solid #cfcfcf;
    border-top-color: #333;
    border-radius: 50%;
    animation: af-spin 0.7s linear infinite;
}

/* Overlay solo mobile */
.af-sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 90;
    display: none;
    opacity: 1;
}

.af-sidebar-overlay.af-visible {
    display: block;
}

/* Bottone Show Result */
@media (max-width: 767px) {
    .af-attr-panel-body {
        padding: 0px 0px 60px;
    }

    #af-sidebar .af-apply {
        flex: 1 1 50%;
        margin: 0;
        width: auto;
        padding: 10px 14px;
        background: #242424;
        color: white;
        border-radius: 6px;
        border: none;
        cursor: pointer;
        font-size: 15px;
        transition: background 0.25s;
    }

    #af-sidebar .af-apply-footer .af-clear-filters {
        flex: 1 1 50%;
        margin: 0;
        padding: 10px 14px;
        background: #bcbcbc;
        color: #000;
        border-radius: 6px;
        border: none;
        cursor: pointer;
        font-size: 15px;
        transition: background 0.25s;
    }

    #af-sidebar .af-apply-footer .af-clear-filters:hover {
        background: #999999;
    }

    #af-sidebar .af-apply:hover {
        background: #1a1a1a;
    }

    #af-sidebar .af-apply-footer {
        position: sticky;
        bottom: 0;
        background: #f5f5f5;
        padding: 15px 20px 15px;
        border-top: 1px solid #e0e0e0;
        z-index: 20;
        display: flex;
        gap: 10px;
    }
}

@media (min-width: 768px) {
    #af-sidebar .af-apply-footer .af-clear-filters {
        display: none;
    }
}

@media (min-width: 768px) {
    #af-sidebar .af-apply-footer {
        display: none;
    }
}


/* ==========================================================
   DESKTOP MODE (STATIC)
========================================================== */

/* ============================================
   DESKTOP RESPONSIVE SIDEBAR
============================================ */
@media (min-width: 768px) {

    #af-sidebar {
        position: relative;
        padding-right: 5px;
        margin-left: 10px;
        background: white;
        width: 100%;           
        max-width: 310px;      
        min-width: 200px;
        box-shadow: none;
        max-height: 1000px;   /* <-- come mobile */
        overflow-y: auto;    /* <-- abilita lo scroll */
    }
}




/* Nascondi elementi inutili */
@media (min-width: 768px) {
    #af-sidebar .af-close,
    .af-sidebar-overlay {
        display: none !important;
    }
}

/* Nascondi bottone "Filters" */
@media (min-width: 768px) {
    .af-filters-button-wrapper {
        display: none !important;
    }
}
