﻿:root {
    --bg: #F6F7FB;
    --surface: #FFFFFF;
    --border: #0B1F3A; /*#E6E8ED;*/
    --text: #1A1D24;
    --muted: #6B7280;
    --primary: #0B1F3A; /* Blu Maserati */
    --accent: #A7A9AC; /* Grigio metallico */
    --success: #157347;
    --radius: 6px;
    --shadow: 0 6px 20px rgba(20, 25, 36, 0.08);
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

h1, h2, h3, h4 {
    margin: 0 0 16px 0;
}

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
}

    /*DRAG ZONE*/
    /* Overlay leggero quando si trascina un file sopra la finestra (UX) */
    body.drag-anywhere::after {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(11,31,58,0.06);
        pointer-events: none;
        z-index: 999;
    }

/*MAIN LAYOUT*/
.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
}

.backend-working {
    margin: 0px 50px 0px 50px;
    padding: 5px 15px;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.brand-logo {
    height: 30px;
    opacity: 0.85;
}

    .brand-logo:hover {
        cursor: pointer;
    }

.nav {
    text-decoration: none;
    color: var(--text);
    margin-left: 16px;
    padding: 8px 12px;
    border-radius: 4px;
    transition: background .2s ease;
}

.nav-link {
    text-decoration: none;
    color: var(--text);
    margin-left: 16px;
    padding: 8px 12px;
    border-radius: 4px;
    transition: background .2s ease;
}

    .nav-link:hover {
        background: #f0f2f7;
    }

    .nav-link.active {
        color: var(--primary);
        background: #e9eef7;
    }

.container {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 20px 60px;
}

.app-footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    padding: 16px 20px;
    text-align: center;
}

/*HOME*/
.home-title {
    text-align: center;
}

.home-description {
    padding-top: 10px;
    text-align: center;
}

