/* =============================================================================
   stampa.css — Stili per le pagine di stampa isoDRIVE
   Schermo : toolbar + intestazione a 3 colonne + contenuto
   Stampa  : intestazione e footer fissi ripetuti su ogni pagina A4
   ============================================================================= */

/* ── Toolbar (solo schermo) ─────────────────────────────────────────── */
.sp-toolbar {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem 1rem;
    background: #f0f4f8;
    border-bottom: 1px solid #dee2e6;
    position: sticky;
    top: 0;
    z-index: 10;
}

.sp-btn-stampa,
.sp-btn-chiudi {
    padding: .3rem .85rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: .83rem;
    font-weight: 600;
    border: 1px solid;
}

.sp-btn-stampa { background: #1E6FC8; color: white; border-color: #1557A0; }
.sp-btn-stampa:hover { background: #1557A0; }

.sp-btn-chiudi { background: white; color: #555; border-color: #bbb; }
.sp-btn-chiudi:hover { background: #f5f5f5; }

.sp-filler { flex: 1; }
.sp-hint { font-size: .75rem; color: #888; font-style: italic; }

/* ── Intestazione a 3 colonne ────────────────────────────────────────── */
.sp-header-table {
    width: 100%;
    border-collapse: collapse;
    border: 1.5pt solid #000;
    font-family: inherit;
    font-size: 9pt;
    margin-bottom: .9rem;
    background: white;
}

.sp-header-table td {
    border: 1pt solid #000;
    padding: 5pt 7pt;
    vertical-align: middle;
}

.sp-col-logo   { width: 18%; }
.sp-col-pag    { width: 13%; }

/* Cella sinistra — logo */
.sp-header-logo-cell { text-align: center; vertical-align: middle; }
.sp-header-logo { max-height: 42pt; max-width: 100%; object-fit: contain; display: block; margin: 0 auto; }

/* Cella centrale — titolo documento */
.sp-header-titolo-cell { text-align: center; vertical-align: middle; }
.sp-header-tipo {
    font-weight: 700;
    font-size: 10.5pt;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #000;
}
.sp-header-soggetto {
    font-size: 9pt;
    font-weight: 600;
    margin-top: 2pt;
    color: #111;
}

/* Cella destra — numero pagina */
.sp-header-pag-cell {
    text-align: right;
    vertical-align: bottom;
    font-size: 8pt;
    white-space: nowrap;
    color: #111;
}

/* ── Footer (solo stampa, nascosto a schermo) ────────────────────────── */
.sp-footer-print { display: none; }

/* ── Contenuto ─────────────────────────────────────────────────────── */
.sp-content { padding: 0 1.5rem 2rem; }

/* ── Tabelle elenco ─────────────────────────────────────────────────── */
.sp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .79rem;
    margin-bottom: 1.25rem;
}

.sp-table th {
    background: #1E6FC8;
    color: white;
    padding: .3rem .5rem;
    text-align: left;
    font-weight: 600;
    font-size: .73rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    border: 1px solid #1557A0;
}

.sp-table td {
    padding: .28rem .5rem;
    border: 1px solid #dee2e6;
    vertical-align: top;
}

.sp-table tbody tr:nth-child(even) td { background: #f8f9fa; }

/* ── Scheda (campi singoli) ─────────────────────────────────────────── */
.sp-campo { margin-bottom: .45rem; }

.sp-label {
    font-size: .68rem;
    font-weight: 700;
    color: #666;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: .05rem;
}

.sp-valore { font-size: .85rem; color: #212529; white-space: pre-wrap; }
.sp-valore--vuoto { color: #aaa; font-style: italic; }

.sp-sezione {
    margin: .9rem 0 .45rem;
    padding: .25rem .5rem;
    background: #e8f0fa;
    font-weight: 700;
    color: #1E6FC8;
    font-size: .82rem;
    border-left: 3px solid #1E6FC8;
}

.sp-riga { display: flex; gap: 1.5rem; flex-wrap: wrap; margin-bottom: .35rem; }
.sp-riga .sp-campo { flex: 1; min-width: 11rem; }

/* ── Badge stato ────────────────────────────────────────────────────── */
.sp-badge {
    display: inline-block;
    font-size: .7rem;
    font-weight: 700;
    padding: .1rem .42rem;
    border-radius: 10px;
}

.sp-badge--verde  { background: #d4edda; color: #0a3622; }
.sp-badge--giallo { background: #fff3cd; color: #664d03; }
.sp-badge--rosso  { background: #f8d7da; color: #58151c; }
.sp-badge--blu    { background: #cfe2ff; color: #052c65; }
.sp-badge--grigio { background: #e9ecef; color: #495057; }

/* ── Firma box ─────────────────────────────────────────────────────── */
.sp-firme-row { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .3rem; }

.sp-firma {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: .28rem .5rem;
    font-size: .76rem;
    min-width: 8rem;
    flex: 1;
}

.sp-firma--ok { border-color: #198754; background: #f0fff4; }
.sp-firma-ruolo { font-weight: 700; font-size: .68rem; color: #555; text-transform: uppercase; margin-bottom: .05rem; }

/* ── Riepilogo ──────────────────────────────────────────────────────── */
.sp-riepilogo {
    margin-top: 1.25rem;
    padding: .65rem 1rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: .8rem;
}

.sp-riepilogo dt { font-weight: 600; display: inline; }
.sp-riepilogo dd { display: inline; margin: 0 1rem 0 .3rem; }

/* ── Loader ─────────────────────────────────────────────────────────── */
.sp-loader { padding: 2rem 1.5rem; color: #666; }

/* ── Hub stampe ─────────────────────────────────────────────────────── */
.sph-modulo {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.sph-modulo-titolo {
    background: #1E6FC8;
    color: white;
    padding: .4rem .85rem;
    font-weight: 600;
    font-size: .88rem;
}

.sph-azioni {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    padding: .6rem .85rem;
}

.sph-btn {
    display: inline-block;
    padding: .3rem .75rem;
    border: 1px solid #1E6FC8;
    border-radius: 4px;
    color: #1E6FC8;
    font-size: .82rem;
    text-decoration: none;
    cursor: pointer;
    background: white;
    font-weight: 500;
}

.sph-btn:hover { background: #e8f0fa; text-decoration: none; }

/* ═══════════════════════════════════════════════════════════════════════
   @MEDIA PRINT — Layout A4 con intestazione e footer fissi
   ═══════════════════════════════════════════════════════════════════════ */
@media print {

    /* Margini pagina A4 */
    @page { margin: 1.8cm 1.5cm; }

    /* Nasconde toolbar e hint schermo */
    .sp-toolbar { display: none !important; }

    /* ── Intestazione fissa: si ripete su ogni pagina ─── */
    .sp-header-table {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        margin-bottom: 0;
    }

    /* Numero pagina corrente via CSS counter (Chrome/Edge) */
    .sp-pag-numero::after {
        content: counter(page);
    }

    /* ── Footer fisso: si ripete su ogni pagina ──────── */
    .sp-footer-print {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        justify-content: space-between;
        gap: 1rem;
        font-size: 7pt;
        font-style: italic;
        color: #333;
        border-top: 0.5pt solid #aaa;
        padding-top: 2pt;
        background: white;
    }

    /* Spaziatura contenuto per non sovrapporsi a header/footer fissi */
    .sp-content {
        padding-top: 3cm;
        padding-bottom: 1cm;
    }

    /* Colori forzati (Chrome blocca i background di default in stampa) */
    .sp-table th,
    .sp-sezione,
    .sp-badge,
    .sp-firma--ok  { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

    /* Evita interruzioni dentro una riga */
    .sp-table tr { page-break-inside: avoid; }

    /* Ripete intestazione tabella su ogni pagina (sp-table thead) */
    .sp-table thead { display: table-header-group; }

    /* Niente hover in stampa */
    .sp-table tbody tr:hover td { background: inherit; }
}
