/* daCLOUD — rifinitura generale, assistenza, caricamento, filtri compatti, campi file
   I fogli di questa cartella si caricano in ordine (numero iniziale): l'ordine conta, i successivi
   rifiniscono i precedenti. */

/* =====================================================================
   2.50.0 — rifinitura generale: leggibilità, bersagli al tocco, pagine lunghe
   ===================================================================== */

/* Niente testo sotto gli 11 px: intestazioni di tabella, pill, etichette (prima 10–10,5 px). */
:root { --text-xs: 11.5px; }
thead th { font-size: var(--text-xs); letter-spacing: .03em; }
.status-pill, .nav-section, .eyebrow, .table-subline { font-size: var(--text-xs); }
small, .hint-line, .login-foot { font-size: var(--text-sm); }

/* Salto fra le sezioni di una pagina lunga (Impostazioni): barra attaccata sotto la barra superiore. */
.section-jump { position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 5; display: flex; gap: 4px; flex-wrap: wrap; margin: -6px 0 18px; padding: 6px; border: 1px solid var(--line); border-radius: 999px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); box-shadow: var(--shadow-sm); width: fit-content; max-width: 100%; }
.section-jump a { display: inline-flex; align-items: center; min-height: 32px; padding: 0 14px; border-radius: 999px; font-size: var(--text-base); font-weight: 600; color: var(--ink-2); text-decoration: none; white-space: nowrap; transition: background .14s ease, color .14s ease; }
.section-jump a:hover { background: var(--green-50); color: var(--green-700); }
.section-jump a.active { background: var(--green-600); color: #fff; }
.section-jump a:focus-visible { outline: 2px solid var(--green-600); outline-offset: 2px; }
.settings-group, [data-jump-section] { scroll-margin-top: calc(var(--topbar-h) + 64px); } /* 4.9.3: anche le schede di Integrazioni raggiunte dalla barra di salto */
@media (max-width: 720px) {
    .section-jump { border-radius: var(--r-md); flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; width: auto; -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); }
    .section-jump::-webkit-scrollbar { display: none; }
}
/* le card affiancate delle altre pagine non si stirano alla più alta (in Impostazioni restano allineate, 1.98.2) */
.inv-lists { align-items: start; }

/* Turni: riquadro "Da sistemare" chiuso di default, con l'azione principale sulla riga del riepilogo
   (il pulsante è fuori dal <summary>, sovrapposto a destra). */
.staff-alerts-wrap { position: relative; margin-bottom: var(--space-4); }
.staff-alerts-wrap > .staff-alerts { margin-bottom: 0; }
.staff-alerts-cta { position: absolute; top: 8px; right: 44px; z-index: 2; }
.staff-alerts-wrap:has(.staff-alerts-cta) > .staff-alerts > summary { padding-right: 260px; min-height: 52px; }
@media (max-width: 720px) {
    .staff-alerts-cta { position: static; padding: 10px 12px 0; }
    .staff-alerts-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
    .staff-alerts-wrap > .staff-alerts { border: 0; box-shadow: none; }
    .staff-alerts-wrap:has(.staff-alerts-cta) > .staff-alerts > summary { padding-right: var(--space-4); }
    .staff-alerts-cta .btn { width: 100%; }
}

/* Regole turni: gli orari non vengono tagliati (prima 8.4em, insufficiente con il formato 12 h). */
.rule-time input { width: auto; min-width: 118px; font-variant-numeric: tabular-nums; }

/* Prodotti: colonna immagine stretta; senza immagine le iniziali su fondo tenue. */
.thumb-cell { width: 64px; }
.product-thumb-empty { background: var(--green-50); color: var(--green-700); display: grid; place-items: center; font-weight: 700; font-size: var(--text-md); letter-spacing: .02em; border-color: var(--green-100); }
@media (max-width: 720px) { .thumb-cell { display: none; } }

/* Tabelle sul telefono: ombre ai bordi quando c'è altro da scorrere, prima colonna che resta ferma. */
@media (max-width: 720px) {
    .table-wrap:not(.no-sticky) {
        background:
            linear-gradient(90deg, var(--surface) 30%, rgba(255, 255, 255, 0)) left / 28px 100% no-repeat local,
            linear-gradient(270deg, var(--surface) 30%, rgba(255, 255, 255, 0)) right / 28px 100% no-repeat local,
            radial-gradient(farthest-side at 0 50%, rgba(10, 43, 30, .18), transparent) left / 14px 100% no-repeat scroll,
            radial-gradient(farthest-side at 100% 50%, rgba(10, 43, 30, .18), transparent) right / 14px 100% no-repeat scroll;
    }
    .table-wrap:not(.no-sticky) table:not(.staff-grid):not(.perm-matrix) > tbody > tr > td:first-child,
    .table-wrap:not(.no-sticky) table:not(.staff-grid):not(.perm-matrix) > thead > tr > th:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--line-soft); }
    .table-wrap:not(.no-sticky) table:not(.staff-grid) > thead > tr > th:first-child { background: var(--surface-2); }
    .table-wrap tbody tr:hover td:first-child { background: var(--surface-2); }
    .perm-matrix th[scope="row"] { position: sticky; left: 0; z-index: 1; background: var(--surface); }
    td .btn-sm, td .btn-ghost { min-height: 36px; }
}