/*UPLOAD*/
.centered {
    display: flex;
    justify-content: center;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.upload-card {
    padding: 40px;
    text-align: center;
}

.drop-zone {
    border: 2px dashed var(--border);
}

    .drop-zone.hover {
        border-style: solid;
    }

.upload-content p {
    color: var(--muted);
    margin: 8px 0 16px;
}

.upload-icon {
    font-size: 28px;
    color: var(--primary);
    margin-bottom: 8px;
    margin-right: 15px;
}

.alert {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #F0F5FF;
}

    .alert.success {
        background: #E8F5EC;
        border-color: #CFE7D6;
        color: var(--success);
    }

.btn-container {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 5px;
}

/* Bottone base */
.btn {
    display: inline-block;
    padding: 10px 18px;
    font-size: 0.95rem;
    border-radius: 6px;
    border: 3px solid var(--primary);
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

    /* Hover stato attivo */
    .btn:hover:not(:disabled) {
        background: #0c2a50; /* variante leggermente più luminosa del blu Maserati */
        transform: translateY(-1px);
        box-shadow: var(--shadow);
    }

/* Variante chiara (se vuoi stile inverso) */
.btn-light {
    background: var(--surface);
    color: var(--primary);
    border: 1px solid var(--primary);
}

    .btn-light:hover:not(:disabled) {
        background: #f0f2f9;
        box-shadow: var(--shadow);
    }

/* Stato disabilitato */
.btn:disabled,
.btn.disabled {
    background: var(--border);
    border-color: var(--border);
    color: var(--muted);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
    opacity: 0.7;
}

.btn.small {
    padding: 4px 12px;
}

.clear-btn {
    margin-left: 30px;
    display: inline-block;
    font-size: 0.95rem;
    border-radius: 6px;
    border: 3px solid var(--primary);
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

/*SEARCH*/
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

    .grid-2 .full {
        grid-column: 1 / -1;
    }

.form-field label {
    display: block;
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 6px;
}

.form-field input, .form-field textarea, .form-field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #FAFBFF;
}

    .form-field input:focus, .form-field textarea:focus, .form-field select:focus {
        outline: none;
        border-color: var(--primary);
        box-shadow: 0 0 0 3px rgba(11,31,58,0.07);
    }

/* FIELD GROUP */
.field-group {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}

.field-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    /*background: #ffffff;*/
}

.field-group-title {
    margin: 0;
    font-size: 1.05rem;
    color: var(--text);
}

.field-group-subtitle {
    margin-top: 4px;
    font-size: 0.9rem;
    color: var(--muted);
}

.field-group-body {
    padding: 16px;
}

    .field-group-body.is-collapsed {
        display: none;
    }


.field-group-grid {
    display: grid;
    gap: 14px 16px;
    /* Il cuore della griglia fluida */
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

/* Campo form coerente (riusa le regole già presenti) */
.form-field label {
    display: block;
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 6px;
}

.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #FAFBFF;
    transition: border-color .15s ease, box-shadow .15s ease;
}

    .form-field input:focus,
    .form-field select:focus,
    .form-field textarea:focus {
        outline: none;
        border-color: var(--primary);
        box-shadow: 0 0 0 3px rgba(11,31,58,0.07);
    }

.one-col {
    grid-template-columns: 1fr;
}

/* Bottoni piccoli per header gruppo */
.btn-sm {
    padding: 6px 10px;
    font-size: 0.85rem;
}

.group-toggle {
    border-color: var(--border);
}

/* Wrapper di utilità per lo stato disabilitato */
.is-disabled {
    --disabled-bg: #F3F5FA;
    --disabled-border: #E1E5EC;
    --disabled-text: #98A1B3;
    position: relative;
    opacity: 0.8; /* leggero “fade” */
}

    /* Campi modulo disabilitati (input, select, textarea) */
    .is-disabled select,
    .is-disabled input,
    .is-disabled textarea,
    select:disabled,
    input:disabled,
    textarea:disabled {
        background: var(--disabled-bg);
        border-color: var(--disabled-border);
        color: var(--disabled-text);
        cursor: not-allowed;
        box-shadow: none;
    }

        /* Placeholder più tenue nei campi disabilitati */
        .is-disabled ::placeholder,
        select:disabled::placeholder,
        input:disabled::placeholder,
        textarea:disabled::placeholder {
            color: #B4BDCF;
        }

        /* Rimuove gli stili di focus sui campi disabilitati */
        .is-disabled select:focus,
        .is-disabled input:focus,
        .is-disabled textarea:focus,
        select:disabled:focus,
        input:disabled:focus,
        textarea:disabled:focus {
            outline: none;
            box-shadow: none;
            border-color: var(--disabled-border);
        }

    /* Etichetta e messaggi nel wrapper disabilitato */
    .is-disabled .form-field label,
    .is-disabled .help-text,
    .is-disabled .validation-message {
        color: var(--disabled-text);
    }


/* ========== Loading Overlay (full page) ========== */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none; /* visibile solo con .show */
}

    .loading-overlay.show {
        display: grid;
        place-items: center;
        /* velo chiaro che mantiene il look "white luxury" */
        background: rgba(255, 255, 255, 0.75);
        backdrop-filter: blur(3px);
    }

/* Contenitore del pannello centrale */
.loading-panel {
    min-width: 260px;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    text-align: center;
}

/* Logo (opzionale) */
.loading-brand {
    height: 28px;
    opacity: .9;
    margin-bottom: 8px;
}

/* Spinner elegante */

.loading-icon {
    width: 36px;
    height: 36px;
}

    .loading-icon.loading-spinner {
        border: 3px solid #e6ebf3;
        border-top-color: var(--primary);
        border-radius: 50%;
        margin: 10px auto 12px;
        animation: spin 0.8s linear infinite;
    }

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Testi */
.loading-title {
    margin: 0;
    font-size: 1rem;
    color: var(--text);
}

