/* app.css — design system dell'applicativo SCORM Studio (nessuna dipendenza esterna) */

/* ===== Tokens / temi ===== */
:root {
  --accent: #2d6fff;
  --accent-hover: #1b57e0;
  --accent-soft: rgba(45, 111, 255, .14);
  --sidebar-w: 236px;
  --radius: 12px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
:root, :root[data-theme=dark] {
  --bg: #0b0e13;
  --surface: #131822;
  --surface-2: #1a2130;
  --border: #232a38;
  --border-strong: #303a4c;
  --text: #e8eaed;
  --text-muted: #a7b0bf;
  --text-dim: #6d7788;
  --input-bg: #0e131b;
  --shadow: 0 12px 32px rgba(0, 0, 0, .38);
  --scrim: rgba(4, 7, 11, .62);
  --ok: #46c483; --ok-bg: #10301f; --ok-border: #23684422;
  --err: #ff7b87; --err-bg: #38151b; --err-border: #7a2530;
  --danger: #b0333f; --danger-hover: #93202c; --danger-text: #ffb3ba;
}
:root[data-theme=light] {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f4f6fb;
  --border: #dfe4ed;
  --border-strong: #c4cddb;
  --text: #1b212c;
  --text-muted: #4c576a;
  --text-dim: #8a94a6;
  --input-bg: #f7f9fc;
  --shadow: 0 12px 32px rgba(25, 38, 60, .14);
  --scrim: rgba(22, 30, 44, .45);
  --ok: #157347; --ok-bg: #e2f5ea; --ok-border: #b3e2c8;
  --err: #c2303c; --err-bg: #fdebec; --err-border: #f3c2c6;
  --danger: #d03744; --danger-hover: #b32431; --danger-text: #ffffff;
}

/* Font vendorizzati in locale (nessun CDN) — Google Fonts, licenza SIL Open Font License.
   Stessi file usati nel runtime del pacchetto SCORM: l'anteprima nell'editor
   corrisponde esattamente al risultato finale. */
@font-face { font-family: 'Roboto'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/roboto-var.woff2') format('woff2'); }
@font-face { font-family: 'Roboto'; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/roboto-var.woff2') format('woff2'); }
@font-face { font-family: 'Open Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/opensans-var.woff2') format('woff2'); }
@font-face { font-family: 'Open Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/opensans-var.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/montserrat-var.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/montserrat-var.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/poppins-regular.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/poppins-bold.woff2') format('woff2'); }

/* ===== Base ===== */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
/* Normalizza <button> a <a>: lo UA stylesheet dà ai bottoni line-height/margin
   propri (diversi da quelli ereditati dai link), facendo apparire elementi con
   la stessa classe di dimensioni diverse. Le classi sotto restano invariate. */
button {
  font: inherit; line-height: inherit; color: inherit; margin: 0;
  -webkit-appearance: none; appearance: none;
}
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font);
  background: var(--bg); color: var(--text);
  font-size: 15px; line-height: 1.5;
}
a { color: var(--accent); }
code { background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 5px; font-size: .9em; }
.muted { color: var(--text-muted); }
.hint { font-size: 13px; color: var(--text-muted); display: block; margin-top: 6px; line-height: 1.5; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px;
}

/* ===== App shell ===== */
.app-shell { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 auto;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 12px 14px;
  z-index: 40;
}
.brand {
  display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px;
  font-weight: 700; font-size: 16px; letter-spacing: .01em;
}
.brand-logo {
  width: 34px; height: 34px; flex: 0 0 auto; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #7a4dff);
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.brand-logo svg { width: 19px; height: 19px; }
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--text-dim); letter-spacing: .04em; }

.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 9px; text-decoration: none;
  color: var(--text-muted); font-size: 14px; font-weight: 500;
}
.nav-item svg { width: 18px; height: 18px; flex: 0 0 auto; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }

.side-foot { display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--border); padding-top: 10px; }
.side-foot .nav-item { width: 100%; border: 0; background: transparent; cursor: pointer; font-family: inherit; text-align: left; }
.side-foot .nav-item:hover { background: var(--surface-2); color: var(--text); }