/* Bersagli di almeno 44 px dove si usa il dito (telefono e tablet), senza toccare i computer. */
@media (pointer: coarse) {
    .btn:not(.btn-sm):not(.btn-icon), .tab, .icon-btn, .modal-close, .sidebar-nav a, .fav-toggle, .tabs .tab, .pager button { min-height: 44px; }
    .btn-sm, td .btn, .row-actions .btn { min-height: 38px; }
    .icon-btn, .modal-close, .fav-toggle { min-width: 44px; }
    .tabs { -webkit-mask-image: linear-gradient(90deg, #000 90%, transparent); mask-image: linear-gradient(90deg, #000 90%, transparent); scroll-snap-type: x proximity; }
    .tabs .tab { scroll-snap-align: start; }
}

/* Finestre: l'azione distruttiva sta a sinistra; sul telefono il piè resta in vista con pulsanti compatti. */
@media (max-width: 720px) {
    .modal-foot { flex-direction: row; flex-wrap: wrap; gap: 8px; position: sticky; bottom: 0; }
    .modal-foot .btn { flex: 1 1 calc(50% - 8px); min-height: 44px; }
    .modal-foot .modal-foot-start { flex-basis: 100%; }
    .modal-foot .btn-primary { order: 9; flex-basis: 100%; }
    /* 4.4.7: con una finestra aperta gli avvisi vanno in alto: in basso coprivano i pulsanti della finestra */
    body:has(#modalRoot .modal) .toast-stack { top: calc(12px + env(safe-area-inset-top)); bottom: auto; }
}

/* Suggerimento del tasto rapido, solo con tastiera e mouse (sul tocco non serve). */
.kbd-hint { display: none; font-family: var(--font-num); font-size: 10.5px; font-weight: 600; line-height: 1; padding: 3px 5px; border-radius: 5px; border: 1px solid currentColor; opacity: .7; margin-left: 6px; vertical-align: middle; }
@media (hover: hover) and (pointer: fine) { .kbd-hint { display: inline-block; } }

/* Stati vuoti con un'azione, dove ha senso. */
.empty-state .btn { margin-top: 14px; }
.empty-state .empty-icon { font-size: 28px; line-height: 1; margin-bottom: 8px; color: var(--green-300); }
/* Turni: una casella vuota mostra "+" al passaggio del mouse (si capisce che si può creare un turno). */
.staff-cell-btn.is-empty { position: relative; }
.staff-cell-btn.is-empty:hover::after, .staff-cell-btn.is-empty:focus-visible::after { content: '+'; position: absolute; inset: 0; display: grid; place-items: center; font-size: var(--text-3xl); font-weight: 500; color: var(--green-500); }
/* Campi file: il pulsante nativo prende lo stile dei pulsanti secondari (prima "Choose File" grigio). */
input[type="file"] { font-size: var(--text-base); color: var(--muted); }
/* 2.52.1: niente padding verticale (l'altezza è fissata dalla regola 1.99.0: con 7 px sopra e sotto il pulsante
   usciva dalla casella e la scritta "Scegli file" era tagliata). */
input[type="file"]::file-selector-button { font: inherit; font-weight: 600; color: var(--green-700); background: var(--surface); border: 1px solid var(--green-300); border-radius: var(--r-sm); padding: 0 12px; box-sizing: border-box; margin-right: 10px; cursor: pointer; transition: background .14s ease; }
input[type="file"]::file-selector-button:hover { background: var(--green-50); }
.field.is-disabled > span { color: var(--muted); }
.field.is-disabled input { background: var(--surface-2); color: var(--muted); }
/* Accesso tablet: motivo dell'apertura fuori dal punto del turno */
.login-form textarea { width: 100%; min-height: 84px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; font: inherit; font-size: var(--text-md); resize: vertical; }
.login-form textarea:focus { outline: none; border-color: var(--green-500); box-shadow: var(--focus); }
#overrideForm .btn + .btn { margin-top: 8px; }
/* Area personale sui computer: griglia come nel pannello (una sola persona); sul telefono il calendario. */
.me-grid-table { display: none; }
@media (min-width: 900px) {
    .me-main { width: min(1280px, 100%); }
    .me-main .me-hello, .me-main .me-banner, .me-main .me-section:not(.me-section-wide) { width: min(720px, 100%); margin-inline: auto; }
    .me-main .me-section:has(.me-grid-table) { width: 100%; }
    .me-only-narrow { display: none; }
    .me-grid-table { display: block; }
    .me-grid-table .staff-cell-btn.is-selected { background: var(--green-50); box-shadow: inset 0 0 0 2px var(--green-400); border-radius: var(--r-sm); }
    .me-grid-table .staff-grid-7 .staff-cell { min-width: 96px; }
    .me-grid-table .staff-grid-14 .staff-cell { min-width: 58px; }
    .me-grid-table .staff-grid-31 .staff-cell { min-width: 33px; }
    .me-grid-table .staff-grid-31 .staff-person { min-width: 120px; max-width: 130px; }
    .me-grid-table .staff-grid-31 .staff-total { min-width: 80px; }
    .me-grid-table .staff-grid-31 .shift-chip { font-size: 10.5px; padding: 1px 2px; letter-spacing: -.02em; }
    .me-grid-table .staff-grid-14 .shift-chip small, .me-grid-table .staff-grid-31 .shift-chip small { display: none; }
    .me-grid-table .staff-grid .staff-person { min-width: 150px; max-width: 170px; }
}

/* =====================================================================
   2.51.0 — assistenza: filo di messaggi, priorità, foto, avvisi
   ===================================================================== */
.assist-metrics { margin-bottom: 16px; }
.assist-card { position: relative; }
.assist-card.is-unread { border-color: var(--green-400); box-shadow: inset 3px 0 0 var(--green-500); }
.assist-card.is-urgent { border-color: var(--danger-line); background: linear-gradient(90deg, var(--danger-bg) 0, var(--surface) 160px); }
.assist-card.is-closed { opacity: .78; }
.assist-card h3.assist-subject { font-size: var(--text-lg); margin: 0 0 4px; }
.assist-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--green-500); box-shadow: 0 0 0 3px var(--green-100); }
.assist-thread { list-style: none; margin: 10px 0 12px; padding: 0; display: grid; gap: 8px; }
.assist-msg-item { max-width: 46rem; padding: 10px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line-soft); }
.assist-msg-item.is-staff { background: var(--green-50); border-color: var(--green-100); margin-left: 32px; }
.assist-msg-item.is-requester { margin-right: 32px; }
.assist-msg-head { display: flex; justify-content: space-between; gap: 12px; font-size: var(--text-sm); margin-bottom: 2px; }
.assist-msg-item p { margin: 0; white-space: pre-wrap; }
.assist-photos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.assist-photos img { width: 88px; height: 88px; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); }
.assist-reply { display: grid; gap: 8px; margin-top: 4px; }
.assist-reply textarea { width: 100%; min-height: 56px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); font: inherit; font-size: var(--text-md); resize: vertical; }
.assist-reply textarea:focus { outline: none; border-color: var(--green-500); box-shadow: var(--focus); }
.assist-reply-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.assist-reply-row select { height: var(--control-h); min-width: 190px; max-width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 0 28px 0 11px; font: inherit; font-size: var(--text-md); background: var(--surface); }
.assist-reply-row select[name="assigned_to_id"] { min-width: 240px; }
.notification-push { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line-soft); font-size: var(--text-base); }
.notification-push .switch-line { margin: 0; }
.nav-badge.is-alert { background: var(--danger); color: #fff; }
.nav-badge:empty { display: none; }
@media (max-width: 720px) {
    .assist-msg-item.is-staff { margin-left: 12px; }
    .assist-msg-item.is-requester { margin-right: 12px; }
    .assist-reply-row select { flex: 1 1 45%; }
    .assist-reply-row .assist-actions-end { width: 100%; justify-content: flex-end; }
}

/* =====================================================================
   2.52.0 — rifinitura: scheletro di caricamento, filtri compatti sul telefono, paginatore in testa
   ===================================================================== */
.page-loading { display: block; padding: 8px 0 40px; }
.skeleton { display: block; border-radius: var(--r-md); background: linear-gradient(90deg, var(--line-soft) 25%, var(--surface) 50%, var(--line-soft) 75%); background-size: 200% 100%; animation: skeleton-shine 1.3s linear infinite; }
.skeleton-head { display: grid; gap: 10px; margin: 12px 0 22px; max-width: 520px; }
.skeleton-title { height: 30px; width: 46%; }
.skeleton-text { height: 14px; width: 80%; }
.skeleton-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.skeleton-card { height: 92px; }
.skeleton-block { height: 280px; }
@keyframes skeleton-shine { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
@media (max-width: 720px) { .skeleton-grid { grid-template-columns: 1fr 1fr; } .skeleton-block { height: 200px; } }

.filter-advanced { display: contents; }
.filter-more { display: none; }
@media (max-width: 720px) {
    .filter-more { display: inline-flex; order: -1; width: 100%; justify-content: center; min-height: 40px; }
    .filter-bar > .search-box, .filter-bar > .tabs { order: -2; }
    .filter-bar:not(.is-open) > .filter-advanced { display: none; }
    .filter-bar.is-open > .filter-advanced { display: grid; gap: 10px; width: 100%; }
}
.card-head .pager-compact { border-top: 0; padding: 0; margin-left: auto; gap: 6px; }
.card-head .pager-compact .btn { min-width: 34px; padding: 0 8px; }
.card-head .pager-compact + * { margin-left: 0; }
/* scheda richiudibile (Clienti › Impostazioni cliente) */
details.card-details > summary.card-head { cursor: pointer; list-style: none; }
details.card-details > summary.card-head::-webkit-details-marker { display: none; }
details.card-details > summary.card-head::after { content: '▾'; margin-left: auto; color: var(--muted); transition: transform .15s ease; }
details.card-details:not([open]) > summary.card-head::after { transform: rotate(-90deg); }
details.card-details:not([open]) > summary.card-head { border-bottom: 0; }
/* avvio operatore sul telefono: QR richiudibile */
details.startup-qr > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; }
details.startup-qr > summary::-webkit-details-marker { display: none; }
details.startup-qr > summary::after { content: '▾'; color: var(--muted); }
details.startup-qr:not([open]) > summary::after { transform: rotate(-90deg); }
details.startup-qr > summary h3 { margin: 0; }
/* Regole turni: barra "Salva" opaca e spazio in fondo, così non copre l'ultima riga */
.rules-savebar { background: var(--surface); box-shadow: 0 -8px 24px -16px rgba(10, 43, 30, .35); }
.rules-panel { padding-bottom: 24px; }
/* Turni: interruttore "Solo con turni" allineato ai filtri */
.staff-toolbar .staff-hide-empty { margin: 0; align-self: end; min-height: 40px; }
/* Area personale: turno di oggi già concluso */
.me-shift.is-ended { opacity: .72; }
.me-shift.is-ended .me-time { text-decoration: line-through; text-decoration-color: var(--green-300); text-decoration-thickness: 2px; }

/* ===================================================================== 2.52.2
   Campo file: il pulsante nativo (::file-selector-button) non si stila allo stesso modo in Safari e Chrome
   ("Scegli file" tagliato o fuori asse). app.js avvolge ogni <input type="file"> visibile in .file-field:
   pulsante nostro + nome del file; l'<input> resta sopra a tutto, trasparente (clic e tastiera come prima). */
.file-field { position: relative; display: inline-flex; align-items: center; gap: 10px; box-sizing: border-box; height: var(--control-h); min-height: var(--control-h); max-width: 100%; flex: 1 1 auto; min-width: 0; padding: 0 12px 0 4px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); vertical-align: middle; cursor: pointer; transition: border-color .14s ease, box-shadow .14s ease; }
.file-field:hover { border-color: var(--green-300); }
.file-field:focus-within { border-color: var(--green-400); box-shadow: var(--focus); }
.file-field input[type="file"] { position: absolute; inset: -1px; width: calc(100% + 2px); height: calc(100% + 2px); min-height: 0; margin: 0; padding: 0; opacity: 0; cursor: pointer; font-size: 0; display: block; }
.file-field .file-field-btn { pointer-events: none; flex: 0 0 auto; display: inline-flex; align-items: center; }
.file-field .file-field-name { flex: 1 1 auto; min-width: 0; color: var(--muted); font-size: var(--text-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.file-field.has-file .file-field-name { color: var(--ink); }
.field > .file-field, .qr-store-body > .file-field { display: flex; width: 100%; }

/* 4.3.0: nota introduttiva in testa a una finestra (carico, trasferimento, inventario): spazio prima del primo campo */
.modal-body > .hint-line:first-child { margin-bottom: 14px; }

/* 4.3.1: avviso di inattività in un contenitore proprio, sopra alle finestre */
#idleRoot .modal-backdrop { z-index: 1200; }
