/* console.css — lo stile delle pagine con la barra laterale: studio, codice, audio.

   L'aspetto e' quello di LabNet e della console di gestione (dontpanic), con le loro stesse
   librerie in copia locale (comune/librerie/: Bootstrap 5.1.3 e Font Awesome 7.0.1). Una pagina
   carica, in quest'ordine: bootstrap.min.css, all.min.css, questo foglio, e poi il suo (se ne ha).
   Non si carica insieme a studio.css (scuro, di immagini, video, 3d e training): sono alternativi.

   Tre parti:
   1. il guscio — barra laterale, contenuto, schede — con le regole di LabNet;
   2. i TOKEN di studio.css (--surface, --line, --text, --accent, ...) ridefiniti sui colori di
      Bootstrap: i fogli di codice e audio sono scritti su quei nomi e diventano chiari da soli;
   3. le classi comuni che il JavaScript di codice e audio gia' genera (.ed-input, .btn-mini,
      .hint, .chip, .empty, .drop, #toast, ...), ridisegnate come i componenti di Bootstrap.

   La terza parte vale solo per i verticali (<body data-vert="...">) dove un nome coincide con
   uno di Bootstrap (.card, .btn, .progress): li' il selettore e' `:where(body[data-vert]) .x`,
   che restringe senza alzare la specificita', cosi' il foglio della pagina continua a vincere. */

/* ---- 2. i token ---- */
:root {
    color-scheme: light;

    --bg: #f8f9fa;
    --surface: #fff;
    --surface-2: #f8f9fa;
    --surface-3: #e9ecef;
    --line: #dee2e6;
    --line-strong: #ced4da;

    --text: #212529;
    --text-dim: #6c757d;
    --text-faint: #868e96;

    --accent: #0d6efd;
    --accent-ink: #fff;
    --accent-soft: rgb(13 110 253 / 0.08);
    --accent-line: rgb(13 110 253 / 0.45);

    --ok: #198754;
    --warn-c: #997404;
    --danger: #dc3545;

    --radius-s: 0.375rem;
    --radius: 0.375rem;
    --radius-l: 0.5rem;
    --tap: 44px;
    --gutter: 16px;
    --bar-h: 0px;                       /* niente barra in basso: la navigazione e' di lato */
    --bar-top: 0px;                     /* niente testata: cio' che e' sticky si ferma in cima */
    --barra-l: 250px;
    --font: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --mono: ui-monospace, 'Cascadia Code', 'SF Mono', Consolas, 'Courier New', monospace;

    --bg-dark: var(--bg);
    --bg-panel: var(--surface);
    --border: var(--line);
    --success: var(--ok);
}

/* ---- 1. il guscio (LabNet: src/static/css/style.css) ---- */
body { margin: 0; padding: 0; background-color: var(--bg); font-family: var(--font); }
[hidden] { display: none !important; }
h1 { font-size: 1.75rem; font-weight: 600; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }

