/* =========================================================================
   Synectis Academy — foglio di stile principale
   Palette ispirata al layout mostrato negli screenshot di riferimento:
   navbar/sidebar blu, card bianche con ombra leggera, badge di stato,
   barre punteggio colorate (rosso/giallo/verde).
   ========================================================================= */

:root {
    --brand-blue: #1565c0;
    --brand-blue-dark: #0d47a1;
    --brand-blue-light: #e3f0fd;
    --bg: #f2f4f7;
    --card-bg: #ffffff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --red: #e53935;
    --yellow: #fbc02d;
    --green: #43a047;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

a { color: var(--brand-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Topbar ---------- */
.topbar {
    background: var(--brand-blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar .brand { font-size: 18px; font-weight: 700; letter-spacing: .3px; color: #fff; }
.topbar .brand small { display: block; font-size: 10px; font-weight: 400; opacity: .8; }
.topbar .user-menu { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.topbar .user-menu .avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: #fff; color: var(--brand-blue);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px;
}
.topbar .logout-link { color: #fff; opacity: .85; }
.topbar .user-profile-link {
    display: flex; align-items: center; gap: 10px; color: #fff;
    padding: 4px 8px; border-radius: 6px;
}
.topbar .user-profile-link:hover { background: rgba(255,255,255,.15); text-decoration: none; }
.topbar .notif-bell { position: relative; cursor: pointer; font-size: 18px; }
.topbar .notif-bell .dot {
    position: absolute; top: -3px; right: -3px;
    width: 9px; height: 9px; border-radius: 50%;
    background: #ff5252; border: 2px solid var(--brand-blue);
    display: none;
}
.topbar .notif-bell.has-new .dot { display: block; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: calc(100vh - 56px); }

.sidebar {
    width: 230px;
    background: #fff;
    border-right: 1px solid var(--border);
    padding: 18px 12px;
    flex-shrink: 0;
}
.btn-crea-nuovo {
    display: block; width: 100%; text-align: center;
    background: var(--brand-blue); color: #fff;
    border: none; border-radius: 6px;
    padding: 11px 10px; font-weight: 600; font-size: 13px;
    cursor: pointer; margin-bottom: 18px;
    letter-spacing: .3px;
}
.btn-crea-nuovo:hover { background: var(--brand-blue-dark); text-decoration: none; }

.sidebar nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 6px;
    color: var(--text); font-size: 13.5px; font-weight: 500;
    margin-bottom: 2px;
}
.sidebar nav a:hover { background: var(--brand-blue-light); text-decoration: none; }
.sidebar nav a.active { background: var(--brand-blue-light); color: var(--brand-blue-dark); font-weight: 700; }
.sidebar nav a .icon { width: 18px; text-align: center; }

.main { flex: 1; padding: 24px; min-width: 0; }

/* ---------- Card ---------- */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}
.card h2, .card h3 { margin-top: 0; }
.card-title { font-size: 15px; font-weight: 700; color: var(--brand-blue-dark); margin: 0 0 14px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .sidebar { display: none; }
}

/* ---------- Stat tiles ---------- */
.stat-row { display: flex; gap: 24px; margin-bottom: 16px; flex-wrap: wrap; }
.stat-tile { flex: 1; min-width: 110px; text-align: center; }
.stat-tile .num { font-size: 26px; font-weight: 700; color: var(--text); }
.stat-tile .label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-top: 2px; }

/* ---------- Gauge (arco punteggio medio) ---------- */
.gauge-wrap { text-align: center; }
.gauge { position: relative; width: 220px; height: 130px; margin: 0 auto; }
.gauge svg { width: 100%; height: 100%; }
.gauge .gauge-value {
    position: absolute; bottom: 6px; left: 0; right: 0;
    text-align: center; font-size: 28px; font-weight: 700;
}

/* ---------- Score bar (elenco svolgimenti) ---------- */
.score-bar-wrap { display: flex; align-items: center; gap: 8px; min-width: 140px; }
.score-bar-track { flex: 1; height: 8px; border-radius: 4px; background: #eef0f3; overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: 4px; }
.score-red .score-bar-fill { background: var(--red); }
.score-yellow .score-bar-fill { background: var(--yellow); }
.score-green .score-bar-fill { background: var(--green); }
.score-bar-pct { font-size: 12px; font-weight: 600; width: 38px; text-align: right; }

/* ---------- Badge stato ---------- */
.badge { display: inline-block; padding: 4px 10px; border-radius: 4px; font-size: 11px; font-weight: 700; letter-spacing: .3px; }
.badge-pass { background: #e2f4e6; color: #1e7e34; }
.badge-fail { background: #fdeaea; color: #c62828; }
.badge-progress { background: #fff4e0; color: #b26a00; }
.badge-draft { background: #eceff1; color: #546e7a; }
.badge-published { background: #e2f4e6; color: #1e7e34; }
.badge-archived { background: #eceff1; color: #546e7a; }

/* ---------- Tabelle ---------- */
table.data-table { width: 100%; border-collapse: collapse; }
table.data-table th {
    text-align: left; font-size: 11px; text-transform: uppercase;
    color: var(--text-muted); border-bottom: 1px solid var(--border);
    padding: 10px 8px; letter-spacing: .4px;
}
table.data-table td { padding: 12px 8px; border-bottom: 1px solid #f1f2f4; vertical-align: middle; }
table.data-table tr:hover td { background: #fafbfc; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--border);
    background: #fff; color: var(--text-muted); cursor: pointer; margin-left: 4px;
}
.icon-btn:hover { background: var(--brand-blue-light); color: var(--brand-blue-dark); text-decoration: none; }

/* ---------- Form ---------- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
input[type=text], input[type=number], input[type=password], input[type=email],
input[type=datetime-local], textarea, select {
    width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 13.5px; font-family: inherit; background: #fff; color: var(--text);
}
textarea { resize: vertical; min-height: 70px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand-blue); }

.btn {
    display: inline-block; border: none; border-radius: 6px; padding: 10px 18px;
    font-size: 13.5px; font-weight: 600; cursor: pointer; text-align: center;
}
.btn-primary { background: var(--brand-blue); color: #fff; }
.btn-primary:hover { background: var(--brand-blue-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: #eceff1; color: var(--text); }
.btn-secondary:hover { background: #dfe3e6; text-decoration: none; }
.btn-danger { background: #fdeaea; color: #c62828; }
.btn-danger:hover { background: #fadada; text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

label.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-weight: 400; }
.toggle input { display: none; }
.toggle .switch {
    display: inline-block; width: 38px; height: 21px; border-radius: 11px; background: #cfd4d9; position: relative; transition: .15s;
    flex-shrink: 0;
}
.toggle .toggle-label-text { flex: 1; }
.toggle .switch::after {
    content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px;
    background: #fff; border-radius: 50%; transition: .15s;
}
.toggle input:checked + .switch { background: var(--brand-blue); }
.toggle input:checked + .switch::after { left: 19px; }

fieldset.settings-section { border: 1px solid var(--border); border-radius: 8px; padding: 16px 18px; margin-bottom: 16px; }
fieldset.settings-section legend { font-weight: 700; font-size: 13.5px; color: var(--brand-blue-dark); padding: 0 6px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tabs a { padding: 10px 16px; font-weight: 600; font-size: 13.5px; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tabs a.active { color: var(--brand-blue-dark); border-color: var(--brand-blue); }

/* ---------- Alerts / flash ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 13.5px; }
.alert-success { background: #e2f4e6; color: #1e7e34; }
.alert-error { background: #fdeaea; color: #c62828; }
.alert-info { background: var(--brand-blue-light); color: var(--brand-blue-dark); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--brand-blue), var(--brand-blue-dark)); }
.login-card { background: #fff; border-radius: 12px; padding: 40px 36px; width: 360px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.login-card .brand { text-align: center; font-size: 22px; font-weight: 800; color: var(--brand-blue-dark); margin-bottom: 4px; }
.login-card .brand small { display: block; font-size: 12px; font-weight: 400; color: var(--text-muted); margin-bottom: 24px; }

/* ---------- Answer review (dettaglio svolgimento) ---------- */
.answer-block { border-left: 5px solid var(--border); border-radius: 6px; background: #fafbfc; padding: 14px 16px; margin-bottom: 14px; }
.answer-block.correct { border-color: var(--green); background: #f2faf3; }
.answer-block.wrong { border-color: var(--red); background: #fdf4f4; }
.answer-block .q-points { float: right; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 4px; }
.answer-block.correct .q-points { background: #e2f4e6; color: #1e7e34; }
.answer-block.wrong .q-points { background: #fdeaea; color: #c62828; }
.answer-option { padding: 6px 10px; border-radius: 5px; margin-top: 6px; font-size: 13.5px; }
.answer-option.opt-correct-checked { background: #e2f4e6; color: #1e7e34; font-weight: 600; }
.answer-option.opt-correct-missed { background: #eef8f0; color: #1e7e34; border: 1px dashed #7cc493; }
.answer-option.opt-wrong-checked { background: #fdeaea; color: #c62828; font-weight: 600; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 40px; margin-bottom: 10px; }

/* ---------- Public quiz-taking page ---------- */
.public-wrap { max-width: 720px; margin: 0 auto; padding: 30px 16px 60px; }
.public-header { text-align: center; margin-bottom: 24px; }
.public-header .brand { color: var(--brand-blue-dark); font-weight: 800; font-size: 20px; }
.timer-box {
    position: sticky; top: 10px; z-index: 20; background: #fff; border-radius: 8px;
    box-shadow: var(--shadow); padding: 10px 16px; text-align: center; font-weight: 700;
    color: var(--brand-blue-dark); margin-bottom: 20px;
}
.timer-box.low-time { color: var(--red); }
.question-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 16px; }
.question-card .q-index { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.question-card .q-text { font-weight: 600; font-size: 15px; margin-bottom: 14px; }
.option-choice { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; cursor: pointer; }
.option-choice:hover { border-color: var(--brand-blue); background: var(--brand-blue-light); }
.option-choice input { margin-top: 3px; }

.progress-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; }

/* ---------- Print / PDF report ---------- */
@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
    .card { box-shadow: none; }
}
.print-toolbar { position: sticky; top: 0; background: #fff; padding: 10px 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; text-align: right; }
.report-page { page-break-after: always; padding-bottom: 30px; }
.report-page:last-child { page-break-after: auto; }