.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.app-header {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 26px; background: var(--surface); border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.app-header h1 { margin: 0; font-size: 17px; font-weight: 650; }
.app-header .header-sub { font-size: 13px; color: var(--text-dim); margin-left: auto; }
.btn-menu { display: none; }

.app-body { flex: 1; overflow-y: auto; padding: 24px 26px 40px; }
.page { max-width: 860px; margin: 0 auto; }
.page.wide { max-width: 1100px; }

.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: var(--scrim); z-index: 35;
}

/* ===== Card / form ===== */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px 26px; display: flex; flex-direction: column; gap: 16px;
}
.card h2 { margin: 0; font-size: 15px; font-weight: 650; color: var(--text); }
.card .section-title { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); margin: 8px 0 0; }

label, .field { display: flex; flex-direction: column; gap: 7px; font-size: 14px; font-weight: 500; }
.field-label { font-size: 14px; font-weight: 500; }
input[type=text], input[type=password], input[type=number], textarea, select {
  background: var(--input-bg); border: 1px solid var(--border-strong); border-radius: 9px;
  color: var(--text); padding: 10px 12px; font-size: 15px; font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
textarea { resize: vertical; }
input.invalid, textarea.invalid { border-color: var(--err); outline-color: var(--err); }

.row { display: flex; gap: 16px; }
.row > label { flex: 1; }
.req { color: var(--err); font-weight: 700; margin-left: 2px; }
.opt { font-weight: 400; font-size: 12px; color: var(--text-dim); margin-left: 4px; }

.interval-fields { display: flex; align-items: center; gap: 8px; }
.interval-fields input { width: 84px; }
.interval-unit { font-size: 13px; color: var(--text-muted); }

/* ===== Bottoni ===== */
.btn {
  border: 0; border-radius: 10px; padding: 12px 22px; font-size: 15px; font-weight: 600;
  color: #fff; background: var(--accent); cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.btn-secondary { background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text); }
.btn.btn-secondary:hover { background: var(--border); }
.btn.btn-danger { background: var(--danger); color: var(--danger-text); }
.btn.btn-danger:hover { background: var(--danger-hover); }
.btn.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 8px; }
.btn-text { background: transparent; border: 0; color: var(--accent); font-size: 13px; cursor: pointer; padding: 4px 6px; border-radius: 6px; font-family: inherit; }
.btn-text:hover { background: var(--accent-soft); }

.btn-icon {
  background: transparent; border: 1px solid var(--border); border-radius: 8px;
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted); cursor: pointer;
}
.btn-icon:hover { color: var(--text); border-color: var(--border-strong); }
.btn-icon svg { width: 18px; height: 18px; }

/* ===== Stepper (wizard) ===== */
.stepper {
  list-style: none; display: flex; margin: 0 0 20px; padding: 0; gap: 6px;
}
.stepper .step {
  flex: 1; display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 10px; font-size: 13px; font-weight: 600;
  color: var(--text-dim); background: var(--surface); border: 1px solid var(--border);
  cursor: default; user-select: none;
}
.stepper .step-num {
  width: 24px; height: 24px; border-radius: 50%; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  font-size: 12px; color: var(--text-muted);
}
.stepper .step.active { color: var(--text); border-color: var(--accent); }
.stepper .step.active .step-num { background: var(--accent); border-color: var(--accent); color: #fff; }
.stepper .step.done { color: var(--text-muted); cursor: pointer; }
.stepper .step.done:hover { border-color: var(--border-strong); }
.stepper .step.done .step-num { background: var(--ok-bg); border-color: transparent; color: var(--ok); }

.wstep[hidden] { display: none; }
.wizard-nav { display: flex; align-items: center; margin-top: 18px; gap: 10px; }
.wizard-nav-right { margin-left: auto; display: flex; gap: 10px; }

/* ===== Dropzone / lista file ===== */
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--input-bg); padding: 30px 20px; text-align: center;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: var(--text-muted); font-weight: 400;
}
.dropzone svg { width: 34px; height: 34px; color: var(--text-dim); margin-bottom: 4px; }
.dropzone strong { color: var(--text); font-size: 15px; }
.dropzone .dz-sub { font-size: 13px; }
.dropzone .hint { margin-top: 2px; }
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.dropzone-sm { padding: 18px 16px; }
.dropzone.dropzone-sm svg { width: 26px; height: 26px; }

