/* AVOLINFO 2K27 — pagina di consegna e pannello docenti, tema chiaro e scuro. */

:root {
  color-scheme: light;
  --page: #f3f3f0;
  --surface: #fcfcfb;
  --surface-2: #f0efeb;
  --surface-3: #e5e4de;
  --line: rgba(11, 11, 11, .08);
  --line-strong: rgba(11, 11, 11, .15);
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #7a7974;
  --accent: #2a63c4;
  --accent-wash: rgba(42, 99, 196, .08);
  --shadow: 0 1px 2px rgba(11, 11, 11, .04), 0 6px 24px rgba(11, 11, 11, .05);
  --ok-ink: #006300;
  --ok-wash: rgba(0, 131, 0, .08);
  --bad-ink: #b42323;
  --bad-wash: rgba(227, 73, 72, .08);
  --warn-ink: #8a5a00;
  --warn-wash: rgba(237, 161, 0, .12);
  --j-key: #6250d6;
  --j-string: #006300;
  --j-number: #2a63c4;
  --j-other: #b0490f;

  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0f1011;
    --surface: #18191b;
    --surface-2: #212225;
    --surface-3: #2b2c30;
    --line: rgba(255, 255, 255, .07);
    --line-strong: rgba(255, 255, 255, .14);
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #8f8e88;
    --accent: #7fa8f5;
    --accent-wash: rgba(127, 168, 245, .1);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .25);
    --ok-ink: #3ccf3c;
    --ok-wash: rgba(60, 207, 60, .08);
    --bad-ink: #ff8d8d;
    --bad-wash: rgba(255, 141, 141, .08);
    --warn-ink: #fab219;
    --warn-wash: rgba(250, 178, 25, .1);
    --j-key: #a99ff0;
    --j-string: #6fd38a;
    --j-number: #7fa8f5;
    --j-other: #f59e6b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0f1011;
  --surface: #18191b;
  --surface-2: #212225;
  --surface-3: #2b2c30;
  --line: rgba(255, 255, 255, .07);
  --line-strong: rgba(255, 255, 255, .14);
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #8f8e88;
  --accent: #7fa8f5;
  --accent-wash: rgba(127, 168, 245, .1);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .25);
  --ok-ink: #3ccf3c;
  --ok-wash: rgba(60, 207, 60, .08);
  --bad-ink: #ff8d8d;
  --bad-wash: rgba(255, 141, 141, .08);
  --warn-ink: #fab219;
  --warn-wash: rgba(250, 178, 25, .1);
  --j-key: #a99ff0;
  --j-string: #6fd38a;
  --j-number: #7fa8f5;
  --j-other: #f59e6b;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--page); color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.wrap { width: min(1240px, 100% - 32px); margin-inline: auto; }

