/* daCLOUD — documenti, IVA, statistiche operatori, importazioni, annulli, obiettivi, animazioni
   I fogli di questa cartella si caricano in ordine (numero iniziale): l'ordine conta, i successivi
   rifiniscono i precedenti. */

/* =====================================================================
   daCLOUD 1.2.0 — documenti, IVA, statistiche operatori, import CSV
   ===================================================================== */

/* Selettore tipo documento (segmentato) */
.doctype-select { display: flex; flex-wrap: wrap; gap: 8px; }
.doctype-option {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border: 1px solid var(--line); border-radius: var(--r-md);
    background: var(--surface); color: var(--ink-2); font-size: var(--text-base); font-weight: 600;
    cursor: pointer; user-select: none; transition: background .12s, border-color .12s, color .12s;
}
.doctype-option:hover { background: var(--surface-2); }
.doctype-option.selected { background: var(--green-50); border-color: var(--green-300); color: var(--green-800); }
.doctype-option input { position: absolute; opacity: 0; width: 0; height: 0; }

/* Griglia form a due colonne (cliente / DDT) */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 6px; }
.doc-customer, .doc-ddt { margin-top: 4px; }
@media (max-width: 640px) { .form-grid-2 { grid-template-columns: 1fr; } }

/* Badge tipo documento */
.doc-badge {
    display: inline-block; border-radius: 999px; font-weight: 700; letter-spacing: .02em; white-space: nowrap;
    background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.doc-badge.doc-scontrino  { background: var(--green-50);  color: var(--green-800); border-color: var(--green-200); }
.doc-badge.doc-gestionale { background: var(--line-soft);          color: var(--ink-2);          border-color: var(--line); }
.doc-badge.doc-ricevuta   { background: var(--info-bg);   color: var(--info-strong);          border-color: var(--info-line); }
.doc-badge.doc-fattura    { background: var(--green-100); color: var(--green-900); border-color: var(--green-300); }
.doc-badge.doc-ddt        { background: var(--amber-bg);          color: var(--amber-strong);          border-color: var(--amber-line); }
.doc-badge.doc-preventivo { background: var(--violet-bg);          color: var(--violet);          border-color: var(--violet-line); }

/* Riga totale nelle tabelle */
tr.table-total td { border-top: 2px solid var(--line); background: var(--surface-2); }

/* Documento: intestazione, dati controparte, ripartizione IVA */
.doc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.doc-sub { font-size: var(--text-xs); color: var(--muted); line-height: 1.4; }
.doc-party {
    border: 1px dashed var(--line); border-radius: var(--r-sm); padding: 8px 12px; margin: 8px 0;
    font-size: var(--text-xs); line-height: 1.5; background: var(--surface-2);
}
.doc-party strong { display: block; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 2px; }
table.doc-vat { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: var(--text-xs); }
table.doc-vat th, table.doc-vat td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; }
table.doc-vat th { color: var(--muted); font-weight: 600; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .02em; }
table.doc-vat .align-right { text-align: right; }
.receipt.doc-fattura, .receipt.doc-ddt, .receipt.doc-preventivo { max-width: 460px; }

/* Anteprima import CSV */
.import-status { display: inline-block; border-radius: 999px; font-weight: 700; }
.import-status.import-create { background: var(--green-100); color: var(--green-800); }
.import-status.import-update { background: var(--info-bg);   color: var(--info-strong); }
.import-status.import-error  { background: var(--danger-bg); color: var(--danger); }

/* Opzioni di reset ambiente demo */
.reset-options { display: flex; flex-direction: column; gap: 12px; }
.reset-option {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 16px; background: var(--surface-2);
}
.reset-option div strong { display: block; font-size: var(--text-md); color: var(--ink); }
.reset-option div span { display: block; font-size: var(--text-sm); color: var(--muted); margin-top: 2px; line-height: 1.4; }
.reset-option .btn { flex: 0 0 auto; white-space: nowrap; }
@media (max-width: 560px) { .reset-option { flex-direction: column; align-items: stretch; } .reset-option .btn { width: 100%; } }

/* Stampa: documenti fiscali dimostrativi */
@media print {
    .doc-party { background: none; }
    tr.table-total td { background: none; }
    .receipt.doc-fattura, .receipt.doc-ddt, .receipt.doc-preventivo { max-width: none; }
}

