/* =====================================================
   ATLAS - RINNOVO GRAFICO SCHERMATE v1.0
   Da caricare DOPO responsive-patch.css (per ultimo).

   OBIETTIVO
   Portare tutte le schermate allo stesso ordine visivo della
   sezione Bilancio, senza riscrivere l'HTML di ognuna: agisce
   sulle classi già usate ovunque (.page-header, .stat-card,
   .toolbar, .table-responsive, .data-table, .card).

   PERCHE' COSI'
   Un intervento sui fogli di stile vale per tutte le schermate
   in una volta, è reversibile (basta togliere questa riga da
   index.html) e non rischia di rompere il markup esistente.
   ===================================================== */

:root {
    /* Scala di grigi coerente per bordi e testi secondari */
    --atlas-bordo: #e5e7eb;
    --atlas-bordo-forte: #d1d5db;
    --atlas-testo-tenue: #6b7280;
    --atlas-sfondo-tenue: #f9fafb;
    --atlas-blu: #1e3a8a;
    --atlas-raggio: 12px;
    --atlas-ombra: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --atlas-ombra-alta: 0 4px 12px rgba(0,0,0,.08);
}

/* -----------------------------------------------------
   1. INTESTAZIONE DI PAGINA
   Titolo e pulsanti allineati, con una linea di chiusura
   che separa l'intestazione dal contenuto.
   ----------------------------------------------------- */
.page-header {
    flex-wrap: wrap;
    gap: 12px;
    padding-bottom: 16px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--atlas-bordo);
}

.page-header h2 {
    font-size: 22px;
    letter-spacing: -0.2px;
    color: var(--atlas-blu);
    margin: 0;
}

.page-header h2 i {
    color: #3b82f6;
    font-size: 19px;
}

/* Gruppo pulsanti a destra: spaziatura uniforme */
.page-header > div,
.header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* -----------------------------------------------------
   2. RIQUADRI STATISTICHE
   Stessa impronta dei riquadri del Bilancio: bordo sottile,
   barra colorata a sinistra, numeri in evidenza.
   ----------------------------------------------------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--atlas-bordo);
    border-radius: var(--atlas-raggio);
    box-shadow: var(--atlas-ombra);
    padding: 16px 18px;
    transition: box-shadow .18s ease, transform .18s ease;
}

.stat-card:hover {
    box-shadow: var(--atlas-ombra-alta);
    transform: translateY(-1px);
}

/* Icona più discreta: quadrata, tinta tenue invece che piena */
.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    font-size: 17px;
    flex-shrink: 0;
}

.stat-value {
    font-size: 25px;
    font-weight: 700;
    line-height: 1.15;
    color: #111827;
}

.stat-label {
    font-size: 11.5px;
    color: var(--atlas-testo-tenue);
    text-transform: uppercase;
    letter-spacing: .4px;
    font-weight: 600;
    margin-top: 2px;
}

/* -----------------------------------------------------
   3. BARRA FILTRI
   Diventa una fascia con bordo, come i riquadri: si distingue
   dal contenuto senza pesare.
   ----------------------------------------------------- */
.toolbar {
    background: #fff;
    border: 1px solid var(--atlas-bordo);
    border-radius: var(--atlas-raggio);
    padding: 12px 14px;
    box-shadow: var(--atlas-ombra);
    align-items: center;
}

.toolbar .form-control,
.toolbar select,
.toolbar input {
    height: 38px;
    font-size: 13px;
}

.filter-group label {
    font-size: 12px !important;
    font-weight: 600;
    color: var(--atlas-testo-tenue);
    text-transform: uppercase;
    letter-spacing: .3px;
}

/* -----------------------------------------------------
   4. TABELLE
   Intestazione più leggera, righe alternate, bordi sottili:
   la stessa resa della tabella movimenti del Bilancio.
   ----------------------------------------------------- */
.table-responsive,
.table-container,
.table-wrapper {
    background: #fff;
    border: 1px solid var(--atlas-bordo);
    border-radius: var(--atlas-raggio);
    box-shadow: var(--atlas-ombra);
    overflow: hidden;
}

/* Se la tabella scorre lateralmente il bordo resta pulito */
.table-responsive { overflow-x: auto; }

.data-table thead {
    background: var(--atlas-sfondo-tenue);
}

.data-table th {
    padding: 12px 14px;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--atlas-testo-tenue);
    text-transform: uppercase;
    letter-spacing: .4px;
    border-bottom: 1px solid var(--atlas-bordo-forte);
    white-space: nowrap;
}

