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

#af-sidebar {
    background: #f5f5f5;
    overscroll-behavior: contain;
    box-sizing: border-box;
    max-height: 1000px;      
    overflow-y: auto;       
    overflow-x: hidden;
    z-index: 300;
    position: relative;
    --af-header-offset: 64px;
}


/* 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: -100%;
        top: 0;
        bottom: auto;
        width: 100%;
        height: 100%;
        transform: none;
        transition: left 0.35s ease;
        display: flex;
        flex-direction: column;
    }

    #af-sidebar.af-open {
        left: 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-selected-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-selected-count {
        display: none;
    }
}

@media (max-width: 767px) {
    #af-sidebar .af-filter-group h4 .af-selected-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;
    background: #f5f5f5;
    transform: translateX(-100%);
    transition: transform 0.35s ease;
    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: 50;
}

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 {
    padding: 16px 20px 80px;
    overflow-y: auto;
}

.af-attr-panel-footer {
    position: sticky;
    bottom: 0;
    padding: 12px 20px;
    background: #f5f5f5;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
}

.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-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;
        width: 100%;           
        max-width: 300px;      
        min-width: 200px;
        background: #f5f5f5;
        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;
    }
}


/* ==========================================================
   SELECTED FILTERS (CHIPS)
========================================================== */

.af-selected-wrap {
    position: sticky;
    top: var(--af-header-offset, 64px);
    background: #ebebeb;
    z-index: 25;
    padding-top: 20px;
    padding-bottom: 15px;
    margin-bottom: 10px !important;
}
    

.af-selected-filters {
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: visible;
    white-space: normal;
}

.af-selected-wrap .af-clear-filters-inline {
    align-self: flex-start;
    margin-top: 12px;
    padding: 6px 12px;
    background: #464646;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}

@media (max-width: 767px) {
    .af-clear-filters-inline {
        display: none;
    }
}

.af-selected-filters::-webkit-scrollbar {
    display: none;
}

.af-selected-group {
    border-radius: 10px;
    padding: 5px 0px;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    position: relative;
    max-width: 100%;
    overflow: hidden;
}

.af-selected-group-title {
    font-size: 13px;
    font-weight: 600;
    color: #111;
    white-space: nowrap;
    min-width: 110px;
    flex-shrink: 0;
}

.af-selected-group-items {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    align-items: center;
    max-width: 100%;
    min-width: 0;
}

@media (max-width: 767px) {
    .af-selected-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .af-selected-group-title {
        /* margin-bottom: 4px; */
    }

    .af-selected-group-items {
        width: 100%;
        padding-right: 12px;
        -ms-overflow-style: none;  /* IE/Edge */
        scrollbar-width: none;     /* Firefox */
    }

    .af-selected-group-items::-webkit-scrollbar {
        display: none;
    }
}

.af-selected-group-items .af-selected-item {
    flex: 0 0 auto;
}

.af-selected-group-items .af-selected-item:last-child {
    margin-bottom: 6px !important;
}

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


    .af-selected-section .af-selected-wrap {
        position: static;
        top: auto;
        padding: 20px 0 15px;
        background: #f5f5f5;
    }

    .af-selected-section .af-selected-filters {
        padding: 0 20px;
    }

    .af-selected-filters {
        flex-wrap: wrap;
        overflow-x: visible;
        overflow-y: visible;
        white-space: normal;
    }

    .af-selected-group-items {
        flex-wrap: wrap;
        overflow: visible;
        max-width: none;
    }
}

@media (max-width: 767px) {
    #af-sidebar .af-selected-wrap .af-apply {
        margin: 0 20px 14px;
    }
}

.af-selected-item {
    display: inline-flex;
    align-items: center;
    background: #dbdbdb;
    color: #242424;
    padding: 4px 12px;
    font-size: 13px;
    border-radius: 100px;
    margin: 0 6px 6px 0;
    height: 33px;
    line-height: 1.2;
    white-space: nowrap;
}

.af-remove-selected {
    margin-left: 3px;
    cursor: pointer;
    font-size: 22px;
    font-weight: bold;
    color: #000000;
    opacity: 0.8;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.af-remove-selected:hover {
    opacity: 1;
}

#af-sidebar .af-clear-filters {
    margin-top: 8px;
    padding: 4px 12px;
    font-size: 12px;
    background: #ddd;
    border: 1px solid #ccc;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.25s;
    display: block;
}