.file-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.file-list:empty { display: none; }
.file-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; font-size: 14px; font-weight: 400;
}
.file-item .fi-num {
  width: 24px; height: 24px; border-radius: 7px; flex: 0 0 auto;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
}
.file-item .fi-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .fi-size { color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.file-item .fi-del {
  background: transparent; border: 0; color: var(--text-dim); cursor: pointer;
  width: 26px; height: 26px; border-radius: 6px; font-size: 15px; line-height: 1;
}
.file-item .fi-del:hover { color: var(--err); background: var(--err-bg); }

.img-field-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ===== Mode cards ===== */
.mode-cards { display: flex; gap: 12px; }
.mode-card {
  flex: 1; display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; font-weight: 400; background: var(--input-bg);
}
.mode-card input { margin-top: 3px; accent-color: var(--accent); }
.mode-card strong { display: block; margin-bottom: 3px; font-size: 14px; }
.mode-card p { margin: 0; font-size: 13px; color: var(--text-muted); }
.mode-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.batch-titles-intro { margin: 0 0 10px; font-size: 13px; font-weight: 500; color: var(--text-muted); }
.batch-title-fields { display: flex; flex-direction: column; gap: 10px; }
.batch-item { display: flex; flex-direction: column; gap: 5px; }
.batch-file-name { font-size: 12px; color: var(--text-dim); }

/* ===== Riepilogo ===== */
dl.summary { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; margin: 0; font-size: 14px; }
dl.summary dt { font-weight: 600; color: var(--text-muted); white-space: nowrap; }
dl.summary dd { margin: 0; }
dl.summary ul { margin: 0; padding-left: 16px; }
dl.summary li { margin-bottom: 2px; }

/* ===== Colonne copertina / finale (step 2 del wizard) =====
   Affianca i due editor invece di impilarli: dimezza l'altezza della pagina
   quando entrambe le slide sono caricate. Si sposta su una colonna sola
   quando lo spazio non basta (flex-wrap, nessun breakpoint fisso). */
/* Sempre affiancate su desktop (50/50, senza andare a capo per mancanza di
   spazio); solo sotto i 900px passano in colonna, come il resto dell'app. */
.slide-cols { display: flex; gap: 22px; align-items: flex-start; }
.slide-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 16px; }

/* Anteprima statica (panoramica): miniatura con altezza fissa + pulsante di editing.
   Nessun legame con la matematica di posizionamento testi (che vive solo in .ed-stage). */
.slide-preview { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.slide-preview-frame {
  background: #000; border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  height: 160px; display: flex; align-items: center; justify-content: center;
}
.slide-thumb { max-width: 100%; max-height: 100%; display: block; }
.slide-preview-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.slide-preview-actions .btn-row { margin-right: 0; }

/* Vista di editing a piena larghezza (una slide alla volta) */
.slide-edit-view { display: flex; flex-direction: column; gap: 14px; }
.ed-view-head { display: flex; align-items: center; gap: 16px; }
.ed-view-head strong { font-size: 14px; color: var(--text-muted); }
.ed-view-head .ed-save-tpl { margin-left: auto; }

/* ===== Editor testi slide (copertina / finale) =====
   Posizione/dimensione/eliminazione si controllano con maniglie sul canvas;
   colore/font/allineamento/grassetto dal pannello "livelli" sotto. */
.slide-editor {
  border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 14px; background: var(--surface-2);
}
.ed-stage {
  position: relative; background: #000; border-radius: 8px; overflow: hidden;
  user-select: none; touch-action: none;
}
.ed-stage .ed-img { display: block; width: 100%; pointer-events: none; }
.ed-item {
  position: absolute; transform: translate(-50%, -50%);
  white-space: pre; line-height: 1.25; cursor: grab;
  text-shadow: 0 2px 8px rgba(0,0,0,.55);
  border: 1px dashed transparent; padding: 2px 6px; outline: none;
}
.ed-item:hover { border-color: rgba(255,255,255,.4); }
.ed-item.selected { border-color: var(--accent); cursor: text; }
/* In scrittura diretta: consente la selezione testo nonostante lo stage abbia
   user-select:none (serve per il drag) e segnala lo stato con bordo pieno. */
.ed-item.editing {
  cursor: text; border-style: solid;
  user-select: text; -webkit-user-select: text; touch-action: auto;
}

/* Maniglie di ridimensionamento/eliminazione: non figlie del testo (che è
   contenteditable), ma elementi condivisi dello stage riposizionati sopra
   l'elemento selezionato — evita che finiscano nel contenuto scritto. */
.ed-stage-handle {
  position: absolute; width: 26px; height: 26px; border-radius: 50%; padding: 0;
  display: none; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.4); cursor: pointer; z-index: 5;
  transform: translate(-50%, -50%);
}
.ed-stage-handle svg { width: 13px; height: 13px; pointer-events: none; }
.ed-stage-handle.visible { display: flex; }
.ed-del-handle { background: var(--danger); }
.ed-resize-handle { cursor: nwse-resize; }

