/* ==========================================================================
   Design system — Piattaforma di selezione
   Token, tipografia e componenti condivisi (candidato + area riservata).
   ========================================================================== */

:root {
  /* Superfici e testo */
  --bg:         #f6f7f9;
  --card:       #ffffff;
  --ink:        #0f172a;
  --ink-soft:   #64748b;
  --ink-mute:   #94a3b8;
  --line:       #e6e9ef;
  --line-strong:#cfd6e2;

  /* Accento (sovrascrivibile dal branding del tenant) */
  --brand:       #4f46e5;
  --brand-ink:   #ffffff;
  --brand-soft:  #eef1ff;
  --brand-strong:#4338ca;

  /* Semantici */
  --ok: #16a34a;  --ok-soft: #e8f7ee;
  --warn: #b45309; --warn-soft: #fdf3e3;
  --danger: #dc2626; --danger-soft: #fdecec;

  /* Forma */
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.05);
  --shadow:    0 1px 2px rgba(15,23,42,.04), 0 4px 16px rgba(15,23,42,.06);
  --shadow-lg: 0 2px 4px rgba(15,23,42,.04), 0 12px 32px rgba(15,23,42,.10);
  --ring: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117; --card: #161b26; --ink: #e8ecf4; --ink-soft: #97a1b4; --ink-mute: #6b7688;
    --line: #262d3b; --line-strong: #394254;
    --brand: #7c8cff; --brand-soft: #1b2140; --brand-strong: #93a0ff;
    --ok-soft: #10251a; --warn-soft: #2a2010; --danger-soft: #2a1416;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.35);
    --shadow-lg: 0 2px 6px rgba(0,0,0,.4), 0 16px 40px rgba(0,0,0,.45);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { letter-spacing: -.015em; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 700; margin: 0 0 10px; }
h2 { font-size: 18px; font-weight: 650; margin: 0 0 12px; }
h3 { font-size: 15px; font-weight: 650; }
a { color: var(--brand); }

.app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Barra superiore (pagine candidato) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--header-bg, color-mix(in srgb, var(--card) 90%, transparent));
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { color: var(--header-text, inherit); }
.brand-logo { max-height: 34px; max-width: 200px; display: block; object-fit: contain; }
.brand-banner { display: block; width: 100%; height: auto; }
.topbar-inner {
  max-width: 780px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; gap: 16px; justify-content: space-between;
}
.brand { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.progress-wrap { display: flex; align-items: center; gap: 10px; flex: 1; max-width: 380px; }
.progress-track { flex: 1; height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--brand); border-radius: 999px; transition: width .3s ease; }
.progress-label { font-size: 12px; color: var(--ink-soft); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Contenuto ---------- */
.content { flex: 1; width: 100%; max-width: 780px; margin: 0 auto; padding: 32px 20px 72px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 26px 28px;
}
.card + .card { margin-top: 20px; }
.lead { font-size: 15.5px; color: var(--ink); margin: 0 0 12px; }
.note { font-size: 13.5px; color: var(--ink-soft); margin: 8px 0 0; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px;
}

/* ---------- Riquadro informativo ---------- */
.tips {
  background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 14%, var(--line));
  border-radius: var(--radius); padding: 16px 20px; margin: 20px 0 4px;
}
.tips > strong {
  display: block; margin-bottom: 8px; font-size: 11.5px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--brand); font-weight: 700;
}
.tips ul, .tips ol { margin: 0; padding-left: 20px; }
.tips li { margin: 5px 0; font-size: 14px; }

/* ---------- Moduli ---------- */
.fields { display: flex; flex-direction: column; gap: 18px; margin-top: 22px; }
.field-row { display: flex; gap: 16px; }
.field-row .field { flex: 1; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.field em, .consent em { color: var(--brand); font-style: normal; }
@media (max-width: 560px) { .field-row { flex-direction: column; gap: 18px; } }

/* Stile unico per tutti i controlli, anche fuori da .field */
input[type=text], input[type=email], input[type=tel], input[type=password],
input[type=search], input[type=url], select, textarea {
  font: inherit; font-size: 14.5px; width: 100%;
  padding: 10px 13px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); background: var(--card); color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { line-height: 1.6; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: var(--ring);
}
input::placeholder, textarea::placeholder { color: var(--ink-mute); }
input[type=file] {
  font: inherit; font-size: 13.5px; padding: 9px 12px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  background: var(--bg); width: 100%; cursor: pointer;
}
input[type=file]:hover { border-color: var(--brand); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%); background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.field.invalid input { border-color: var(--danger); }
.consent { display: flex; gap: 11px; align-items: flex-start; font-size: 14px; color: var(--ink-soft); }
.consent input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--brand); flex: 0 0 auto; }

/* ---------- Pulsanti ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-size: 14px; font-weight: 600; line-height: 1; cursor: pointer;
  padding: 10px 16px; border-radius: var(--radius-sm); text-decoration: none;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--ink);
  box-shadow: var(--shadow-sm); white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .05s ease;
}
.btn:hover { background: var(--bg); border-color: var(--brand); color: var(--brand); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--brand-ink); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); box-shadow: none; }
.btn-ghost:hover { background: var(--bg); color: var(--ink); border-color: transparent; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

/* ---------- Questionario ---------- */
.question-list { display: flex; flex-direction: column; gap: 16px; }
.question {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px 8px; background: var(--card);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.question:hover { border-color: var(--line-strong); }
.question.unanswered-flag { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.q-head { display: flex; gap: 11px; margin-bottom: 13px; }
.q-num {
  flex: 0 0 auto; min-width: 28px; height: 25px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-soft); color: var(--brand); border-radius: 7px;
  font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.q-text { font-size: 15.5px; font-weight: 600; line-height: 1.45; }
.q-options { display: flex; flex-direction: column; gap: 8px; padding-bottom: 14px; }
.opt {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  cursor: pointer; transition: background .12s ease, border-color .12s ease;
}
.opt:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); background: var(--brand-soft); }
.opt input { margin-top: 2px; accent-color: var(--brand); width: 17px; height: 17px; flex: 0 0 auto; }
.opt.checked { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.opt span { font-size: 14.5px; }

.nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; }
.done-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 22px 0 4px; }

/* ---------- Piè di pagina ---------- */
.footnote {
  text-align: center; color: var(--footer-text, var(--ink-soft));
  background: var(--footer-bg, transparent); font-size: 12.5px; padding: 24px 20px;
}
.footnote a { color: var(--footer-text, var(--brand)); text-decoration: none; }
.footnote a:hover { text-decoration: underline; }

/* Copy-block: niente selezione/copia del testo del questionario */
#questionStep { user-select: none; -webkit-user-select: none; }