.data-table td {
    padding: 11px 14px;
    font-size: 13.5px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr {
    transition: background .12s ease;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

/* -----------------------------------------------------
   5. SCHEDE (card)
   Uniformate a quelle del Bilancio.
   ----------------------------------------------------- */
.card {
    background: #fff;
    border: 1px solid var(--atlas-bordo);
    border-radius: var(--atlas-raggio);
    box-shadow: var(--atlas-ombra);
    margin-bottom: 16px;
    overflow: hidden;
}

.card-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--atlas-bordo);
    background: var(--atlas-sfondo-tenue);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.card-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--atlas-blu);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header h3 i { color: #3b82f6; }

.card-body { padding: 16px; }

/* -----------------------------------------------------
   6. PULSANTI
   Altezze e raggi uniformi: è la differenza che si nota di più
   quando in una barra convivono pulsanti di stili diversi.
   ----------------------------------------------------- */
.btn {
    border-radius: 8px;
    font-weight: 600;
    font-size: 13.5px;
    padding: 9px 14px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: filter .15s ease, box-shadow .15s ease;
    border-width: 1px;
}

.btn:hover { filter: brightness(.96); }

.btn-sm {
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 7px;
}

/* Pulsanti di sola icona nelle tabelle: quadrati e allineati */
.data-table .btn-sm {
    min-width: 32px;
    justify-content: center;
}

/* -----------------------------------------------------
   7. CAMPI DI INSERIMENTO
   ----------------------------------------------------- */
.form-control {
    border: 1px solid var(--atlas-bordo-forte);
    border-radius: 8px;
    padding: 8px 11px;
    font-size: 13.5px;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.form-control:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

.form-group label {
    font-size: 12.5px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 5px;
    display: block;
}

/* -----------------------------------------------------
   8. STATO VUOTO
   Quando una tabella non ha righe, il messaggio è centrato
   e discreto invece che una riga qualsiasi.
   ----------------------------------------------------- */
.data-table tbody tr td[colspan] {
    text-align: center;
    color: #9ca3af;
    padding: 28px 14px;
    font-style: italic;
}

/* -----------------------------------------------------
   9. ETICHETTE DI STATO
   Uniforma i "pallini" colorati usati in varie schermate.
   ----------------------------------------------------- */
.badge,
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 20px;
    letter-spacing: .2px;
    white-space: nowrap;
}

/* =====================================================
   10. RINNOVO PIU' MARCATO (v2)
   Le regole sopra erano volutamente prudenti. Qui diamo
   alle schermate un'identita' visiva riconoscibile.
   ===================================================== */

/* --- Intestazione di pagina: barra colorata a sinistra --- */
.page-header h2 {
    position: relative;
    padding-left: 14px;
}
.page-header h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 26px;
    background: linear-gradient(180deg, #3b82f6, #1e3a8a);
    border-radius: 3px;
}

/* --- Riquadri statistiche: accento colorato in alto --- */
.stats-grid .stat-card {
    position: relative;
    padding-top: 20px;
    overflow: hidden;
}
.stats-grid .stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: #3b82f6;
}
/* Colori diversi per riquadro, in sequenza */
.stats-grid .stat-card:nth-child(2)::before { background: #10b981; }
.stats-grid .stat-card:nth-child(3)::before { background: #f59e0b; }
.stats-grid .stat-card:nth-child(4)::before { background: #8b5cf6; }
.stats-grid .stat-card:nth-child(5)::before { background: #ec4899; }
.stats-grid .stat-card:nth-child(6)::before { background: #06b6d4; }

/* Icona: tinta tenue invece che colore pieno, meno invadente */
.stat-card .stat-icon {
    filter: saturate(.9);
    box-shadow: 0 2px 6px rgba(0,0,0,.10);
}

/* --- Tabelle: intestazione scura, molto piu' leggibile --- */
.data-table thead {
    background: #1e3a8a;
}
.data-table th {
    color: #e0e7ff;
    border-bottom: none;
}
.data-table thead tr th:first-child { border-top-left-radius: 0; }

/* Righe alternate: lettura piu' facile su tabelle lunghe */
.data-table tbody tr:nth-child(even) {
    background: #fcfcfd;
}
.data-table tbody tr:hover {
    background: #eff6ff;
}

/* --- Barra filtri: fondo tenue e separazione netta --- */
.toolbar {
    background: linear-gradient(180deg, #ffffff, #fbfcfe);
    border-color: var(--atlas-bordo);
}

/* --- Contenitore tabella: stacco dal fondo pagina --- */
.table-responsive,
.table-container,
.table-wrapper {
    box-shadow: 0 2px 8px rgba(15,23,42,.06);
}

/* --- Pulsanti principali: leggera profondita' --- */
.btn-primary,
.btn-success,
.btn-danger {
    box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
.btn-primary:hover,
.btn-success:hover,
.btn-danger:hover {
    box-shadow: 0 3px 8px rgba(0,0,0,.16);
}

/* --- Sfondo generale leggermente piu' freddo: fa risaltare le schede --- */
.main-content {
    background: #f5f7fa;
}

/* =====================================================
   11. FINESTRE MODALI
   Tutte le 54 finestre del gestionale usano la stessa
   struttura (.modal-header / .modal-body / .modal-footer),
   quindi si uniformano da qui senza toccare l'HTML.
   ===================================================== */

/* --- Sfondo: piu' morbido, con leggera sfocatura --- */
.modal {
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

/* --- Contenitore: comparsa animata invece che apparizione secca --- */
.modal-content {
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(0,0,0,.28);
    border: 1px solid rgba(255,255,255,.6);
    animation: atlasModaleEntra .18s ease-out;
    max-height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
}

@keyframes atlasModaleEntra {
    from { opacity: 0; transform: translateY(10px) scale(.985); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Chi preferisce ridurre le animazioni non le subisce */
@media (prefers-reduced-motion: reduce) {
    .modal-content { animation: none; }
}

/* --- Intestazione --- */
.modal-header {
    padding: 16px 20px;
    border-radius: 14px 14px 0 0;
    flex-shrink: 0;
}

.modal-header h2,
.modal-header h3 {
    font-size: 17px;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 9px;
    letter-spacing: -.2px;
}

.modal-header h2 i,
.modal-header h3 i {
    opacity: .9;
    font-size: 16px;
}

/* Pulsante di chiusura: reagisce al passaggio */
.modal-close {
    transition: background .15s ease, transform .15s ease;
    flex-shrink: 0;
}
.modal-close:hover {
    background: rgba(255,255,255,.35);
    transform: rotate(90deg);
}

/* --- Corpo --- */
.modal-body {
    padding: 20px;
    flex: 1 1 auto;
    max-height: none;
}

/* Barra di scorrimento discreta dentro le finestre */
.modal-body::-webkit-scrollbar { width: 9px; }
.modal-body::-webkit-scrollbar-track { background: transparent; }
.modal-body::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 6px;
    border: 2px solid #fff;
}
.modal-body::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* --- Campi affiancati: due colonne uniformi --- */
.modal-body .form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin-bottom: 14px;
}

.modal-body .form-group {
    margin-bottom: 14px;
}

.modal-body .form-row .form-group {
    margin-bottom: 0;
}

/* Campo obbligatorio: l'asterisco si nota */
.modal-body label {
    color: #374151;
}

/* --- Piede: resta visibile anche nelle finestre lunghe --- */
.modal-footer {
    padding: 14px 20px;
    background: var(--atlas-sfondo-tenue);
    border-top: 1px solid var(--atlas-bordo);
    border-radius: 0 0 14px 14px;
    flex-shrink: 0;
}

/* --- Sezioni interne alle finestre --- */
/* Molte finestre raggruppano i campi sotto piccoli titoli:
   li rendiamo riconoscibili con una linea di separazione. */
.modal-body h4,
.modal-body h5 {
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--atlas-testo-tenue);
    font-weight: 700;
    margin: 18px 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--atlas-bordo);
}
.modal-body h4:first-child,
.modal-body h5:first-child { margin-top: 0; }

/* Tabelle dentro le finestre: piu' compatte */
.modal-body .data-table th { padding: 9px 11px; font-size: 10.5px; }
.modal-body .data-table td { padding: 8px 11px; font-size: 12.5px; }

/* --- Su telefono le finestre salgono dal basso a tutta larghezza --- */
@media (max-width: 768px) {
    .modal-content {
        max-height: 92vh;
        border-radius: 16px 16px 0 0;
        animation: atlasModaleEntraMobile .2s ease-out;
    }
    @keyframes atlasModaleEntraMobile {
        from { opacity: 0; transform: translateY(24px); }
        to   { opacity: 1; transform: translateY(0); }
    }
    .modal-header { border-radius: 16px 16px 0 0; padding: 14px 16px; }
    .modal-header h2, .modal-header h3 { font-size: 15.5px; }
    .modal-body { padding: 16px; }
    .modal-footer { border-radius: 0; padding: 12px 16px; }
}