/* ---------- Barra superiore ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--page) 82%, transparent); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 24px; min-height: 58px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-size: 15px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--ink); color: var(--page); font-size: 11px; font-weight: 800; letter-spacing: .02em; }
.brand-tag { padding: 2px 8px; border: 1px solid var(--line-strong); border-radius: 99px; color: var(--muted); font-size: 11px; }
.topnav { display: flex; gap: 2px; }
.topnav a { padding: 7px 11px; border-radius: 7px; color: var(--ink-2); font-size: 13px; font-weight: 500; }
.topnav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.topnav a[aria-current="page"] { background: var(--surface-3); color: var(--ink); }
.topbar-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-btn { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink-2); }
.icon-btn:hover { color: var(--ink); background: var(--surface-2); }
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.icon-btn .i-moon { fill: currentColor; stroke: none; }
.icon-btn[data-mode="dark"] .i-moon, .icon-btn:not([data-mode="dark"]) .i-sun { display: none; }

/* ---------- Controlli ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 6px 13px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 550; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-sm { min-height: 28px; padding: 3px 10px; font-size: 12px; }
.btn-primary { border-color: transparent; background: var(--ink); color: var(--page); }
.btn-primary:hover { background: var(--ink-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-lg { min-height: 44px; padding: 10px 20px; font-size: 14.5px; border-radius: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.field { display: grid; gap: 5px; min-width: 0; }
.field > span { color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .02em; }
.field input, .field select { width: 100%; min-height: 36px; padding: 7px 11px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 14px; }
.field input::placeholder { color: var(--muted); }
.field input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-wash); }

/* ---------- Struttura pagina docenti ---------- */
.page { padding: 28px 0 80px; }
.page-head { margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: clamp(26px, 3.4vw, 34px); font-weight: 650; letter-spacing: -.02em; line-height: 1.15; }
.page-sub { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.back-link { display: inline-block; margin-bottom: 8px; color: var(--muted); font-size: 13px; }
.card { min-width: 0; padding: 20px 22px 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 10px 18px; margin-bottom: 16px; }
.card-head h2 { margin: 0; font-size: 16px; font-weight: 650; }
.card-head p { max-width: 70ch; margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.empty-card { color: var(--muted); text-align: center; padding: 40px 20px; }
.block { margin-top: 26px; }
.block-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 12px; }
.block-head h2 { margin: 0; font-size: 18px; font-weight: 650; }
.block-head p { max-width: 80ch; margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 12px; }
.kpi { display: grid; align-content: start; gap: 4px; min-width: 0; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.kpi-label { color: var(--muted); font-size: 12px; font-weight: 550; }
.kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-value small { color: var(--muted); font-size: 15px; font-weight: 500; letter-spacing: 0; }
.kpi-sub { color: var(--muted); font-size: 12px; }
.kpi-sub b { color: var(--ink-2); }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-bottom: 12px; }
.filters .field { flex: 0 1 180px; }
.filters .field.grow { flex: 1 1 260px; max-width: 360px; }
.filters-note { flex-basis: 100%; margin: 0; color: var(--muted); font-size: 12px; }

/* ---------- Tabelle ---------- */
.table-card { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.table-card.tall { max-height: none; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; text-align: left; }
.data-table th { position: sticky; top: 0; z-index: 1; padding: 10px 14px; border-bottom: 1px solid var(--line-strong); background: var(--surface); color: var(--muted); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.data-table td { padding: 9px 14px; border-bottom: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; vertical-align: top; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: var(--surface-2); }
.data-table td b { color: var(--ink); font-weight: 600; }
.data-table td:first-child a { font-weight: 600; }
.data-table .num { font-variant-numeric: tabular-nums; text-align: right; }
.data-table .end { text-align: right; }
.data-table small { color: var(--muted); }
.data-table code { color: var(--ink); }
.data-table .empty-row { padding: 28px; color: var(--muted); text-align: center; white-space: normal; }
.file-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.keys-cell { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.keys-cell code { color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-ok { color: var(--ok-ink); }
.status-bad { color: var(--bad-ink); }
.tag { display: inline-block; margin-left: 6px; padding: 1px 7px; border: 1px solid var(--line-strong); border-radius: 99px; color: var(--muted); font-size: 11px; font-weight: 600; vertical-align: 1px; }
.tag-warn { border-color: transparent; background: var(--warn-wash); color: var(--warn-ink); }

/* ---------- Struttura ---------- */
.structure-table td { white-space: normal; }
.path-cell code { white-space: nowrap; }
.path-cell[data-depth="1"] { padding-left: 30px; }
.path-cell[data-depth="2"] { padding-left: 46px; }
.path-cell[data-depth="3"] { padding-left: 62px; }
.path-cell[data-depth="4"] { padding-left: 78px; }
.path-cell[data-depth="5"], .path-cell[data-depth="6"], .path-cell[data-depth="7"], .path-cell[data-depth="8"] { padding-left: 94px; }
.meter-cell { width: 140px; }
.meter { display: block; width: 120px; height: 6px; margin-top: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--accent); }
.type { display: inline-block; margin: 0 4px 2px 0; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); color: var(--ink-2); font: 600 11px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.examples-cell { max-width: 420px; color: var(--muted); overflow-wrap: anywhere; }
.examples-cell code { color: var(--ink-2); }

/* ---------- Dettaglio consegna ---------- */
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 14px 24px; margin: 0; }
.meta-grid div { min-width: 0; }
.meta-grid dt { color: var(--muted); font-size: 11.5px; font-weight: 600; }
.meta-grid dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.meta-grid small { color: var(--muted); }
.json-tree { overflow: auto; font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.j-node > summary { cursor: pointer; list-style: none; border-radius: 4px; }
.j-node > summary::-webkit-details-marker { display: none; }
.j-node > summary::before { content: "▸"; display: inline-block; width: 14px; color: var(--muted); transition: transform .12s; }
.j-node[open] > summary::before { transform: rotate(90deg); }
.j-node > summary:hover { background: var(--surface-2); }
.j-children { margin-left: 7px; padding-left: 12px; border-left: 1px solid var(--line-strong); }
.j-leaf { padding-left: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.j-key { color: var(--j-key); font-weight: 600; }
.j-key::after { content: ": "; color: var(--muted); font-weight: 400; }
.j-sum, .j-empty { color: var(--muted); }
.j-string { color: var(--j-string); }
.j-number { color: var(--j-number); }
.j-boolean, .j-null { color: var(--j-other); }
.j-cut { color: var(--warn-ink); }
.raw-card > summary { cursor: pointer; font-weight: 650; }
.raw { max-height: 520px; margin: 14px 0 0; padding: 14px; overflow: auto; border-radius: 10px; background: var(--surface-2); white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Pagina studenti ---------- */
.student-main { padding: 40px 0 80px; }
.hero { max-width: 720px; margin-bottom: 26px; }
.hero h1 { margin: 0; font-size: clamp(28px, 4.4vw, 40px); font-weight: 680; letter-spacing: -.025em; line-height: 1.1; }
.hero p { margin: 10px 0 0; color: var(--ink-2); font-size: 15.5px; }
.submit-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.submit-card { padding: 24px; }
.step-title { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 15px; font-weight: 650; }
.step-title span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-3); color: var(--ink-2); font-size: 12px; font-weight: 700; }
.who { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 12px; margin-bottom: 24px; }
.drop { position: relative; display: grid; justify-items: center; gap: 6px; padding: 30px 18px; border: 1.5px dashed var(--line-strong); border-radius: 14px; background: var(--surface-2); color: var(--ink-2); text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.is-dragging { border-color: var(--accent); background: var(--accent-wash); }
.drop svg { width: 38px; height: 38px; color: var(--muted); }
.drop strong { color: var(--ink); font-size: 15px; }
.drop small { color: var(--muted); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.files { display: grid; gap: 8px; margin: 14px 0 0; padding: 0; list-style: none; }
.file-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.file-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--surface-3); color: var(--ink-2); font: 700 10px ui-monospace, monospace; }
.file-name { overflow: hidden; color: var(--ink); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.file-note { color: var(--muted); font-size: 12px; }
.file-note.warn { color: var(--warn-ink); }
.file-note.bad { color: var(--bad-ink); }
.file-note.ok { color: var(--ok-ink); }
.file-state { font-size: 12px; font-weight: 600; white-space: nowrap; }
.file-row.is-done { border-color: color-mix(in srgb, var(--ok-ink) 30%, transparent); background: var(--ok-wash); }
.file-row.is-error { border-color: color-mix(in srgb, var(--bad-ink) 30%, transparent); background: var(--bad-wash); }
.remove-btn { padding: 4px 8px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-size: 12px; }
.remove-btn:hover { background: var(--surface-3); color: var(--ink); }
.submit-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 20px; }
.feedback { margin: 0; font-size: 13px; }
.feedback.error { color: var(--bad-ink); }
.feedback.ok { color: var(--ok-ink); font-weight: 600; }
.feedback.info { color: var(--muted); }
.side { display: grid; gap: 18px; }
.steps { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { display: grid; grid-template-columns: 24px 1fr; gap: 10px; color: var(--ink-2); counter-increment: step; }
.steps li::before { content: counter(step); display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-3); color: var(--ink-2); font-size: 12px; font-weight: 700; }
.note { margin: 0; color: var(--muted); font-size: 13px; }
.receipts { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.receipts li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; border-radius: 10px; background: var(--ok-wash); color: var(--ink-2); font-size: 13px; }
.receipts b { color: var(--ok-ink); font-variant-numeric: tabular-nums; }
.site-foot { padding: 24px 0 40px; color: var(--muted); font-size: 12px; }

@media (max-width: 860px) {
  .submit-grid { grid-template-columns: 1fr; }
  .topnav { display: none; }
}
@media (max-width: 560px) {
  .who { grid-template-columns: 1fr; }
  .card, .submit-card { padding: 16px; }
  .brand-tag { display: none; }
}
