/* daCLOUD — moduli: personale, assistenza, turni, permessi, campi file, gruppi, impostazioni, previsioni
   I fogli di questa cartella si caricano in ordine (numero iniziale): l'ordine conta, i successivi
   rifiniscono i precedenti. */

/* =====================================================================
   daCLOUD — seconda passata UI / moduli HR, audit e pricing
   ===================================================================== */
:root {
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    /* 1.97.9: spazio unico fra pulsanti di uno stesso gruppo di azioni */
    --gap-actions: var(--space-2);
    /* 1.92.0 — stati: testo forte, bordo, riempimento */
    --danger-strong: #8f1e17; --danger-line: #f3ccc8;
    --amber-strong: #7d4405;  --amber-line: #f2e0c2;  --amber-fill: #d98324;
    --info-strong: #1f5570;   --info-line: #d3e6ef;
    --violet: #5b3fa0;        --violet-bg: #efeafc;   --violet-line: #ddd2f4;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    align-items: end;
}
.filter-grid.compact { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.filter-grid > .btn { align-self: end; }
.editor-lines { display: grid; gap: 8px; margin: 8px 0 12px; }
.editor-line-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 110px auto;
    gap: 8px;
    align-items: center;
    padding: 8px;
    border: 1px solid var(--line-soft);
    border-radius: var(--r-sm);
    background: var(--surface-2);
}
.editor-line-row select, .editor-line-row input { min-width: 0; }
@media (max-width: 720px) {
    .editor-line-row { grid-template-columns: 1fr 92px auto; }
}

.mini { font-size: var(--text-sm); }
.field-wide { grid-column: 1 / -1; }
.table-actions { text-align: right; } /* 1.92.0: le azioni vanno a capo invece di uscire dalla card */
.settings-check { margin-top: var(--space-4); }

fieldset.field {
    min-width: 0;
    margin: 0;
    border: 1px solid var(--line);
}
fieldset.field > legend { padding: 0 6px; color: var(--ink-2); font-size: var(--text-base); font-weight: 700; }

.choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 8px 12px;
    margin-top: 8px;
}
.choice-grid > label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 8px 8px;
    border: 1px solid var(--line-soft);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    cursor: pointer;
}
.choice-grid input { flex: none; }
.scroll-choice { max-height: 290px; overflow: auto; overscroll-behavior: contain; }
.switch-line { display: flex; align-items: center; gap: 8px; min-height: var(--control-h); font-weight: 600; }

.pricing-product-grid { display: grid; gap: 8px; max-height: 430px; overflow: auto; margin-top: 8px; padding-right: 4px; }
.pricing-product-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 130px;
    gap: 16px;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line-soft);
}
.pricing-product-row:last-child { border-bottom: 0; }
.pricing-product-row span { min-width: 0; }
.pricing-product-row strong, .pricing-product-row small { display: block; }
.pricing-product-row small { color: var(--muted); margin-top: 2px; }
.auto-price-note { display: block; margin-top: 2px; color: var(--green-700); font-weight: 550; line-height: 1.25; }
.auto-price-note s { color: var(--muted); font-weight: 450; }

.audit-table { min-width: 1040px; }
.audit-summary { min-width: 220px; max-width: 420px; }
/* 1.97.0: paginazione condivisa (prima solo .audit-pager) */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; border-top: 1px solid var(--line-soft); }
.pager .pager-page { color: var(--muted); font-size: 13px; }
.audit-detail-grid { margin-bottom: 16px; }
.audit-detail-summary { margin: 0 0 12px; padding: 12px 12px; background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--r-sm); }
.audit-meta { margin: 0; max-height: 340px; overflow: auto; padding: 12px; border-radius: var(--r-md); background: var(--ink); color: var(--green-100); font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }

.startup-briefing { display: grid; gap: 20px; }
.startup-intro { color: var(--muted); }
.startup-section { display: grid; gap: 8px; }
.startup-section h3 { font-size: var(--text-base); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); } /* 1.93.0: var(--muted) non raggiungeva 4,5:1 sullo sfondo della sezione */
.startup-card, .startup-shift { border: 1px solid var(--line); background: var(--surface-2); padding: 12px 16px; }
.startup-card.delivery { border-color: var(--amber-line); background: var(--amber-bg); }
.startup-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.startup-card > strong { display: block; font-size: var(--text-lg); }
.startup-card p { margin-top: 6px; color: var(--ink-2); white-space: pre-wrap; }
.startup-required { color: var(--amber); font-size: var(--text-xs); font-weight: 700; }
.startup-shift { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.startup-shift strong { font: 700 19px var(--font-num); color: var(--green-700); }
.startup-shift span { color: var(--muted); text-align: right; }

.pwa-update-banner {
    position: fixed;
    z-index: 10020;
    right: 18px;
    bottom: 18px;
    width: min(390px, calc(100vw - 36px));
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    border: 1px solid var(--green-200);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}
.pwa-update-banner strong, .pwa-update-banner small { display: block; }
.pwa-update-actions { display: flex; gap: 8px; }
/* 4.5.1: sulla cassa l'avviso sta a sinistra, lontano da carrello e pagamento */
.tablet-app-body .pwa-update-banner { left: 18px; right: auto; }
.pwa-update-banner small { color: var(--muted); margin-top: 2px; }

.table-wrap { scrollbar-gutter: stable; }
table th { white-space: nowrap; }
.field input, .field select, .field textarea { min-height: var(--control-h); }
textarea { resize: vertical; }

@media (max-width: 1500px) {
}
@media (max-width: 720px) {
    .pricing-product-row { grid-template-columns: 1fr 110px; }
    .choice-grid { grid-template-columns: 1fr; }
    .startup-shift { align-items: flex-start; flex-direction: column; }
    .startup-shift span { text-align: left; }
    .pwa-update-banner { left: 12px; right: 12px; bottom: 12px; width: auto; }
    .tablet-app-body .pwa-update-banner { left: 12px; right: 12px; }
}
.logout-inline { margin: 0; }
.logout-inline button { appearance: none; border: 0; background: transparent; width: 100%; text-align: left; cursor: pointer; color: inherit; font: inherit; }
.user-popover .logout-inline button { color: var(--ink-2); }

.tablet-account-menu .logout-inline button { padding: 12px 12px; }
.startup-shift span small { display: block; margin-top: 4px; color: var(--ink-2); }
.filter-grid > label { display: grid; gap: 4px; min-width: 0; color: var(--muted); font-size: var(--text-sm); font-weight: 550; } /* 1.97.9: come .field-inline */
.filter-grid > label > input, .filter-grid > label > select { width: 100%; min-width: 0; min-height: var(--control-h); }

/* ---- Bacheca assistenza ---- */
.assist-card { border: 1px solid var(--line); padding: 16px 16px; margin-bottom: 12px; }
.assist-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.assist-num { font-weight: 700; font-size: var(--text-base); }
.assist-type { font-size: var(--text-xs); font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.assist-type-tech { background: var(--info-bg); color: var(--info); }
.assist-type-admin { background: var(--violet-bg); color: var(--violet); }
.assist-status { font-size: var(--text-xs); font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-left: auto; }
.assist-status.status-open { background: var(--danger-bg); color: var(--danger); }
.assist-status.status-in_progress { background: var(--amber-bg); color: var(--amber); }
.assist-status.status-closed { background: var(--green-100); color: var(--green-700); }
.assist-subject { font-weight: 600; margin-bottom: 4px; }
.assist-meta { font-size: var(--text-sm); margin-bottom: 12px; }

/* ---- Griglia turni (stile TeamManager) ---- */

/* ---- QR presenze nel briefing operatore ---- */
.startup-qr { text-align: center; }
.startup-qr-img { display: block; justify-self: center; margin-inline: auto; } /* 1.97.7 */
.startup-qr-note { font-size: var(--text-base); color: var(--muted); margin: 8px 0 0; }
/* celle con più turni */

/* ---- QR per punto vendita (impostazioni) ---- */
.qr-store-name { font-weight: 600; min-width: 160px; }
.qr-store-preview { width: 54px; height: 54px; object-fit: contain; image-rendering: pixelated; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; padding: 4px; }

/* ==== Griglia turni stile TeamManager (v2) ==== */

/* Focus programmatico sull'area principale: nessun contorno/selezione visibile (fix Safari) */
#page:focus, #page:focus-visible { outline: none; box-shadow: none; }

/* Niente ri-animazione del contenuto ai cambi pagina (anti-sfarfallio) */
#page.no-enter > * { animation: none !important; }

/* ---- Editor whitelist/blacklist IP ---- */
.ip-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 12px 0; }
.ip-cols h4 { margin: 0 0 6px; font-size: var(--text-base); font-weight: 700; }
@media (max-width: 640px) { .ip-cols { grid-template-columns: 1fr; } }

/* ---- Dashboard: controllo dimensione widget ---- */
.dash-widget-controls { display: inline-flex; align-items: center; gap: 8px; }
.dash-widget-size { padding: 4px 6px; font-size: var(--text-sm); border-radius: var(--r-sm); border: 1px solid var(--line); background: #fff; }

/* 1.92.0 — campo file con l'aspetto del pulsante secondario (prima: pulsante nativo del browser) */
/* 1.98.1: il pulsante "Scegli file" sta centrato nella sua casella: la casella
   è alta come gli altri campi (--control-h) e il pulsante ha 4 px di margine
   uguale sopra, sotto e a sinistra (prima scendeva verso il basso). */
input[type="file"] {
    font: inherit; font-weight: 400; max-width: 100%;
    /* 1.99.0: pulsante centrato allo stesso modo in Chrome e in Safari, misurato
       sui pixel: riga alta quanto la casella, pulsante a metà riga con 1 px di
       correzione comune ai due motori (prima Safari lo metteva 1–2 px più in basso). */
    box-sizing: border-box; height: var(--control-h); min-height: var(--control-h); padding: 0 12px 0 4px;
    line-height: calc(var(--control-h) - 2px); display: block; width: 100%;
}
input[type="file"]::file-selector-button { margin: -1px 12px 1px 0; height: calc(var(--control-h) - 10px);
    vertical-align: middle; line-height: 1;
}
input[type="file"]::file-selector-button:hover { border-color: var(--green-300); color: var(--green-700); }
input[type="file"]:focus-visible { outline: none; }
input[type="file"]:focus-visible::file-selector-button { box-shadow: var(--focus); border-color: var(--green-400); }

/* Testo solo per lettori di schermo (1.93.0) */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
/* Campo con pulsante affiancato (1.93.0) */
.input-with-action { display: flex; gap: 8px; }
.input-with-action input { flex: 1; min-width: 0; }
/* Pie' delle finestre: azione distruttiva a sinistra, separata dalle conferme (1.93.0) */
.footer-start { margin-right: auto; }
/* Pulsanti di stato: quello attivo è evidenziato */
.btn-secondary[aria-pressed="true"] { border-color: var(--green-400); background: var(--green-50); color: var(--green-700); }
.assist-actions-end { display: inline-flex; gap: var(--gap-actions); margin-left: auto; }

/* 1.93.0 — etichette colorate dei gruppi HR: un componente, 8 colori (contrasto >= 6:1) */
.group-badge { display: inline-flex; align-items: center; border-radius: 999px; font-weight: 650; white-space: nowrap; }
.group-red    { background: #fdecea; color: #9b2118; }
.group-green  { background: #dcefe4; color: #0b6242; }
.group-blue   { background: #e3eef8; color: #1d4f86; }
.group-amber  { background: #fdf1dc; color: #7d4405; }
.group-violet { background: #efeafc; color: #5b3fa0; }
.group-teal   { background: #dff3f1; color: #1b5f5a; }
.group-rose   { background: #fbe8ef; color: #8e2a52; }
.group-slate  { background: #eceff1; color: #3f4b53; }
.color-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.color-choice { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer; }
.color-choice:has(input:checked) { border-color: var(--green-500); box-shadow: var(--focus); }

/* 1.93.0 — Impostazioni in gruppi ordinati (prima 14 schede impilate nella colonna destra) */
.settings-layout { display: grid; }
.settings-group { display: grid; min-width: 0; }
.settings-group-title { margin: 0; font-size: var(--text-sm); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.settings-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.settings-cards > .card { margin: 0; min-width: 0; }

/* 1.94.0 — griglia turni: persone x giorni, 7/14/31 giorni, assenze e ore (barra e legenda: 2.20.0, in fondo al file) */
.badge-compact { padding: 1px 8px; font-size: var(--text-xs); }
.staff-grid { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
.staff-grid th, .staff-grid td { border-bottom: 1px solid var(--line-soft); border-right: 1px solid var(--line-soft); vertical-align: top; padding: 0; background: var(--surface); }
.staff-grid thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); }
.staff-grid .staff-person { position: sticky; left: 0; z-index: 1; max-width: 220px; padding: 8px 12px; text-align: left; font-weight: 600; }
.staff-grid thead .staff-person, .staff-grid thead .staff-total { z-index: 3; } /* angoli fissi sopra le intestazioni che scorrono */
.staff-grid .staff-total { position: sticky; right: 0; z-index: 1; min-width: 110px; padding: 8px 12px; display: table-cell; font-size: var(--text-sm); }
.staff-grid .staff-total > * { display: block; }
.staff-grid .staff-total .is-neg { color: var(--danger); }
.staff-grid .staff-total .is-pos { color: var(--green-700); }
.staff-person { white-space: nowrap; }
.staff-avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; margin-right: 8px; border-radius: 50%; background: var(--green-100); color: var(--green-700); font-size: var(--text-xs); font-weight: 700; vertical-align: middle; }
.staff-name { vertical-align: middle; }
.staff-day { padding: 6px 4px; text-align: center; font-weight: 600; }
.staff-day > span { display: block; font-size: var(--text-xs); color: var(--muted); text-transform: capitalize; }
.staff-day > strong { display: block; font-size: var(--text-md); }
.staff-day > small { display: block; font-size: var(--text-xs); color: var(--danger); font-weight: 600; white-space: normal; line-height: 1.2; }
.staff-grid .is-weekend { background: var(--surface-2); }
.staff-grid .is-holiday { background: var(--danger-bg); }
.staff-grid .staff-day.is-holiday > span { color: var(--danger-strong); } /* 4.3.0: il grigio sul rosa delle festività scendeva sotto 4,5:1 */

.staff-grid-14 .staff-cell { min-width: 82px; }
.staff-grid-31 .staff-cell { min-width: 40px; }
.staff-grid-31 .staff-day { padding: 6px 2px; }
.staff-cell-btn { display: flex; flex-direction: column; align-items: stretch; gap: 4px; width: 100%; min-height: 56px; padding: 6px; border: 0; background: transparent; font: inherit; text-align: left; cursor: pointer; }
.staff-cell-btn:hover { background: var(--green-50); }
.staff-cell-btn:focus-visible { outline: 2px solid var(--green-600); outline-offset: -2px; }
.staff-grid-31 .staff-cell-btn { min-height: 44px; padding: 4px 2px; align-items: center; }
.shift-chip { display: inline-flex; justify-content: space-between; gap: 4px; padding: 2px 6px; background: var(--green-100); color: var(--green-700); font-size: var(--text-sm); font-weight: 650; white-space: nowrap; }
.shift-chip small { font-size: var(--text-xs); font-weight: 600; color: var(--ink-2); }
.shift-chip.is-draft { background: var(--surface); border: 1px dashed var(--green-400); }
.staff-grid-31 .shift-chip { padding: 1px 3px; font-size: var(--text-xs); }
.shift-actual { font-size: var(--text-xs); color: var(--green-700); font-weight: 600; }
.shift-actual.is-short { color: var(--amber-strong); }
.staff-grid tfoot td, .staff-grid tfoot th { background: var(--surface-2); padding: 6px; font-size: var(--text-sm); text-align: center; }
.staff-grid tfoot td span { display: block; font-size: var(--text-xs); color: var(--muted); }
.staff-group-row th { left: 0; padding: 8px 12px; background: var(--surface-2); text-align: left; font-weight: 600; }
.staff-cell-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.staff-cell-list li { display: flex; gap: 8px; }
.staff-cell-list li > .btn { margin-left: auto; }
.staff-add-tabs { margin: 12px 0; }

/* 1.95.0 — previsioni */
.forecast-method summary { padding: 16px 20px; cursor: pointer; font-weight: 650; }
.forecast-method ul { margin: 8px 0 0; padding-left: 20px; color: var(--ink-2); }
tr.is-muted td { color: var(--muted); }

/* 1.96.0 — conferma d'eliminazione nel pie' di una finestra di modifica */
.footer-confirm { display: flex; align-items: center; gap: 8px; width: 100%; justify-content: flex-end; }
.footer-confirm > span { margin-right: auto; color: var(--danger); font-weight: 600; font-size: var(--text-base); }
