/* ============================================================
   SNF - Filtro Taglia e Colore
   ============================================================ */

:root {
    --snf-black:    #1a1a1a;
    --snf-white:    #ffffff;
    --snf-grey:     #f7f7f7;
    --snf-border:   #e8e8e8;
    --snf-muted:    #999;
    --snf-radius:   2px;
    --snf-speed:    .25s;
    --snf-drawer-w: 100vw;
}

/* ============================================================
   DESKTOP — barra filtri stile minimal (Ordina | Filtra | count)
   ============================================================ */

/* Base: filter-wrap e filter-group sempre inline */
#snf-filter-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.snf-filter-group {
    position: relative;
    display: inline-block;
}

/* Desktop: filtri e ordina sulla stessa riga, allineati */
@media (min-width: 992px) {
    #js-product-list-top.products-selection {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 8px;
    }
    #js-product-list-top .products-sort-order {
        margin-left: auto;
    }
}



.snf-filter-group { position: relative; display: inline-block; }

.snf-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--snf-border);
    background: var(--snf-white);
    cursor: pointer;
    font-size: 11px;
    font-family: inherit;
    color: var(--snf-black);
    border-radius: var(--snf-radius);
    transition: border-color var(--snf-speed);
    white-space: nowrap;
    letter-spacing: .8px;
    text-transform: uppercase;
    font-weight: 700;
}
.snf-toggle-btn:hover,
.snf-filter-group.is-open .snf-toggle-btn { border-color: var(--snf-black); background: var(--snf-grey); }

.snf-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 17px; height: 17px; padding: 0 5px;
    background: var(--snf-black); color: var(--snf-white);
    border-radius: 999px; font-size: 10px; font-weight: 800;
    cursor: pointer;
    transition: background .15s;
}
.snf-badge:hover { background: #c00; }
.snf-arrow { font-size: 9px; transition: transform var(--snf-speed); color: var(--snf-muted); margin-left: 2px; }
.snf-filter-group.is-open .snf-arrow { transform: rotate(180deg); }

.snf-dropdown {
    display: none !important;
    position: absolute; top: calc(100% + 6px); left: 0;
    min-width: 200px; max-width: 280px;
    background: var(--snf-white);
    border: 1px solid var(--snf-border);
    border-radius: var(--snf-radius);
    box-shadow: 0 8px 32px rgba(0,0,0,.10);
    z-index: 9990;
    flex-direction: column;
    animation: snf-fade-in .15s ease;
}
.snf-filter-group.is-open .snf-dropdown { display: flex !important; }

@keyframes snf-fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.snf-options-list { max-height: 280px; overflow-y: auto; padding: 6px 0; }
.snf-options-list::-webkit-scrollbar { width: 4px; }
.snf-options-list::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

.snf-option {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 16px; cursor: pointer;
    transition: background .12s; user-select: none;
}
.snf-option:hover { background: var(--snf-grey); }
.snf-option input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }

.snf-check {
    display: inline-flex; align-items: center; justify-content: center;
    width: 16px; height: 16px; border: 1.5px solid #ccc;
    border-radius: 2px; flex-shrink: 0; transition: border-color .12s, background .12s;
}
.snf-option input:checked ~ .snf-check,
.snf-option.is-selected .snf-check { background: var(--snf-black); border-color: var(--snf-black); }
.snf-option input:checked ~ .snf-check::after,
.snf-option.is-selected .snf-check::after {
    content: ''; display: block;
    width: 4px; height: 8px;
    border: 1.5px solid #fff; border-top: none; border-left: none;
    transform: rotate(45deg) translateY(-1px);
}

