/* ═══════════════════════════════════════════════════════════════════
   SEARCH.CSS – Pagina ricerca cataloghi
   Palette: --c-primary #024EA2 | --c-accent #ED1C24
   Layout: sidebar sinistra (300px) + area risultati (flex:1)
   Responsive: drawer a scomparsa su tablet/mobile (<992px)
═══════════════════════════════════════════════════════════════════ */

/* ── Intestazione pagina ─────────────────────────────────────────── */
.page-hero {
    background: linear-gradient(135deg, #024EA2 0%, #013d80 100%);
    color: #fff;
    padding: 2.5rem 0 2rem;
}
.page-hero--sm { padding: 1.75rem 0 1.5rem; }
.page-hero-title { font-size: 1.8rem; font-weight: 800; margin: 0 0 .35rem; }
.page-hero-sub   { font-size: .95rem; opacity: .85; margin: 0; }

/* ── Layout principale ───────────────────────────────────────────── */
.search-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1.75rem;
    align-items: start;
    padding-bottom: 3rem;
}

/* ── Pulsante "Mostra filtri" (solo mobile) ──────────────────────── */
.filter-toggle-btn {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: #024EA2;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: .65rem 1.25rem;
    font-size: .88rem;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 1rem;
    width: 100%;
    justify-content: center;
    transition: background .2s;
}
.filter-toggle-btn:hover { background: #013d80; }

.filter-badge {
    background: #ED1C24;
    color: #fff;
    border-radius: 10px;
    font-size: .72rem;
    font-weight: 700;
    padding: 1px 7px;
    min-width: 20px;
    text-align: center;
}

/* ── SIDEBAR ─────────────────────────────────────────────────────── */
.search-sidebar {
    position: sticky;
    top: calc(var(--topbar-h, 42px) + var(--header-h, 100px) + 1rem);
    align-self: start;
}

/* ── Pannello filtri ─────────────────────────────────────────────── */
.filter-panel {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.filter-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .85rem 1rem;
    background: #024EA2;
    color: #fff;
}
.filter-panel-title {
    font-size: .95rem;
    font-weight: 700;
    margin: 0;
    color: #fff;
}

.filter-header-right {
    display: flex;
    align-items: center;
    gap: .4rem;
}

.filter-close-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,.8);
    font-size: 1.2rem;
    cursor: pointer;
    padding: .2rem .4rem;
    line-height: 1;
    transition: color .2s;
}
.filter-close-btn:hover { color: #fff; }

/* Pulsante azzera filtri (nell'header) */
.filter-reset-btn {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    background: none;
    border: 1px solid rgba(255,255,255,.55);
    border-radius: 20px;
    padding: .22rem .65rem;
    font-size: .72rem;
    font-weight: 700;
    color: rgba(255,255,255,.9);
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.filter-reset-btn:hover {
    background: rgba(255,255,255,.15);
    border-color: #fff;
    color: #fff;
}

/* ── Gruppi filtro ───────────────────────────────────────────────── */
.filter-group {
    padding: .85rem 1rem;
    border-bottom: 1px solid #e2e8f0;
}
.filter-group:last-child { border-bottom: none; }

.filter-group-label {
    display: block;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #6c757d;
    margin-bottom: .6rem;
}

.filter-group-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .6rem;
}

.filter-cat-collapseall {
    background: none;
    border: none;
    padding: 0;
    font-size: .7rem;
    font-weight: 600;
    color: #024EA2;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: .25rem;
    opacity: .75;
    transition: opacity .15s;
}
.filter-cat-collapseall:hover { opacity: 1; }

/* Campo di testo */
.filter-input-wrap {
    position: relative;
}
.filter-input {
    width: 100%;
    padding: .5rem 2rem .5rem .75rem;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-size: .85rem;
    font-family: inherit;
    color: #2d2d2d;
    transition: border-color .2s, box-shadow .2s;
    background: #f9fafb;
}
.filter-input:focus {
    outline: none;
    border-color: #024EA2;
    box-shadow: 0 0 0 3px rgba(2,78,162,.12);
    background: #fff;
}
.filter-input-icon {
    position: absolute;
    right: .7rem;
    top: 50%;
    transform: translateY(-50%);
    color: #adb5bd;
    font-size: .8rem;
    pointer-events: none;
}

/* ── Lista categorie accordion ───────────────────────────────────── */
.filter-cat-list,
.filter-cat-l2-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.filter-cat-l1-head {
    display: flex;
    align-items: center;
    gap: .25rem;
}

.filter-cat-l1-btn {
    flex: 1;
    text-align: left;
    background: none;
    border: none;
    padding: .45rem .5rem;
    font-size: .85rem;
    font-weight: 600;
    color: #2d2d2d;
    cursor: pointer;
    border-radius: 4px;
    transition: background .15s, color .15s;
    font-family: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.filter-cat-l1-btn:hover     { background: #e6f0ff; color: #024EA2; }
.filter-cat-l1-btn.is-active { background: #024EA2; color: #fff; font-weight: 700; }

/* Chevron accordion */
.filter-cat-toggle {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: .4rem .5rem;
    border-radius: 4px;
    font-size: .75rem;
    flex-shrink: 0;
    transition: background .15s, color .15s;
}
.filter-cat-toggle:hover { background: #e6f0ff; color: #024EA2; }

/* Lista L2 (sotto accordion) */
.filter-cat-l2-list {
    padding-left: .75rem;
    border-left: 2px solid #e6f0ff;
    margin: .25rem 0 .25rem .75rem;
}
.filter-cat-l2-btn {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: .35rem .5rem;
    font-size: .82rem;
    font-weight: 500;
    color: #495057;
    cursor: pointer;
    border-radius: 4px;
    transition: background .15s, color .15s;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: .3rem;
}
.filter-cat-l2-btn:hover     { background: #e6f0ff; color: #024EA2; }
.filter-cat-l2-btn.is-active { background: #024EA2; color: #fff; }
.filter-cat-l2-btn.is-active i { color: #fff; }
.filter-cat-l2-btn i { font-size: .55rem; color: #024EA2; }

/* ── Lista brand ─────────────────────────────────────────────────── */
.filter-brand-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 260px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #cdd8e8 transparent;
}
.filter-brand-list::-webkit-scrollbar       { width: 3px; }
.filter-brand-list::-webkit-scrollbar-thumb { background: #cdd8e8; border-radius: 2px; }

.filter-brand-btn {
    display: flex;
    align-items: center;
    gap: .6rem;
    width: 100%;
    background: none;
    border: none;
    padding: .4rem .5rem;
    cursor: pointer;
    border-radius: 5px;
    transition: background .15s;
    font-family: inherit;
    text-align: left;
}
.filter-brand-btn:hover     { background: #e6f0ff; }
.filter-brand-btn.is-active { background: #024EA2; }
.filter-brand-btn.is-active .filter-brand-name    { color: #fff; font-weight: 700; }
.filter-brand-btn.is-active .filter-brand-initial { background: rgba(255,255,255,.25); color: #fff; }

.filter-brand-logo {
    width: 36px;
    height: 24px;
    object-fit: contain;
    border-radius: 3px;
    background: #f4f6fb;
    padding: 2px;
    flex-shrink: 0;
    border: 1px solid #e2e8f0;
}
.filter-brand-initial {
    width: 36px;
    height: 24px;
    background: #e6f0ff;
    color: #024EA2;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: .85rem;
    flex-shrink: 0;
}
.filter-brand-name {
    font-size: .82rem;
    font-weight: 600;
    color: #2d2d2d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* ── Area risultati ──────────────────────────────────────────────── */
.search-results-area { min-width: 0; }

/* Barra stato (contatore + chips) */
.search-status-bar {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 1rem;
    padding-bottom: .75rem;
    border-bottom: 2px solid #e2e8f0;
}
.search-count {
    font-size: .88rem;
    color: #6c757d;
    margin: 0;
    white-space: nowrap;
    padding-top: .2rem;
}
.search-count strong { color: #024EA2; font-size: 1rem; }

/* Chips filtri attivi */
.search-active-filters { display: flex; flex-wrap: wrap; gap: .4rem; }

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    background: #e6f0ff;
    color: #024EA2;
    border: 1px solid #c5d8f5;
    border-radius: 20px;
    padding: .25rem .75rem;
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s;
}
.filter-chip:hover { background: #ED1C24; color: #fff; border-color: #ED1C24; }

/* Loader */
.search-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    padding: 3rem;
    color: #6c757d;
}
.search-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e6f0ff;
    border-top-color: #024EA2;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Griglia risultati ───────────────────────────────────────────── */
.search-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 1.25rem;
}

/* Stato vuoto */
.search-empty {
    text-align: center;
    padding: 3.5rem 1rem;
    color: #6c757d;
    background: #f4f6fb;
    border-radius: 8px;
}
.search-empty p { margin: 0 0 .25rem; font-weight: 600; }
.search-empty small { font-size: .82rem; }

/* ── Card catalogo ───────────────────────────────────────────────── */
.search-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow .2s, border-color .2s, transform .2s;
    box-shadow: 0 2px 10px rgba(2,78,162,.06);
}
.search-card:hover {
    box-shadow: 0 6px 24px rgba(2,78,162,.14);
    border-color: #024EA2;
    transform: translateY(-3px);
}

/* Anteprima */
.search-card-thumb {
    position: relative;
    aspect-ratio: 3/4;
    background: #f4f6fb;
    overflow: hidden;
    flex-shrink: 0;
}
.search-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .3s;
}
.search-card:hover .search-card-thumb img { transform: scale(1.04); }

.search-card-nothumb {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #024EA2;
    opacity: .25;
    font-size: 2.5rem;
}
.search-card-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #ED1C24;
    color: #fff;
    font-size: .65rem;
    font-weight: 800;
    letter-spacing: 1px;
    padding: 2px 7px;
    border-radius: 3px;
}

/* Corpo card */
.search-card-body {
    padding: .8rem;
    display: flex;
    flex-direction: column;
    gap: .3rem;
    flex: 1;
}

/* Brand */
.search-card-brand {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .72rem;
    font-weight: 700;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.search-card-brand-logo {
    width: 100%;
    height: auto;
    max-height: 36px;
    object-fit: contain;
}

/* Titolo */
.search-card-title {
    font-size: .88rem;
    font-weight: 700;
    color: #024EA2;
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Categoria */
.search-card-category {
    font-size: .73rem;
    color: #6c757d;
    margin: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .2rem;
}
.search-card-category i    { color: #024EA2; }
.search-card-sep           { opacity: .5; }

/* Dimensione */
.search-card-size {
    font-size: .7rem;
    color: #adb5bd;
    margin: 0;
}
.search-card-size i { font-size: .65rem; }

/* Azioni */
.search-card-actions {
    display: flex;
    gap: .4rem;
    margin-top: auto;
    padding-top: .5rem;
}

/* Bottoni piccoli (btn-sm sovrascrive stile globale) */
.btn-gesco.btn-sm {
    padding: 0.1rem .7rem;
    font-size: .60rem;
}

/* ══ BROWSE MODE – Brand card (sovrascrive solo ciò che differisce da .search-card) ══ */

/* La card brand è cliccabile come articolo */
.sc-brand-card,
.sc-catbrand-card { cursor: pointer; }

/* Area logo: sfondo bianco, centrato, senza aspect-ratio 3/4 */
.sc-brand-logo-wrap {
    background: #fff !important;
    aspect-ratio: 3 / 2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.1rem;
}

.sc-brand-logo-wrap img {
    width: 100% !important;
    height: auto !important;
    object-fit: contain !important;
    display: block;
    transition: transform .3s;
}

.sc-brand-card:hover .sc-brand-logo-wrap img,
.sc-catbrand-card:hover .sc-brand-logo-wrap img { transform: scale(1.06); }

/* CTA "Vedi cataloghi →" */
.sc-brand-cta {
    display: flex;
    align-items: center;
    gap: .3rem;
    font-size: .75rem;
    font-weight: 700;
    color: #ED1C24;
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-top: auto;
    padding-top: .35rem;
    transition: gap .2s;
}

.sc-brand-card:hover .sc-brand-cta,
.sc-catbrand-card:hover .sc-brand-cta { gap: .55rem; }

/* ══ BROWSE MODE – Header navigazione (indietro + label brand) ══════ */

.sc-browse-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding-bottom: .85rem;
    border-bottom: 2px solid #e2e8f0;
    flex-wrap: wrap;
}

.sc-backbtn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: none;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    color: #024EA2;
    font-size: .8rem;
    font-weight: 700;
    cursor: pointer;
    padding: .35rem .85rem;
    font-family: inherit;
    transition: background .15s, border-color .15s, color .15s;
    white-space: nowrap;
}

.sc-backbtn:hover {
    background: #e6f0ff;
    border-color: #024EA2;
}

.sc-browse-brand-label {
    font-size: .95rem;
    font-weight: 700;
    color: #2d2d2d;
}

.sc-browse-subtitle {
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #6c757d;
    margin: 0 0 1rem;
}

/* ══ BROWSE MODE – Griglia categorie brand ═══════════════════════════ */

.sc-brandcat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.sc-brandcat-card {
    display: flex;
    align-items: center;
    gap: .85rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: .75rem 1rem;
    cursor: pointer;
    transition: box-shadow .2s, border-color .2s, transform .15s;
    box-shadow: 0 2px 8px rgba(2,78,162,.05);
}

.sc-brandcat-card:hover {
    border-color: #ED1C24;
    box-shadow: 0 5px 18px rgba(2,78,162,.13);
    transform: translateY(-2px);
}

.sc-brandcat-thumb {
    width: 54px;
    height: 42px;
    border-radius: 5px;
    overflow: hidden;
    background: #f4f6fb;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sc-brandcat-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sc-brandcat-noimg {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #024EA2;
    opacity: .3;
    font-size: 1.2rem;
}

.sc-brandcat-body {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    flex: 1;
    min-width: 0;
}

.sc-brandcat-name {
    font-size: .88rem;
    font-weight: 700;
    color: #024EA2;
    display: block;
    line-height: 1.3;
}

.sc-brandcat-count {
    font-size: .75rem;
    color: #6c757d;
}

.sc-brandcat-arrow {
    color: #ED1C24;
    font-size: .8rem;
    flex-shrink: 0;
    transition: transform .2s;
}

.sc-brandcat-card:hover .sc-brandcat-arrow { transform: translateX(4px); }

/* ── RESPONSIVE ──────────────────────────────────────────────────── */

/* Tablet / mobile: sidebar come drawer */
@media (max-width: 991px) {

    /* Layout a colonna singola */
    .search-layout {
        grid-template-columns: 1fr;
    }

    /* Sidebar: drawer fisso a sinistra */
    .search-sidebar {
        position: fixed;
        top: 0;
        left: -320px;
        width: 300px;
        height: 100dvh;
        max-height: 100dvh;
        z-index: 1050;
        background: #fff;
        box-shadow: 4px 0 20px rgba(0,0,0,.18);
        transition: left .28s ease;
        overflow-y: auto;
        border-radius: 0;
    }

    /* Stato aperto del drawer */
    .search-sidebar.is-open {
        left: 0;
    }

    /* Overlay scuro quando drawer è aperto */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.45);
        z-index: 1049;
    }
    .search-sidebar.is-open ~ * .sidebar-overlay,
    .search-sidebar.is-open .sidebar-overlay {
        display: block;
    }
    body.sidebar-open .sidebar-overlay {
        display: block;
    }

    /* Non sticky su mobile */
    .search-sidebar { sticky: unset; }

    /* Griglia risultati più stretta su tablet */
    .search-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
    .sc-brandcat-grid {
        grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    }
}

@media (max-width: 575px) {
    .search-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: .75rem;
    }
    .sc-brandcat-grid {
        grid-template-columns: 1fr;
    }
    .page-hero-title { font-size: 1.4rem; }
}

@media (max-width: 380px) {
    .search-grid { grid-template-columns: 1fr; }
}
