/* =========================================================
   StudioEsagono - Taxonomy Filter Widget
   ========================================================= */

.cew-tax-filter {
    width: 100%;
    box-sizing: border-box;
}

.cew-tax-filter__title {
    margin: 0 0 16px;
}

.cew-tax-filter__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cew-tax-filter__option {
    margin: 0;
    padding: 0;
}

.cew-tax-filter__label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    line-height: 1.4;
    transition: color 0.2s ease;
}

.cew-tax-filter__input {
    flex-shrink: 0;
    margin: 0;
    cursor: pointer;
}

.cew-tax-filter__name {
    word-break: break-word;
}

.cew-tax-filter__count {
    font-size: 0.9em;
    opacity: 0.85;
}

.cew-tax-filter__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.cew-tax-filter--auto .cew-tax-filter__actions:empty {
    display: none;
}

.cew-tax-filter__button {
    display: inline-block;
    border: none;
    cursor: pointer;
    text-decoration: none;
    line-height: 1;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.cew-tax-filter__button:focus,
.cew-tax-filter__button:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.cew-tax-filter__button--reset {
    background-color: transparent;
    color: inherit;
    border: 1px solid currentColor;
}

/* =========================================================
   BOTTOM-BAR ESPANDIBILE (Tablet/Mobile) — namespace .cew-bsh
   Barra discreta appoggiata al fondo della pagina con
   icona + etichetta + chevron. Click → il body si espande
   verso l'alto sopra la barra.

   STRATEGIA:
   - Desktop: in-flow normale. La barra (.cew-bsh__head) è nascosta,
     il form si vede inline come sempre.
   - Tablet/mobile: la sheet diventa fissa al bottom; la barra
     rimane sempre visibile, il body parte da max-height:0 e si
     espande al click.
   ========================================================= */

.cew-bsh { width: 100%; }

/* Default (desktop): inline, barra ed overlay nascosti */
.cew-bsh__head    { display: none; }
.cew-bsh__overlay { display: none; }
.cew-bsh__sheet   { display: block; }
.cew-bsh__body    { display: block; }

/* === Overlay dietro al pannello (mostrato solo quando attivo + aperto) === */
.cew-bsh__overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;             /* sotto al pannello (100000) */
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    cursor: pointer;
}

/* === Stili della barra (usati solo quando attiva) === */
.cew-bsh__head {
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    width: 100%;
    background: transparent;
    border: 0;
    cursor: pointer;
    font: inherit;
    color: #8a8f99;
    text-align: left;
    line-height: 1.2;
    transition: color 0.2s ease;
}
.cew-bsh__head:hover { color: #5a6068; }
.cew-bsh__head:focus,
.cew-bsh__head:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: -4px;
}

.cew-bsh__head-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
}
.cew-bsh__head-icon svg { display: block; }

.cew-bsh__head-label {
    flex: 1 1 auto;
    word-break: break-word;
}

.cew-bsh__head-chevron {
    display: inline-block;
    width: 0.55em;
    height: 0.55em;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
    transform: rotate(-45deg);   /* freccia su (chiuso) */
    flex-shrink: 0;
    margin-left: 6px;
    margin-bottom: 2px;
    transition: transform 0.3s ease;
}
.cew-bsh[data-state="open"] .cew-bsh__head-chevron {
    transform: rotate(135deg);   /* freccia giù (aperto) */
    margin-bottom: -2px;
}

/* Etichetta nascosta quando il pannello è aperto (restano solo icona + chevron) */
.cew-bsh[data-state="open"] .cew-bsh__head-label { display: none; }

/* Disabilita TUTTE le transizioni quando ripristiniamo lo stato dopo un reload
   (evita l'animazione "chiusura → apertura" appena la pagina torna). */
.cew-bsh.cew-bsh--no-anim,
.cew-bsh.cew-bsh--no-anim *,
.cew-bsh.cew-bsh--no-anim *::before,
.cew-bsh.cew-bsh--no-anim *::after {
    transition: none !important;
    animation: none !important;
}

/* =========================================================
   AJAX — stato di caricamento
   ========================================================= */
.cew-ajax-loading {
    position: relative;
    opacity: 0.5;
    transition: opacity 0.2s ease;
    pointer-events: none;
}
.cew-ajax-loading-text {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    z-index: 100001;
    font-size: 14px;
    line-height: 1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    pointer-events: none;
}

/* === Attivazione barra fissa via media query === */
/* TABLET (≤1024px) */
@media (max-width: 1024px) {
    .cew-bsh.cew-bsh--tablet > .cew-bsh__sheet {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 100000;
        display: flex;
        flex-direction: column;
        background-color: #fff;
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
        overflow: hidden;
    }
    .cew-bsh.cew-bsh--tablet > .cew-bsh__sheet > .cew-bsh__body {
        order: 1; /* body sopra */
        max-height: 0;
        overflow: hidden;
        padding: 0 18px;
        transition: max-height 0.3s ease, padding 0.3s ease, border-color 0.3s ease;
        border-bottom: 1px solid transparent;
    }
    .cew-bsh.cew-bsh--tablet > .cew-bsh__sheet > .cew-bsh__head {
        display: flex;
        order: 2; /* head sempre in basso */
    }
    .cew-bsh.cew-bsh--tablet[data-state="open"] > .cew-bsh__sheet > .cew-bsh__body {
        max-height: calc(80vh - 60px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 18px;
        border-bottom-color: #e7e9ec;
    }
    .cew-bsh.cew-bsh--tablet > .cew-bsh__overlay { display: block; }
    .cew-bsh.cew-bsh--tablet[data-state="open"] > .cew-bsh__overlay {
        opacity: 1;
        pointer-events: auto;
    }
}

/* MOBILE (≤767px) */
@media (max-width: 767px) {
    .cew-bsh.cew-bsh--mobile > .cew-bsh__sheet {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 100000;
        display: flex;
        flex-direction: column;
        background-color: #fff;
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
        overflow: hidden;
    }
    .cew-bsh.cew-bsh--mobile > .cew-bsh__sheet > .cew-bsh__body {
        order: 1;
        max-height: 0;
        overflow: hidden;
        padding: 0 18px;
        transition: max-height 0.3s ease, padding 0.3s ease, border-color 0.3s ease;
        border-bottom: 1px solid transparent;
    }
    .cew-bsh.cew-bsh--mobile > .cew-bsh__sheet > .cew-bsh__head {
        display: flex;
        order: 2;
    }
    .cew-bsh.cew-bsh--mobile[data-state="open"] > .cew-bsh__sheet > .cew-bsh__body {
        max-height: calc(80vh - 60px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 18px;
        border-bottom-color: #e7e9ec;
    }
    .cew-bsh.cew-bsh--mobile > .cew-bsh__overlay { display: block; }
    .cew-bsh.cew-bsh--mobile[data-state="open"] > .cew-bsh__overlay {
        opacity: 1;
        pointer-events: auto;
    }
}