/* Pannello livelli (stile Illustrator): un rigo per testo, con selezione
   bidirezionale canvas↔elenco e i controlli di colore/font/allineamento/grassetto. */
.ed-layers { display: flex; flex-direction: column; gap: 10px; }
.ed-layers-head { display: flex; align-items: center; justify-content: space-between; }
.ed-layers-head strong { font-size: 14px; color: var(--text-muted); }
.ed-layer-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ed-layer {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  background: var(--input-bg); border: 1px solid var(--border); border-radius: 9px;
  padding: 5px 7px;
}
.ed-layer.active { border-color: var(--accent); background: var(--accent-soft); }
.ed-layer-select {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0;
  background: transparent; border: 0; color: var(--text); cursor: pointer; padding: 4px;
  font-family: inherit; font-size: 13px; text-align: left;
}
.ed-layer-select svg { width: 15px; height: 15px; flex: 0 0 auto; color: var(--text-dim); }
.ed-layer-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-layer-pos { display: flex; gap: 5px; flex: 0 0 auto; }
.ed-pos-field {
  display: flex; flex-direction: row; align-items: center; gap: 3px; flex: 0 0 auto;
  font-size: 11px; font-weight: 700; color: var(--text-dim);
}
.ed-pos-field input {
  width: 52px; padding: 4px 5px; font-size: 12px; border-radius: 6px;
  border: 1px solid var(--border-strong); background: var(--input-bg); color: var(--text); font-family: inherit;
}
.ed-layer-color {
  width: 26px; height: 26px; padding: 2px; flex: 0 0 auto;
  border: 1px solid var(--border-strong); border-radius: 6px; background: var(--input-bg); cursor: pointer;
}
.ed-layer-font { flex: 0 0 auto; width: 116px; font-size: 12px; padding: 5px 6px; }
.ed-layer-align { display: flex; gap: 2px; flex: 0 0 auto; }
.ed-align-btn, .ed-bold-btn, .ed-layer-del {
  width: 26px; height: 26px; border-radius: 6px; flex: 0 0 auto; padding: 0;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-muted);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; font-family: inherit;
}
.ed-align-btn svg { width: 14px; height: 14px; }
.ed-align-btn.active, .ed-bold-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.ed-layer-del { color: var(--err); }
.ed-layer-del:hover { background: var(--err-bg); border-color: var(--err); }
.ed-layers-empty { margin: 0; }

/* ===== Overlay avanzamento (upload / generazione) ===== */
.busy-overlay {
  position: fixed; inset: 0; z-index: 90; background: var(--scrim);
  display: flex; align-items: center; justify-content: center;
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.busy-overlay[hidden] { display: none; }
.busy-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); padding: 30px 34px; width: min(420px, 90vw);
  display: flex; flex-direction: column; gap: 14px; text-align: center;
}
.busy-title { font-size: 15px; font-weight: 600; }
.busy-bar { height: 8px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.busy-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 6px; transition: width .15s linear; }
.busy-bar.indeterminate .busy-fill {
  width: 36%; animation: busy-slide 1.1s ease-in-out infinite;
}
@keyframes busy-slide {
  0% { margin-left: -36%; } 100% { margin-left: 100%; }
}
.busy-pct { font-size: 13px; color: var(--text-muted); min-height: 18px; }