.loading-subtitle {
    margin: 6px 0 0;
    font-size: .9rem;
    color: var(--muted);
}

.loading-close {
    margin-top: 1rem;
}

/* Summary chip */
.filters-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.chip {
    background: #f2f5fb;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: .9rem;
}

/* ========== Griglia card ======= */
.cards-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Header card */
.config-card {
    padding: 14px;
    width: 1000px;
    margin: 14px;
}

.config-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
}

.config-title {
    margin: 0;
    font-weight: 600;
}

.config-meta {
    display: flex;
    gap: 6px;
}

/* Recap moduli */
.modules-list {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 10px;
    /* snap elegante quando scorri */
    scroll-snap-type: x mandatory;
    /* migliora lo scroll su touch */
    -webkit-overflow-scrolling: touch;
}

    /* Scrollbar coerente (WebKit) */
    .modules-list::-webkit-scrollbar {
        height: 10px;
    }

    .modules-list::-webkit-scrollbar-thumb {
        background: #d7dce7;
        border-radius: 999px;
        border: 2px solid #f6f7fb; /* stacco pulito */
    }

    .modules-list::-webkit-scrollbar-track {
        background: transparent;
    }

.module-box {
    flex: 1 0 550px; /* grow=1, shrink=0, basis=450px */
    min-width: 550px; /* esplicito (ridondante ma chiaro) */
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    padding: 10px 12px;
}

/* Se vuoi che su schermi molto larghi stiano 2-3 moduli senza scroll,
   puoi usare min-width più piccola o aggiungere breakpoint */
@media (min-width: 1400px) {
    .module-box {
        width: 380px;
    }
}

.module-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
}

.module-title {
    font-weight: 600;
}

.module-pn {
    color: var(--muted);
    font-size: .9rem;
}

/* Tabella specs in stile "definition list" */
.spec-grid {
    display: grid;
    /* auto-fit: 1 col su mobile, 2-3 su desktop in base allo spazio */
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    margin: 0;
    gap: 8px 18px;
}

    /* Ogni “riga” dt/dd diventa una mini-griglia */
    .spec-grid .spec-item {
        display: grid;
        grid-template-columns: 150px 1fr; /* label + valore */
        align-items: baseline;
        column-gap: 10px;
    }

        /* Label (dt) */
        .spec-grid .spec-item dt {
            margin: 0;
            font-size: .85rem;
            color: var(--muted);
            white-space: nowrap;
        }

        /* Valore (dd) */
        .spec-grid .spec-item dd {
            margin: 0;
            color: var(--text);
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        /* Se hai valori molto lunghi, puoi consentire wrapping su alcune voci */
        .spec-grid .spec-item.wrap dd {
            white-space: normal;
            overflow: visible;
            text-overflow: clip;
        }

/* Su schermi piccoli, riduci la colonna label */
@media (max-width: 520px) {
    .spec-grid .spec-item {
        grid-template-columns: 90px 1fr;
    }
}

/* Azioni moduli (Mostra tutti / meno) */
.modules-actions {
    margin-top: 6px;
}

.thumbnails {
    height: calc(120px + 2rem);
    overflow-y: auto;
}

    /* Scrollbar coerente (WebKit) */
    .thumbnails::-webkit-scrollbar {
        height: 10px;
    }

    .thumbnails::-webkit-scrollbar-thumb {
        background: #d7dce7;
        border-radius: 999px;
        border: 2px solid #f6f7fb; /* stacco pulito */
    }

    .thumbnails::-webkit-scrollbar-track {
        background: transparent;
    }

.thumbnails-row {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
}

.thumbnail {
    justify-self: center;
    align-self: center;
    padding: .4rem;
    display: flex;
    width: 160px;
    height: 124px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
}

    .thumbnail > img {
        width: 100%;
    }

/* Skeleton (placeholder durante Virtualize) */
.skeleton-card {
    height: 320px;
    opacity: .6;
    animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
    0%,100% {
        background: #f3f5fa
    }

    50% {
        background: #e9edf4
    }
}

/* ========= Lightbox ========= */
.lb-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(255,255,255,.85);
    backdrop-filter: blur(4px);
    display: grid;
    grid-template-columns: 64px 1fr 64px;
    align-items: center;
}