.sidebar {
    position: fixed; top: 0; left: 0; z-index: 1000;
    width: var(--barra-l); height: 100vh; height: 100dvh; overflow-y: auto;
    display: flex; flex-direction: column;
    background-color: #212529; color: #fff;
    transition: transform 0.3s ease;
}
.sidebar-header { padding: 1.5rem 1rem; border-bottom: 1px solid rgb(255 255 255 / 0.1); }
.sidebar-brand { display: flex; align-items: center; color: #fff; text-decoration: none; font-weight: 600; font-size: 1.25rem; }
.sidebar-brand:hover { color: #fff; }
/* Il marchio di ZStudio: l'omega blu su bianco, lo stesso disegno dell'icona dell'app */
.app-mark { width: 28px; height: 28px; margin-right: 0.5rem; border-radius: 7px; flex: 0 0 auto; display: block;
    object-fit: contain; background: #fff; }
.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }
.sidebar-link {
    display: flex; align-items: center; width: 100%; padding: 0.75rem 1.5rem;
    color: rgb(255 255 255 / 0.75); text-decoration: none; text-align: left; font: inherit;
    background: none; border: 0; border-left: 3px solid transparent;
    transition: all 0.2s;
}
.sidebar-link:hover { background-color: rgb(255 255 255 / 0.1); color: #fff; }
/* "dove sono": le pagine lo dicono in tre modi (.active, aria-current, aria-selected di una tablist) */
.sidebar-link.active, .sidebar-link[aria-current="page"], .sidebar-link[aria-selected="true"] {
    background-color: rgb(255 255 255 / 0.1); color: #fff; border-left-color: #0d6efd;
}
.sidebar-link i { width: 20px; margin-right: 0.75rem; font-size: 1rem; text-align: center; }
.sidebar-link:focus-visible { outline: 2px solid #6ea8fe; outline-offset: -2px; }
.sidebar-separator {
    margin: 0.5rem 0; padding: 0.5rem 1.5rem; border-top: 1px solid rgb(255 255 255 / 0.1);
    font-size: 0.75rem; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase;
    color: rgb(255 255 255 / 0.5);
}
.sidebar-separator:empty { padding: 0; height: 1px; }
.sidebar-footer { flex-shrink: 0; padding: 1rem 1.5rem; border-top: 1px solid rgb(255 255 255 / 0.1); background-color: #1a1d20; }
.sidebar-footer-text { display: flex; flex-direction: column; line-height: 1.2; }
.sidebar-footer-brand { color: rgb(255 255 255 / 0.9); font-weight: 600; font-size: 0.85rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer-version { color: rgb(255 255 255 / 0.5); font-size: 0.7rem; font-family: 'Courier New', monospace; }

.main-content { margin-left: var(--barra-l); min-height: 100vh; min-width: 0; }
.content-wrapper { padding: 2rem; }
.mobile-menu-toggle {
    position: fixed; top: 1rem; left: 1rem; z-index: 1100; display: none;
    background-color: #212529; color: #fff; border: none; border-radius: 0.375rem;
    padding: 0.75rem 1rem; font-size: 1.25rem; line-height: 1; cursor: pointer;
}
.mobile-menu-toggle:hover { background-color: #343a40; }
.sidebar-overlay { position: fixed; inset: 0; z-index: 999; display: none; background-color: rgb(0 0 0 / 0.5); }

.card { box-shadow: 0 0.125rem 0.25rem rgb(0 0 0 / 0.075); border: 1px solid rgb(0 0 0 / 0.125); }
.card-header { background-color: #fff; border-bottom: 1px solid rgb(0 0 0 / 0.125); font-weight: 600; }
.table-responsive { border-radius: 0.375rem; }
.badge { font-size: 0.75em; }
.btn, .alert { border-radius: 0.375rem; }
.table th { border-top: none; font-weight: 600; white-space: nowrap; }
.ov-btn { min-height: 44px; min-width: 44px; }
.ov-btn.btn-sm { display: inline-flex; align-items: center; }
/* la scheda con il bordo a sinistra che dice come sta (dashboard di LabNet) */
.ov-card { border-left: 4px solid var(--bs-secondary, #6c757d); }
.ov-card[data-status="ok"] { border-left-color: var(--bs-success, #198754); }
.ov-card[data-status="warn"] { border-left-color: var(--bs-warning, #ffc107); }
.ov-card[data-status="error"] { border-left-color: var(--bs-danger, #dc3545); }

/* ---- le viste di studio ---- */
.page-head { margin-bottom: 1.5rem; }
.page-head p { margin: 0; max-width: 48rem; }
.content-wrapper .card { margin-bottom: 1.5rem; }
.content-wrapper .card-header { display: flex; align-items: center; justify-content: space-between; gap: 0.25rem 1rem; flex-wrap: wrap; }
.content-wrapper .card-header .text-muted { font-weight: 400; }
.content-wrapper .card-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.griglia { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr)); margin-bottom: 1.5rem; }
.content-wrapper .griglia > .card, .content-wrapper .griglia > .alert { margin-bottom: 0; }
.table .azione { text-align: right; white-space: nowrap; width: 1%; }
.table .vuota { color: var(--text-dim); text-align: center; padding: 1.5rem 1rem; }
.form-control.numero { width: 5.5rem; text-align: right; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.alert:empty { display: none; }
/* I messaggi restano in vista anche con la pagina scorsa */
#avvisi { position: sticky; top: 0.5rem; z-index: 1030; }
.accesso { max-width: 26rem; margin: 0 auto; padding: 3rem 1rem; }
.tile { flex-direction: row; gap: 1rem; align-items: flex-start; padding: 1rem; color: inherit; text-decoration: none; }
a.tile:hover { border-color: #0d6efd; color: inherit; }
.tile.off { opacity: 0.55; }
.tile .ico { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 0.375rem; display: grid; place-items: center;
    background: var(--accent-soft); color: #0d6efd; font-size: 1.25rem; }
.tile h2 { font-size: 1.05rem; margin: 0 0 0.25rem; }
.tile p { margin: 0; color: var(--text-dim); font-size: 0.9rem; }

.spinner {
    width: 36px; height: 36px; border-radius: 50%;
    border: 3px solid var(--surface-3); border-top-color: #0d6efd;
    animation: studio-gira 0.8s linear infinite;
}
@keyframes studio-gira { to { transform: rotate(360deg); } }
.boot { display: grid; place-items: center; min-height: 50vh; color: var(--text-dim); }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- 3. le classi comuni dei verticali, come componenti di Bootstrap ---- */
.hint { color: var(--text-dim); font-size: 0.875rem; }
.warn { color: var(--danger); }
.eyebrow, label.eyebrow {
    display: block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--text-faint);
}
:where(body[data-vert]) label { color: var(--text-dim); font-size: 0.875rem; font-weight: 600; }
.control-group { margin-bottom: 16px; }
.control-group > label { display: block; margin-bottom: 6px; }
:where(body[data-vert]) :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px;
}

/* i campi: .form-control e .form-select */
.ed-input, select.ed-input, textarea.ed-input {
    width: 100%; min-height: var(--tap); padding: 0.375rem 0.75rem;
    background-color: #fff; color: var(--text);
    border: 1px solid var(--line-strong); border-radius: var(--radius-s);
    font: inherit; font-size: 1rem;              /* 16px: sotto, iOS ingrandisce la pagina */
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.ed-input::placeholder { color: var(--text-faint); }
.ed-input:focus { outline: 0; border-color: #86b7fe; box-shadow: 0 0 0 0.25rem rgb(13 110 253 / 0.25); }
.ed-input:disabled { background-color: var(--surface-3); }
textarea.ed-input { resize: vertical; line-height: 1.5; }
select.ed-input {
    appearance: none; -webkit-appearance: none; padding-right: 2.25rem;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat; background-position: right 0.75rem center; background-size: 16px 12px;
}
:where(body[data-vert]) input[type="checkbox"], :where(body[data-vert]) input[type="radio"] { accent-color: var(--accent); width: 20px; height: 20px; }
:where(body[data-vert]) input[type="range"] { accent-color: var(--accent); }

/* i bottoni. Nei verticali un .btn senza variante e' il bottone secondario (in Bootstrap sarebbe
   senza bordo), .btn-mini quello piccolo, .btn-generate il primario, .btn-danger il distruttivo
   secondario: contorno rosso, non pieno. */
:where(body[data-vert]) .btn, .btn-mini {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font: inherit; font-weight: 400; text-decoration: none; cursor: pointer; white-space: nowrap;
    color: var(--text-dim); background-color: #fff;
    border: 1px solid var(--text-dim); border-radius: var(--radius-s);
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
}
:where(body[data-vert]) .btn { min-height: var(--tap); padding: 0.375rem 1rem; font-size: 1rem; }
.btn-mini { min-height: 38px; padding: 0.25rem 0.75rem; font-size: 0.875rem; }
:where(body[data-vert]) .btn:hover, .btn-mini:hover { color: #fff; background-color: var(--text-dim); border-color: var(--text-dim); }
:where(body[data-vert]) .btn-primary, .btn-generate { color: #fff; background-color: #0d6efd; border-color: #0d6efd; font-weight: 400; }
:where(body[data-vert]) .btn-primary:hover, .btn-generate:hover { color: #fff; background-color: #0b5ed7; border-color: #0a58ca; }
:where(body[data-vert]) .btn-danger { color: var(--danger); background-color: #fff; border-color: var(--danger); }
:where(body[data-vert]) .btn-danger:hover { color: #fff; background-color: var(--danger); border-color: var(--danger); }
:where(body[data-vert]) .btn:disabled, .btn-mini:disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
:where(body[data-vert]) .btn-row > .btn { flex: 1 1 auto; }

/* i pannelli: nei verticali il contenuto sta direttamente nella .card, senza .card-body */
:where(body[data-vert]) .card { display: block; padding: 1.25rem; border-radius: var(--radius-l); }
:where(body[data-vert]) .card > h2:first-child, :where(body[data-vert]) .card > h3:first-child { margin-top: 0; }
.page { width: 100%; max-width: 72rem; margin: 0 auto; padding: 20px var(--gutter) 32px; }
:where(body[data-vert]) .page-head { margin: 4px 0 18px; }
:where(body[data-vert]) .page-head p { color: var(--text-dim); max-width: 42rem; }
:where(body[data-vert]) hr { margin: 16px 0; }

:where(body[data-vert]) details > summary { cursor: pointer; list-style: none; }
:where(body[data-vert]) details > summary::-webkit-details-marker { display: none; }
details.fold > summary { min-height: var(--tap); display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--text); }
details.fold > summary::after {
    content: ""; margin-left: auto; width: 8px; height: 8px; flex: 0 0 auto;
    border-right: 2px solid var(--text-dim); border-bottom: 2px solid var(--text-dim);
    transform: rotate(45deg); transition: transform 0.2s;
}
details.fold[open] > summary::after { transform: rotate(-135deg); }

/* le etichette di stato: i .badge chiari */
.chip {
    display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 0 0.6em;
    border-radius: var(--radius-s); font-size: 0.75rem; font-weight: 700; white-space: nowrap;
    background: var(--surface-3); color: #495057; border: 1px solid var(--line);
}
.chip.ok { color: #0f5132; background: #d1e7dd; border-color: #badbcc; }
.chip.run { color: #664d03; background: #fff3cd; border-color: #ffecb5; }
.chip.err { color: #842029; background: #f8d7da; border-color: #f5c2c7; }

.empty { padding: 28px 16px; text-align: center; color: var(--text-dim);
    border: 1.5px dashed var(--line-strong); border-radius: var(--radius); }

/* zona per scegliere un file: grande, da toccare */
.drop {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 6px; min-height: 120px; padding: 18px; text-align: center; cursor: pointer;
    border: 1.5px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface-2);
    color: var(--text-dim); overflow-wrap: anywhere; transition: border-color 0.15s, background-color 0.15s;
}
.drop:hover, .drop:focus-within { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.drop input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.drop strong { color: var(--text); font-weight: 700; }

/* nei verticali la barra di avanzamento e' .progress > span, non .progress-bar */
:where(body[data-vert]) .progress { display: block; height: 8px; border-radius: 999px; }
.progress > span:not(.progress-bar) { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width 0.3s; }

/* gli avvisi brevi (comune/js/dom.js: #toast con le classi `toast show [error]`, che sono anche
   nomi di Bootstrap: qui si riscrive tutto cio' che Bootstrap ci metterebbe) */
#toast {
    position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 1090;
    display: block; width: auto; max-width: calc(100vw - 32px); padding: 0.75rem 1.1rem;
    transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
    border: 0; border-radius: 0.375rem; background: #212529; color: #fff; font-size: 1rem; font-weight: 600;
    box-shadow: 0 0.5rem 1rem rgb(0 0 0 / 0.25);
    transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); }

/* "Servizio spento" (comune/js/motore.js): sopra il lavoro, mai in un toast, perche' resta vero
   finche' il motore non risponde. E' un .alert-warning */
.motori-avvisi { display: grid; gap: 8px; margin: 0 0 16px; }
.motore-avviso {
    display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
    padding: 0.75rem 1rem; border-radius: var(--radius);
    color: #664d03; background: #fff3cd; border: 1px solid #ffecb5;
}
.motore-avviso[data-stato="in_avvio"] { color: #055160; background: #cff4fc; border-color: #b6effb; }
.motore-avviso[data-stato="sconosciuto"] { color: var(--text); background: var(--surface-3); border-color: var(--line); }
.motore-testo { flex: 1 1 220px; display: grid; gap: 2px; min-width: 0; }
.motore-testo .hint { color: inherit; opacity: 0.85; font-size: 0.875rem; }
.motore-errore { color: #842029; font-size: 0.875rem; }
.motore-avviso .btn { flex: 0 0 auto; }
.motore-avviso[data-stato="in_avvio"] .motore-testo strong::before {
    content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px;
    border-radius: 50%; border: 2px solid rgb(0 0 0 / 0.15); border-top-color: currentColor;
    animation: studio-gira 0.8s linear infinite;
}

/* ---- telefono: la barra laterale esce da sinistra, col bottone in alto ---- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(calc(-1 * var(--barra-l))); }
    .sidebar.show { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    .main-content { margin-left: 0; padding-top: 4rem; }
    /* cio' che e' sticky si ferma sotto il bottone del menu */
    :root { --bar-top: 4rem; }
    .mobile-menu-toggle { display: block; }
    .content-wrapper { padding: 1rem; padding-top: 0; }
    .table-responsive { font-size: 0.875rem; }
    .badge { font-size: 0.65em; }
}

@media (min-width: 900px) {
    :root { --gutter: 24px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation-duration: 0.001ms !important; }
}
