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

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

.af-filter-group:first-child {
    padding-top: 9px;
}

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

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

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

@media (max-width: 767px) {
    .af-filter-group {
        padding: 15px 20px;
    }

    .af-filter-group:first-child {
        padding-top: 20px;
    }

    .af-filter-group h4 {
        background: transparent;
    }

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

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

.af-cat-search-wrap {
    position: static;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 2px 10px 0;
    /* background: #fff; */
}

#af-sidebar input[type="search"].af-cat-search-input,
.af-attr-panel input[type="search"].af-cat-search-input {
    width: 100%;
    height: 32px;
    border: 1px solid #d9d9d9;
    /* border-radius: 8px; */
    padding: 0 34px 0 12px;
    font-size: 14px;
}

.af-cat-search-input:focus {
    outline: none;
    border-color: #bdbdbd;
}

.af-cat-search-input::placeholder {
    color: #9d9d9d;
    opacity: 1;
}

#af-sidebar .af-filter-group .af-cat-search-wrap .af-cat-search-clear,
.af-attr-panel .af-filter-group .af-cat-search-wrap .af-cat-search-clear {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    color: #666;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
}

#af-sidebar .af-filter-group .af-cat-search-wrap .af-cat-search-clear.is-visible,
.af-attr-panel .af-filter-group .af-cat-search-wrap .af-cat-search-clear.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.af-cat-search-empty {
    font-size: 13px;
    color: #666;
    margin-bottom: 12px;
}

.af-cat-search-results {
    margin: 0 0 12px;
    border: 1px solid #d2d2d2;
    border-radius: 8px;
    padding: 8px;
}

.af-cat-search-results-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#af-sidebar .af-cat-search-result-row,
.af-attr-panel .af-cat-search-result-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
}

#af-sidebar .af-cat-search-result-row:hover,
.af-attr-panel .af-cat-search-result-row:hover {
    background: #f3f3f3;
}

.af-cat-search-result-row input[type="checkbox"] {
    width: 28px;
    height: 28px;
    margin-right: 12px;
    margin-left: 0;
    flex-shrink: 0;
    cursor: pointer;
}

@media (min-width: 767px) {
    .af-cat-search-result-row input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }
}

.af-cat-search-result-row input[type="checkbox"]:checked {
    accent-color: #e30513;
}

.af-cat-search-result-name {
    flex: 1 1 auto;
}

.af-cat-search-result-name mark {
    background: #e30513;
    color: #fff;
    padding: 3px 6px;
}

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

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

.af-filter-scroll {
    scrollbar-width: thin;
}

#af-sidebar::-webkit-scrollbar {
    width: 4px;
}

#af-sidebar::-webkit-scrollbar-thumb {
    background: #e3e3e3;
    border-radius: 3px;
}



/* ==========================================================
   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;
    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: 0px;
}

.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: 100%;
    }
}
.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: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.af-filter.af-filter-cat .af-cat-label {
    display: flex;
    align-items: center;
    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: 14px;
    font-weight: 600;
}


@media (min-width: 768px) {
    .af-filter-group:not(.af-filter-group-cats) .af-filter-scroll {
        max-height: 250px;
        overflow: hidden;
    }

    .af-filter-group-cats .af-filter-scroll {
        max-height: 400px;
        overflow-y: auto;
        overflow-x: hidden;
        touch-action: pan-y;
        -webkit-overflow-scrolling: touch;
    }

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

    .af-filter-group:not(.af-filter-group-cats) .af-filter-scroll.af-hide-disabled .af-filter-disabled {
        display: none;
    }

    .af-filter-group:not(.af-filter-group-cats) .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;
}