.af-selected-wrap .af-clear-filters:hover {
    background: #202020;
    color: white;
}


/* ==========================================================
   FILTER GROUPS
========================================================== */

.af-filter-group {
    background: white;
    padding: 15px 16px;
    border-bottom: 1px solid #eee;
}

.af-filter-group:last-child {
    border-bottom: none;
}

/* Titolo sticky */
.af-filter-group h4 {
    position: sticky;
    top: 0;
    font-size: 15px;
    margin-bottom: 14px;
    z-index: 5;
    background: #ebebeb;
    padding: 5px 10px;
}

.af-filter-group-cats h4 {
    z-index: 10;
}

@media (max-width: 767px) {
    .af-filter-group h4 {
        background: transparent;
    }
}

/* Lista scrollabile */
.af-filter-scroll {
    max-height: 250px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    padding-right: 4px;
}

/* Scrollbar elegante */
.af-filter-scroll::-webkit-scrollbar {
    width: 6px;
}

.af-filter-scroll::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}


/* ==========================================================
   CHECKBOX E RADIO
========================================================== */

.af-filter {
    display: flex;
    align-items: stretch; /* label alta quanto la riga */
    font-size: 15px;
    margin-bottom: 20px;
}

#af-sidebar .af-filter label,
#af-sidebar .af-cat-label {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    min-height: 28px;
    cursor: pointer !important;
}

#af-sidebar .af-filter label *,
#af-sidebar .af-cat-label * {
    cursor: pointer !important;
}

#af-sidebar .af-filter-group .af-filter,
#af-sidebar .af-filter-group .af-filter * {
    cursor: pointer !important;
}

.af-filter .af-filter-count,
.af-cat-label .af-filter-count {
    color: #8a8a8a;
    font-size: 0.9em;
    font-weight: 400;
    margin-left: 6px;
    display: inline-block;
}



.af-filter.af-filter-disabled {
    opacity: 0.45;
    pointer-events: none;
    color: #777;
}


.af-filter input[type="checkbox"],
.af-filter input[type="radio"] {
    width: 28px;
    height: 28px;
    margin-right: 12px;
    cursor: pointer;
    flex-shrink: 0;

}


@media (min-width: 767px) {

    .af-filter {
        margin-bottom: 6px;
    }

    .af-filter input[type="checkbox"],
    .af-filter input[type="radio"] {
        width: 20px;
        height: 20px;
    }
}

.af-filter input[type="checkbox"]:checked,
.af-filter input[type="radio"]:checked {
    accent-color: #e30513;
}




/* ==========================================================
   BUTTON "FILTERS" (solo mobile)
========================================================== */

.af-filters-button-wrapper {
    margin-bottom: 20px;
}

.af-filters-button-wrapper .af-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

@media (max-width: 767px) {
    .af-filters-button-wrapper {
        text-align: left;
    }

    .af-filters-button-wrapper .af-toggle {
        width: 40%;
    }
}
.af-filters-button-wrapper .af-toggle {
    background: #333;
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.25s;
}

.af-filters-button-wrapper .af-toggle:hover {
    background: #000;
}

.af-sticky-toggle {
    position: fixed !important;
    left: 0 !important;
    top: 50vh !important;
    transform: translateY(-50%) !important;
    width: 46px;
    height: 46px;
    border: none;
    border-radius: 50%;
    background: #e30513 !important;
    color: #fff !important;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    z-index: 100 !important;
    opacity: 0;
    pointer-events: none;
}

html body .af-sticky-toggle {
    background: #e30513 !important;
    color: #fff !important;
}

html body .af-sticky-toggle i {
    font-size: 18px;
    color: #fff !important;
}

.af-sticky-toggle.af-sticky-visible {
    opacity: 1;
    pointer-events: auto;
}


/* ==========================================================
   AJAX LOADER (rotellina)
========================================================== */

/* .af-loader {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 26px;
    height: 26px;
    border: 3px solid #ddd;
    border-top-color: #333;
    border-radius: 50%;
    animation: af-spin 0.7s linear infinite;
    display: none;
    pointer-events: none;
    z-index: 90;
}
*/

/* Loader fisso sul margine destro della sidebar */
#af-inline-loader {
    position: absolute;
    width: 20px;
    height: 20px;

    border: 3px solid transparent;
    border-top-color: #333;
    border-radius: 50%;
    animation: af-spin 0.6s linear infinite;

    pointer-events: none;
    z-index: 200;
    display: none;
    will-change: transform;
}