/* ===== Toast ===== */
.toasts {
  position: fixed; top: 18px; right: 18px; z-index: 100;
  display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 36px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 11px;
  box-shadow: var(--shadow); padding: 12px 14px; font-size: 14px;
  animation: toast-in .22s ease-out;
}
.toast.leaving { opacity: 0; transform: translateX(12px); transition: all .25s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.toast-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex: 0 0 auto; }
.toast.success .toast-dot { background: var(--ok); }
.toast.error .toast-dot { background: var(--err); }
.toast.info .toast-dot { background: var(--accent); }
.toast-msg { flex: 1; }
.toast-close { background: transparent; border: 0; color: var(--text-dim); cursor: pointer; font-size: 15px; padding: 0 2px; line-height: 1.4; }
.toast-close:hover { color: var(--text); }

/* ===== Modale conferma ===== */
.modal-scrim {
  position: fixed; inset: 0; z-index: 95; background: var(--scrim);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); width: min(440px, 100%);
  padding: 24px 26px; display: flex; flex-direction: column; gap: 14px;
  animation: toast-in .18s ease-out;
}
.modal h3 { margin: 0; font-size: 16px; }
.modal p { margin: 0; color: var(--text-muted); font-size: 14px; white-space: pre-line; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ===== Ritaglio immagine (proporzioni standard) ===== */
.crop-modal { width: min(520px, 100%); }
.crop-ratios { display: flex; gap: 6px; flex-wrap: wrap; }
.crop-ratios button {
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text-muted); cursor: pointer; font-size: 13px; font-family: inherit;
}
.crop-ratios button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.crop-stage {
  position: relative; overflow: hidden; margin: 0 auto; background: #000;
  border-radius: 8px; cursor: grab; touch-action: none; user-select: none;
}
.crop-stage:active { cursor: grabbing; }
#crop-img { position: absolute; max-width: none; pointer-events: none; }
.crop-zoom-label { display: flex; flex-direction: row; align-items: center; gap: 10px; font-size: 13px; font-weight: 500; color: var(--text-muted); }
.crop-zoom-label input[type=range] { flex: 1; accent-color: var(--accent); }

/* ===== Modelli di slide (salvataggio/riuso di immagine + testi dall'editor) ===== */
.tpl-modal { width: min(640px, 100%); }
.tpl-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px;
  max-height: 50vh; overflow-y: auto; padding: 2px;
}
.tpl-card {
  display: flex; flex-direction: column; gap: 6px; padding: 8px; text-align: left;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface-2);
  cursor: pointer; font-family: inherit;
}
.tpl-card:hover { border-color: var(--accent); }
.tpl-card img { width: 100%; height: 90px; object-fit: cover; border-radius: 6px; background: #000; display: block; }
.tpl-card-name { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Pagina di gestione modelli (elenco + eliminazione) */
.tpl-manage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.tpl-manage-card {
  display: flex; flex-direction: column; gap: 10px; padding: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.tpl-manage-thumb {
  height: 140px; border-radius: 8px; overflow: hidden; background: #000;
  display: flex; align-items: center; justify-content: center;
}
.tpl-manage-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tpl-manage-body { display: flex; flex-direction: column; gap: 2px; }
.tpl-manage-body strong { font-size: 14px; }
.tpl-manage-body .muted { font-size: 12px; }
.tpl-del-form { margin: 0; }

/* ===== Archivio ===== */
.file-toolbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0; border-bottom: 0;
}
.search-box { position: relative; display: flex; align-items: center; }
.search-box svg { position: absolute; left: 10px; width: 15px; height: 15px; color: var(--text-dim); pointer-events: none; }
.search-box input { padding-left: 32px; padding-top: 8px; padding-bottom: 8px; font-size: 14px; width: 220px; }
.checkbox-label { display: flex; flex-direction: row; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; user-select: none; font-weight: 400; }
.checkbox-label input, .col-check input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }
.file-count { font-size: 13px; }
.bulk-btns { display: flex; gap: 8px; margin-left: auto; }

.file-table {
  width: 100%; border-collapse: collapse;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius); overflow: hidden;
}
.file-table thead th {
  text-align: left; padding: 11px 14px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.file-table tbody tr { border-bottom: 1px solid var(--border); }
.file-table tbody tr:last-child { border-bottom: 0; }
.file-table tbody tr:hover { background: var(--surface-2); }
.file-table td { padding: 12px 14px; font-size: 14px; vertical-align: middle; }

.col-check { width: 40px; }
.col-name { word-break: break-all; }
.file-icon { margin-right: 8px; }
.col-size { white-space: nowrap; color: var(--text-muted); min-width: 90px; }
.col-date { white-space: nowrap; color: var(--text-muted); min-width: 130px; }
.col-actions { white-space: nowrap; min-width: 240px; }

.btn-row {
  display: inline-flex; align-items: center; gap: 5px; text-decoration: none; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); border-radius: 7px;
  padding: 6px 12px; font-size: 13px; cursor: pointer; margin-right: 6px; font-family: inherit;
}
.btn-row:hover { border-color: var(--accent); color: var(--accent); }
.btn-row-danger:hover { border-color: var(--err); color: var(--err); background: var(--err-bg); }