.snf-color-swatch {
    display: inline-block; width: 18px; height: 18px;
    border-radius: 50%; border: 2px solid var(--snf-border);
    flex-shrink: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.snf-option.is-selected .snf-color-swatch { border-color: var(--snf-black); box-shadow: 0 0 0 2px var(--snf-black); }

.snf-option-name { font-size: 13px; color: var(--snf-black); line-height: 1.3; }
.snf-option.is-selected .snf-option-name { font-weight: 700; }

.snf-dropdown-footer { border-top: 1px solid var(--snf-border); padding: 8px 16px; }
.snf-clear-group {
    background: none; border: none; padding: 0;
    font-size: 11px; color: var(--snf-muted); cursor: pointer;
    text-transform: uppercase; letter-spacing: .5px;
    font-family: inherit; font-weight: 600;
}
.snf-clear-group:hover { color: var(--snf-black); }

#snf-reset-all {
    display: inline-flex; align-items: center; gap: 5px;
    background: none; border: 1px solid #e0aaaa; color: #c00;
    padding: 7px 13px; font-size: 11px; font-family: inherit;
    font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
    cursor: pointer; border-radius: var(--snf-radius); transition: background var(--snf-speed), color var(--snf-speed);
}
#snf-reset-all:hover { background: #c00; color: #fff; border-color: #c00; }

#snf-loading { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; color: var(--snf-muted); }
.snf-spinner {
    display: inline-block; width: 14px; height: 14px;
    border: 2px solid var(--snf-border); border-top-color: var(--snf-black);
    border-radius: 50%; animation: snf-spin .6s linear infinite;
}
@keyframes snf-spin { to { transform: rotate(360deg); } }
#js-product-list.snf-is-loading { opacity: .45; pointer-events: none; transition: opacity .3s; }
.snf-no-results { width: 100%; padding: 48px 20px; text-align: center; font-size: 14px; color: var(--snf-muted); }
.snf-option.snf-unavailable { opacity: .3; cursor: not-allowed; }
.snf-option.snf-unavailable .snf-option-name { text-decoration: line-through; }
.snf-option.snf-unavailable input { pointer-events: none; }

.snf-count { color: var(--snf-muted); font-weight: 400; font-size: .9em; }

/* ============================================================
   TEMA — div FILTRA
   ============================================================ */
#snf-open-drawer { display: none !important; }

.custom-order .col-xs-6.custom-jsbtn-search,
.custom-order .custom-jsbtn-search {
    cursor: pointer;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px;
    color: #fff !important;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    transition: opacity .2s;
    user-select: none;
    padding: 14px 0 !important;
    box-sizing: border-box;
}
.custom-jsbtn-search::before {
    content: '';
    display: inline-block; width: 14px; height: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 15' fill='none'%3E%3Cpath d='M1 3h13M3 7.5h9M5 12h5' stroke='white' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-size: contain; background-repeat: no-repeat; background-position: center;
}
.snf-theme-trigger-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 17px; height: 17px; padding: 0 4px;
    background: #fff; color: #1a1a1a;
    border-radius: 999px; font-size: 10px; font-weight: 800;
}



/* ============================================================
   DRAWER — nascosto di default su tutti i device
   ============================================================ */
/* Drawer nascosto fuori schermo — usa transform, non display */
#snf-drawer  { 
    position: fixed;
    transform: translateX(100%);
    top: 0; right: 0;
    width: 100vw; max-width: 480px; height: 100%;
    background: #fff;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform .32s cubic-bezier(.4,0,.2,1);
    box-shadow: -4px 0 32px rgba(0,0,0,.12);
    pointer-events: none;
}
#snf-drawer.is-open {
    transform: translateX(0);
    pointer-events: auto;
}
#snf-overlay { 
    display: none !important; 
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 10000;
}
#snf-overlay.is-open { display: block !important; }

/* ============================================================
   MOBILE
   ============================================================ */