/* ============================================================================
   daCLOUD 1.3.0 — annullo documenti, obiettivi e grafici operatori
   ============================================================================ */

/* Badge "Annullato" e righe/documenti annullati */
.doc-badge.doc-void { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-line); }
tr.row-voided > td { color: var(--muted); }
tr.row-voided .num, tr.row-voided strong { text-decoration: line-through; text-decoration-color: rgba(176, 38, 29, .5); }

/* Banner "DOCUMENTO ANNULLATO" sul documento */
.receipt-voided { position: relative; }
.receipt-void-banner {
    margin: -2px 0 12px; padding: 8px 12px; border-radius: var(--r-sm);
    background: var(--danger-bg); color: var(--danger);
    border: 1px dashed var(--danger);
    font-size: var(--text-sm); font-weight: 800; letter-spacing: .06em; text-align: center;
    text-transform: uppercase;
}
.receipt-voided .receipt-total,
.receipt-voided .receipt-line strong { text-decoration: line-through; text-decoration-color: rgba(176, 38, 29, .45); }

/* Grafico sovrapposto operatori */
.ops-chart { width: 100%; height: 320px; }
.ops-chart.chart-pie { height: 250px; }

/* Barre di avanzamento obiettivi */
.progress-wrap { display: flex; align-items: center; gap: 8px; }
.progress-track {
    flex: 1; border-radius: 999px; overflow: hidden; min-width: 90px;
}
.progress-fill { height: 100%; border-radius: 999px; transition: width .3s ease; } /* 1.92.0: prima var(--green-mid), inesistente: barra invisibile */

.progress-fill.low { background: var(--amber-fill); }
.progress-label { font-family: var(--font-num); font-size: var(--text-base); font-weight: 600; color: var(--ink-2); min-width: 40px; text-align: right; }

/* Campo obiettivo nella finestra "Imposta obiettivi" */
.target-input {
    padding: 8px 12px; border: 1px solid var(--line);
    font-family: var(--font-num); font-size: var(--text-md); background: var(--surface);
}
.target-input:focus { outline: none; border-color: var(--green-300); box-shadow: 0 0 0 3px var(--green-50); }

/* Il nome operatore resta a schermo ma non viene stampato (non visibile al cliente). */
@media print { .receipt-operator { display: none !important; } }

/* Intestazioni di colonna ordinabili (tabella documenti). */
.th-sort { cursor: pointer; user-select: none; white-space: nowrap; }
.th-sort:hover { color: var(--ink); }
.th-sort-active { color: var(--ink); }

/* ---- Esperienza d'uso: animazioni e transizioni ---- */
@keyframes rise-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateX(26px); } }
/* Comparsa in sequenza dei blocchi al cambio schermata */
.main-content > * { animation: rise-in .32s cubic-bezier(.22, .61, .36, 1) both; }
.main-content > *:nth-child(2) { animation-delay: .045s; }
.main-content > *:nth-child(3) { animation-delay: .09s; }
.main-content > *:nth-child(4) { animation-delay: .135s; }
.main-content > *:nth-child(5) { animation-delay: .18s; }
.main-content > *:nth-child(n+6) { animation-delay: .22s; }
/* Schede e indicatori cliccabili: sollevamento all'hover */
.card { transition: box-shadow .18s ease, transform .14s ease; }
[data-nav] { transition: transform .14s ease, box-shadow .18s ease; }
[data-nav]:hover, .turnstile-card:hover { transform: translateY(-3px); box-shadow: 0 12px 26px rgba(16, 40, 32, .14); }
/* Pulsanti: leggero sollevamento all'hover (e pressione già gestita) */
.btn:hover:not(:active):not(:disabled) { transform: translateY(-1px); }
/* Righe cliccabili e testate ordinabili */
tbody tr.clickable { transition: background-color .13s ease; }
.th-sort { transition: color .12s ease; }
/* Toast: ingresso da destra */
.toast { animation: toast-in .28s cubic-bezier(.22, .61, .36, 1); }
@media (prefers-reduced-motion: reduce) {
    .main-content > *, .card, [data-nav], .btn, .toast{ animation: none !important; transition: none !important; }
}
.th-arrow { font-size: var(--text-xs); opacity: .75; margin-left: 2px; }