@media (max-width: 767px) {
    #af-sidebar.af-sidebar-loading::after {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(255, 255, 255, 0.7);
        z-index: 250;
    }

    #af-sidebar.af-sidebar-loading::before {
        content: "";
        position: fixed;
        left: 50%;
        top: 50%;
        width: 28px;
        height: 28px;
        margin-left: -14px;
        margin-top: -14px;
        border: 3px solid #cfcfcf;
        border-top-color: #333;
        border-radius: 50%;
        animation: af-spin 0.7s linear infinite;
        z-index: 260;
    }
}

.af-grid-loading {
    position: relative;
    min-height: 120px;
    pointer-events: none;
    opacity: 0.65;
}

.af-grid-loader {
    display: none;
}

.af-grid-spinner {
    display: none;
}

@media (min-width: 768px) {
    .af-grid-loader {
        position: absolute;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.7);
        z-index: 9;
    }

    .af-grid-spinner {
        display: none;
    }
}


@keyframes af-spin {
    to { transform: rotate(360deg); }
} 

.af-page-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.75);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.af-page-spinner {
    display: block;
    width: 34px;
    height: 34px;
    box-sizing: border-box;
    border: 3px solid #444;
    border-top-color: #111;
    border-radius: 50%;
    animation: af-spin 0.7s linear infinite;
    pointer-events: none;
}



/* .af-loading .af-loader {
    display: block !important;
} */



/* ============================================
   CATEGORIE: PADRE VS FIGLIA
============================================ */

/* Categoria principale */
/* Categorie: gruppo padre/figli */
.af-filter.af-filter-cat {
    padding-left: 0;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.af-filter.af-filter-cat .af-cat-label {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 auto;
    min-height: 28px;
}

.af-filter-cat-children {
    display: none;
    padding-left: 18px;
    margin-bottom: 20px;
    border-top: 1px solid lightgray;
    border-bottom: 1px solid lightgray;
    padding-top: 10px;
    padding-bottom: 10px;
    overflow-x: hidden;
}

.af-filter-cat-children:last-child,
.af-filter-cat-children.is-open:last-child {
    border-bottom: none;
}

.af-filter-cat-children.is-open {
    display: block;
}

.af-filter-cat-children .af-filter.af-filter-cat {
    font-size: 13px;
}


@media (min-width: 768px) {
    .af-filter-group-cats .af-filter-scroll {
        max-height: 400px;
        overflow-y: auto;
    }

    .af-filter-scroll.af-scroll-collapsed {
        max-height: var(--af-scroll-max-height, 250px);
        overflow: hidden;
    }

    .af-filter-scroll.af-hide-disabled .af-filter-disabled {
        display: none;
    }

    .af-filter-scroll.af-scroll-expanded {
        max-height: none;
        overflow: visible;
    }

    .af-filter-group .af-show-more {
        margin: 8px 20px 0;
        background: none !important;
        border: none;
        color: #111;
        font-weight: 600;
        cursor: pointer;
        padding: 0;
        text-align: left;
    }

    .af-show-more::after {
        content: ">";
        display: inline-block;
        margin-left: 6px;
        transform: rotate(90deg);
        line-height: 1;
    }
}

.af-filter .af-cat-toggle {
    width: 35px !important;
    height: 35px !important;
    background: transparent;
    border: none;
    color: #777;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    transform: rotate(0deg);
    transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease;
    border-radius: 999px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.af-filter .af-cat-toggle:hover {
    background: transparent !important;
}

.af-filter .af-cat-toggle,
.af-filter .af-cat-toggle:hover,
.af-filter .af-cat-toggle:focus {
    border-radius: 999px !important;
}

.af-cat-toggle-bg {
    width: 35px;
    height: 35px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    transition: background-color 0.2s ease;
}

.af-filter .af-cat-toggle:hover .af-cat-toggle-bg,
.af-filter .af-cat-toggle:focus .af-cat-toggle-bg {
    background: #e6e6e6;
}

.af-cat-toggle.is-open {
    transform: rotate(90deg);
}

.af-cat-toggle-icon {
    width: 12px;
    height: 12px;
    display: block;
    opacity: 1;
    visibility: visible;
    flex: 0 0 auto;
}

.af-cat-toggle-icon path {
    stroke: #777;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}