@media (max-width: 991px) {

    #snf-filter-wrap { display: none !important; }

    /* Affianca ORDINA | FILTRA */
    .custom-order {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        width: 100%;
    }
    .custom-order .col-xs-6 {
        flex: 1 1 50% !important;
        max-width: 50% !important;
        float: none !important;
    }

    /* Overlay: già definito globalmente */
    @keyframes snf-overlay-in { from { opacity:0; } to { opacity:1; } }

    /* ---- Drawer contenitore ---- */
    /* Drawer: già definito globalmente con transform */

    /* ---- Header ---- */
    .snf-drawer-header {
        display: flex; align-items: center; justify-content: space-between;
        padding: 0 20px;
        height: 56px;
        border-bottom: 1px solid var(--snf-border);
        flex-shrink: 0;
        position: relative;
    }
    .snf-drawer-back {
        background: none; border: none; cursor: pointer;
        padding: 8px; margin-left: -8px;
        display: none; align-items: center; justify-content: center;
        color: var(--snf-black);
    }
    .snf-drawer-back.visible { display: flex; }
    .snf-drawer-title {
        position: absolute; left: 50%; transform: translateX(-50%);
        font-size: 13px; font-weight: 800;
        letter-spacing: 2px; text-transform: uppercase;
        color: var(--snf-black); white-space: nowrap;
    }
    .snf-drawer-close {
        background: none; border: none; cursor: pointer;
        padding: 8px; margin-right: -8px;
        display: flex; align-items: center; color: var(--snf-black);
    }

    /* ---- Pannelli (slider) ---- */
    .snf-drawer-panels {
        flex: 1; overflow: hidden;
        position: relative;
    }
    .snf-panel {
        position: absolute; top: 0; left: 0;
        width: 100%; height: 100%;
        overflow-y: auto;
        transition: transform .3s cubic-bezier(.4,0,.2,1);
        background: var(--snf-white);
    }
    .snf-panel::-webkit-scrollbar { width: 4px; }
    .snf-panel::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

    /* Pannello principale: visibile */
    #snf-panel-main { transform: translateX(0); z-index: 1; }
    /* Pannello sub: fuori schermo a destra */
    #snf-panel-sub  { transform: translateX(100%); z-index: 2; }
    /* Quando sub è aperto, main scivola a sinistra */
    #snf-drawer.sub-open #snf-panel-main { transform: translateX(-30%); }
    #snf-drawer.sub-open #snf-panel-sub  { transform: translateX(0); }

    /* ---- Righe nel pannello principale ---- */
    .snf-drawer-row {
        display: flex; align-items: center; justify-content: space-between;
        padding: 18px 20px;
        border-bottom: 1px solid var(--snf-border);
        cursor: pointer;
        transition: background .12s;
    }
    .snf-drawer-row:hover { background: var(--snf-grey); }
    .snf-drawer-row-left {
        display: flex; align-items: center; gap: 10px;
        font-size: 14px; color: var(--snf-black); font-weight: 500;
    }
    .snf-drawer-row-right {
        display: flex; align-items: center; gap: 8px;
        color: var(--snf-muted); font-size: 13px;
    }
    .snf-drawer-row-badge {
        display: inline-flex; align-items: center; justify-content: center;
        min-width: 20px; height: 20px; padding: 0 5px;
        background: var(--snf-black); color: #fff;
        border-radius: 999px; font-size: 11px; font-weight: 800;
    }
    .snf-drawer-chevron { font-size: 11px; color: #bbb; }

    /* ---- Opzioni nel pannello sub ---- */
    #snf-panel-sub .snf-option {
        padding: 14px 20px;
        border-bottom: 1px solid var(--snf-border);
    }
    #snf-panel-sub .snf-option:last-child { border-bottom: none; }
    #snf-panel-sub .snf-option-name { font-size: 15px; }
    #snf-panel-sub .snf-color-swatch { width: 24px; height: 24px; }

    /* ---- Footer ---- */
    .snf-drawer-footer {
        display: flex; gap: 0;
        border-top: 1px solid var(--snf-border);
        flex-shrink: 0; height: 60px;
    }
    .snf-footer-btn {
        flex: 1; border: none; cursor: pointer;
        font-size: 11px; font-family: inherit;
        font-weight: 800; letter-spacing: 1.5px;
        text-transform: uppercase; transition: opacity .2s;
        display: flex; align-items: center; justify-content: center; gap: 6px;
    }
    .snf-footer-btn:hover { opacity: .8; }
    .snf-footer-reset {
        background: var(--snf-white); color: var(--snf-black);
        border-right: 1px solid var(--snf-border);
    }
    .snf-footer-apply {
        background: var(--snf-black); color: var(--snf-white);
    }
    .snf-footer-reset-sub {
        background: var(--snf-white); color: var(--snf-black);
        border-right: 1px solid var(--snf-border);
    }
}