.empty-state {
  text-align: center; padding: 60px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.empty-icon { font-size: 48px; opacity: .5; }
.empty-state p { margin: 0; font-size: 16px; color: var(--text-muted); }

/* ===== Anteprima ===== */
.preview-wrap { display: flex; gap: 20px; height: 100%; min-height: 0; }
.preview-left { flex: 1; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.preview-iframe-box {
  flex: 1; background: #000; border-radius: var(--radius); overflow: hidden;
  min-height: 480px; border: 1px solid var(--border);
}
.preview-iframe-box iframe { width: 100%; height: 100%; border: 0; display: block; min-height: 480px; }
.preview-aside { width: 320px; flex-shrink: 0; }
.preview-aside .card { gap: 14px; }
.btn-outline {
  display: block; text-align: center; text-decoration: none;
  border: 1px solid var(--border-strong); border-radius: 10px; padding: 12px 18px;
  font-size: 14px; color: var(--text-muted);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

/* ===== Alert inline (login) ===== */
.alert { padding: 12px 14px; border-radius: 9px; font-size: 14px; }
.alert.error { background: var(--err-bg); border: 1px solid var(--err-border); color: var(--err); }
.alert.success { background: var(--ok-bg); border: 1px solid var(--ok-border); color: var(--ok); }

/* ===== Login ===== */
.login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 34px 32px; width: 380px; max-width: 100%; display: flex; flex-direction: column; gap: 16px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.login-brand h1 { margin: 0; font-size: 20px; }
.login-brand small { display: block; font-size: 12px; font-weight: 500; color: var(--text-dim); }
.login-card p { margin: 0; font-size: 14px; color: var(--text-muted); }
.captcha-row { display: flex; align-items: center; gap: 10px; }
.captcha-row img { border-radius: 8px; border: 1px solid var(--border); display: block; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: var(--shadow);
  }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .btn-menu { display: inline-flex; }
  .app-body { padding: 18px 16px 34px; }
  .app-header { padding: 12px 16px; }

  .stepper { flex-wrap: wrap; }
  .stepper .step { flex: 1 1 44%; }
  .stepper .step-label { font-size: 12px; }
  .row { flex-direction: column; }
  .mode-cards { flex-direction: column; }
  .slide-cols { flex-direction: column; }

  .preview-wrap { flex-direction: column; height: auto; }
  .preview-aside { width: 100%; }
  .preview-iframe-box, .preview-iframe-box iframe { min-height: 56vw; }

  .col-date, .col-size { display: none; }
  .bulk-btns { margin-left: 0; width: 100%; }
  .search-box input { width: 100%; }
  .search-box { flex: 1 1 100%; }
}
