/* RGMediaServer: palette "sala proiezione".
   Grigi freddi, blu proiettore per le azioni, tre colori di stato.
   L'unico elemento decorativo è la barra di scansione a pellicola. */

:root {
  --bg: #f2f4f7;
  --surface: #ffffff;
  --ink: #17202a;
  --muted: #5a6774;
  --line: #d6dde4;
  --accent: #1d5fc2;
  --accent-ink: #ffffff;
  --amber: #b7791f;
  --green: #2e7d4f;
  --red: #b3261e;
  --film: #243140;
  --radius-s: 4px;
  --radius-m: 8px;
  color-scheme: light dark;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161c;
    --surface: #19212a;
    --ink: #e4e9ee;
    --muted: #97a3b0;
    --line: #2b3540;
    --accent: #6ea2f0;
    --accent-ink: #0d1420;
    --amber: #e0a43a;
    --green: #5cb884;
    --red: #f07a70;
    --film: #0a0f14;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); }
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* --- struttura --- */

.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.brand { font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.side ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.side ul a {
  display: block;
  padding: 7px 10px;
  border-radius: var(--radius-s);
  color: var(--ink);
  text-decoration: none;
}
.side ul a:hover { background: var(--bg); }
.side ul a[aria-current="page"] { background: var(--bg); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.side .logout { margin-top: auto; }
.version { margin: 0; color: var(--muted); font-size: 12px; }

main { padding: 28px 36px 64px; max-width: 1040px; width: 100%; }
main.narrow { max-width: 420px; margin: 9vh auto 0; padding: 0 20px 48px; }
main.narrow .brand { display: block; margin-bottom: 26px; font-size: 20px; }

h1 { font-size: 26px; line-height: 1.2; margin: 0 0 22px; letter-spacing: -0.015em; }
h2 { font-size: 17px; margin: 34px 0 10px; }
h2:first-child { margin-top: 0; }
p { margin: 0 0 12px; max-width: 72ch; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

section.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.danger-zone { border-color: color-mix(in srgb, var(--red) 45%, var(--line)); }

.breadcrumbs { font-size: 13px; color: var(--muted); margin: -12px 0 14px; }
.breadcrumbs a { color: var(--muted); }

.head-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.head-row h1 { margin: 0; }

/* --- messaggi --- */

.notice, .error {
  padding: 10px 14px;
  border-radius: var(--radius-s);
  margin: 0 0 18px;
  border-left: 4px solid;
  background: var(--surface);
}
.notice { border-color: var(--green); }
.error { border-color: var(--red); }

.token-box {
  border: 1px solid var(--amber);
  background: color-mix(in srgb, var(--amber) 9%, var(--surface));
  border-radius: var(--radius-m);
  padding: 16px 18px;
  margin-bottom: 18px;
}
.token-box code { font-size: 15px; word-break: break-all; }

/* --- tabelle --- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; font-weight: 600; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.actions { text-align: right; white-space: nowrap; }
.path { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; overflow-wrap: anywhere; }
table.middle td { vertical-align: middle; }
.tag {
  display: inline-block;
  font-size: 12px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.tag.warn { color: var(--amber); border-color: currentColor; }
.tag.ok { color: var(--green); border-color: currentColor; }
.tag.off { color: var(--red); border-color: currentColor; }

/* --- moduli --- */

form.stack { display: grid; gap: 14px; max-width: 520px; }
form.inline { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
label { display: grid; gap: 4px; font-weight: 600; font-size: 14px; }
label .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
input[type="text"], input[type="password"], input[type="search"], select {
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 8px 10px;
  min-width: 0;
}
input:focus-visible, select:focus-visible { outline-offset: 0; }
.with-button { display: flex; gap: 8px; }
.with-button input { flex: 1; min-width: 0; width: 26rem; max-width: 100%; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
legend { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.choice { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.choice input { margin-top: 4px; }
.choice strong { display: block; }
.radio-row { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-row label { display: flex; gap: 6px; align-items: center; font-weight: 400; }

button, .button {
  font: inherit;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-s);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
button.secondary, .button.secondary { background: transparent; color: var(--accent); }
button.danger { background: transparent; color: var(--red); border-color: var(--red); }
button.link { background: none; border: 0; padding: 0; color: var(--muted); font-weight: 400; text-decoration: underline; }
button:disabled { opacity: .55; cursor: default; }

.pager { display: flex; gap: 12px; align-items: center; margin-top: 14px; font-size: 14px; }

/* --- scansione: la pellicola --- */

.scan { display: grid; gap: 10px; }
.scan-line { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.strip {
  position: relative;
  height: 26px;
  background: var(--film);
  border-radius: 3px;
  overflow: hidden;
}
/* le perforazioni sopra e sotto */
.strip::before, .strip::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  z-index: 2;
  background: repeating-linear-gradient(90deg, transparent 0 5px, var(--bg) 5px 11px);
  opacity: .9;
}
.strip::before { top: 3px; }
.strip::after { bottom: 3px; }
.strip .frames {
  position: absolute;
  top: 9px;
  bottom: 9px;
  left: 0;
  width: 0;
  background: var(--amber);
  transition: width .5s ease-out;
}
/* pellicola ferma: nessuna scansione in corso */
.strip.idle .frames { background: var(--muted); opacity: .35; width: 100%; }
.strip.indeterminate .frames { width: 30%; animation: roll 1.6s linear infinite; }
@keyframes roll { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
@media (prefers-reduced-motion: reduce) {
  .strip .frames { transition: none; }
  .strip.indeterminate .frames { animation: none; width: 100%; opacity: .5; }
}

/* --- selettore cartelle --- */

dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
  color: var(--ink);
  width: min(560px, 92vw);
  padding: 0;
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
.picker-head { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.picker-list { max-height: 50vh; overflow-y: auto; list-style: none; margin: 0; padding: 6px; }
.picker-list button {
  width: 100%;
  justify-content: flex-start;
  background: none;
  border: 0;
  color: var(--ink);
  font-weight: 400;
  padding: 7px 10px;
}
.picker-list button:hover { background: var(--bg); }
.picker-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }

/* --- schermi piccoli --- */

@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { border-right: 0; border-bottom: 1px solid var(--line); padding: 14px 16px; gap: 10px; }
  .side ul { grid-auto-flow: column; justify-content: start; overflow-x: auto; }
  .side ul a { white-space: nowrap; }
  .side .logout, .version { margin: 0; }
  main { padding: 20px 16px 48px; }
  .wide-only { display: none; }
}