.lb-stage {
    display: grid;
    place-items: center;
    padding: 10px;
}

.lb-img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.lb-caption {
    margin-top: 6px;
    text-align: center;
    color: var(--muted);
}

.lb-close {
    position: fixed;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    cursor: pointer;
}

.lb-nav {
    font-size: 28px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    cursor: pointer;
}

    .lb-nav.prev {
        justify-self: center;
    }

    .lb-nav.next {
        justify-self: center;
    }

/* ====== Boolean Pill ====== */
.bool-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    font-size: .85rem;
    line-height: 1.2;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    white-space: nowrap;
}

/* Stato: sì / no / n.d. (null) */
.bool-yes {
    color: var(--primary);
    background: #eaf1ff;
    border-color: #cfd9ee;
}

.bool-no {
    color: #6b7280;
    background: #f7f8fa;
    border-color: #e7eaf0;
}

.bool-null {
    color: #98a1b3;
    background: #f3f5fa;
    border-color: var(--border);
}

/* Icona tonda minimal */
.bool-icon {
    width: 14px;
    height: 14px;
    display: inline-grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid currentColor;
    font-size: 11px;
    line-height: 1;
}

/* Symbol-only via CSS: ✓ ✕ – */
.bool-yes .bool-icon::before {
    content: "✓";
}

.bool-no .bool-icon::before {
    content: "×";
}

.bool-null .bool-icon::before {
    content: "–";
}

/* Variante compatta (se ti serve in spazi stretti) */
.bool-pill.compact {
    padding: 1px 6px;
    font-size: .8rem;
    gap: 4px;
}

    .bool-pill.compact .bool-icon {
        width: 12px;
        height: 12px;
        font-size: 10px;
    }


/* Search row: allinea campo + bottone sulla stessa riga */
.search-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

/* Pulsante annulla: stile danger, riusa le basi di .btn via app.css */
.btn-cancel {
    display: inline-block;
    padding: 10px 18px;
    font-size: 0.95rem;
    border-radius: 6px;
    border: 3px solid #9b1c1c;
    background: #9b1c1c;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

    .btn-cancel:hover {
        background: #7f1d1d;
        box-shadow: var(--shadow);
    }

/* Messaggio errore */
.error-text {
    margin: 0.5rem 0 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: #9b1c1c;
}

/* Centratura del pannello di caricamento globale */
.loader-wrap {
    display: flex;
    justify-content: center;
    margin: 1.5rem 0;
}

/* Sezione per configurazione */
.config-section {
    margin-bottom: 2rem;
}

/* Container scorrevole a colonna singola per Virtualize */
.image-scroll-area {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    height: 560px;
    overflow-y: auto;
    padding: 0.5rem;
}

/* Ogni item di Virtualize: riga con 2 colonne */
.image-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    height: 360px; /* altezza fissa = ItemSize(376) - margin-bottom(16) */
    margin-bottom: 1rem; /* i 16px rimanenti del ItemSize */
}

/* Card immagine */
.image-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow: hidden;
}

/* Placeholder per riga con solo 1 immagine (numero dispari) */
.image-card-placeholder {
    border-radius: var(--radius);
    background: transparent;
}

.image-title {
    margin: 0;
    flex-shrink: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.image-preview {
    flex: 1;
    min-height: 0;
    width: 100%;
    object-fit: contain;
    border-radius: var(--radius);
    background: var(--bg);
}

/* Stato vuoto */
.empty-state {
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    color: var(--muted);
    font-size: 1rem;
}
