/* OftaAid ECM — design system VIEMME (tema scuro, accento arancio). Niente stili inline: la CSP li blocca. */

:root {
    --bg: #0b0f14;
    --panel: rgba(255,255,255,0.06);
    --panel-strong: rgba(255,255,255,0.1);
    --panel-solid: #14181f;
    --text: #e8edf2;
    --muted: #a9b6c6;
    --brand: #ff7f00;
    --brand-2: #7d5cff;
    --ring: rgba(255,255,255,0.12);
    --shadow: 0 10px 30px rgba(0,0,0,0.3);
    --radius: 16px;
    --radius-sm: 12px;
    --maxw: 1200px;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background:
        radial-gradient(1200px 600px at 90% -10%, rgba(255,127,0,0.09), transparent 60%),
        radial-gradient(900px 500px at -10% 10%, rgba(125,92,255,0.12), transparent 60%),
        var(--bg);
    background-attachment: fixed;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.25; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 12px; }
code { background: var(--panel-strong); padding: 1px 6px; border-radius: 6px; }

.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding: 0 24px; }
.main { flex: 1; padding-top: 32px; padding-bottom: 32px; }
.muted { color: var(--muted); }
.sm { font-size: 0.85rem; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.upper { text-transform: uppercase; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.eyebrow { color: var(--brand); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; margin: 0 0 8px; }
.inline-form { display: inline; margin: 0; }
.offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }

/* HEADER / FOOTER */
.header {
    position: sticky; top: 0; z-index: 50;
    background: linear-gradient(to bottom, rgba(11,15,20,0.92), rgba(11,15,20,0.65));
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--ring);
}
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 12px; color: var(--text); font-weight: 700; }
.logo:hover { text-decoration: none; }
/* logo ufficiale OftaAid (versione negativa, per fondo scuro); "ECM" accanto distingue l'app dal sito */
.logo-img { display: block; height: 40px; width: auto; flex: none; }
.login-logo-img { display: block; height: 70px; width: auto; margin: 0 auto 12px; }
.logo-title { padding-left: 12px; border-left: 1px solid var(--ring); color: var(--muted); letter-spacing: 0.06em; }
.logo-version { padding-left: 12px; }
.logo-text { display: flex; flex-direction: column; line-height: 1.15; }
.logo-version { color: var(--muted); font-size: 0.72rem; font-weight: 500; }
.nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.nav a { color: var(--muted); font-size: 0.9rem; }
.nav a:hover, .nav a.active { color: var(--text); text-decoration: none; }
.nav-user { color: var(--muted); font-size: 0.85rem; }
.footer { display: flex; justify-content: space-between; gap: 12px; padding-top: 16px; padding-bottom: 24px; color: var(--muted); font-size: 0.8rem; border-top: 1px solid var(--ring); }

/* CARD */
.card {
    background: var(--panel);
    border: 1px solid var(--ring);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}
.card.narrow { max-width: 640px; margin-inline: auto; }
.card.quiz { max-width: 820px; margin-inline: auto; }
.login-card { max-width: 420px; margin: 40px auto; }
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo h1 { margin: 0; }

/* BUTTON */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 16px; border-radius: var(--radius-sm);
    border: 1px solid var(--ring); background: var(--panel-strong); color: var(--text);
    font-size: 0.9rem; font-family: inherit; cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: opacity 0.2s, transform 0.1s;
}
.btn:hover { opacity: 0.88; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.brand { background: linear-gradient(135deg, var(--brand), #ffb266); color: #111; border-color: transparent; font-weight: 600; }
.btn.danger { background: rgba(239,68,68,0.15); color: #fca5a5; border-color: rgba(239,68,68,0.45); font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 0.8rem; }
.btn.block { display: flex; width: 100%; padding: 14px 18px; font-size: 1rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* FORM */
.form-group { margin-bottom: 16px; }
.form-label { display: block; color: var(--muted); font-size: 0.85rem; margin-bottom: 6px; }
.form-input {
    width: 100%; padding: 11px 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--ring); background: rgba(0,0,0,0.25); color: var(--text);
    font-size: 1rem; font-family: inherit;
}
.form-input:focus { outline: none; border-color: var(--brand); }
.form-input.invalid { border-color: var(--danger); }
.field-error { color: #fca5a5; font-size: 0.82rem; margin: 6px 0 0; }
.form-checkbox { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 0.9rem; }
.form-checkbox input { margin-top: 4px; accent-color: var(--brand); width: 18px; height: 18px; flex: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.copy-row { display: flex; gap: 8px; }
.copy-row .form-input { font-size: 0.9rem; }

/* PILL / TAG / ALERT */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--panel-strong); border: 1px solid var(--ring); font-size: 0.75rem; color: var(--text); white-space: nowrap; }
.pill.sm { font-size: 0.68rem; padding: 1px 7px; }
.pill.orange { background: rgba(255,127,0,0.18); color: #ffb266; border-color: rgba(255,127,0,0.4); }
.pill.purple { background: rgba(125,92,255,0.18); color: #b8a7ff; border-color: rgba(125,92,255,0.4); }
.pill.green { background: rgba(34,197,94,0.18); color: #86efac; border-color: rgba(34,197,94,0.4); }
.tag { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; font-size: 0.72rem; background: var(--panel-strong); color: var(--muted); vertical-align: middle; }
.tag.ok { background: rgba(34,197,94,0.18); color: #86efac; }
.alert { padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid var(--ring); }
.alert.danger { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.4); color: #fca5a5; }
.alert.success { background: rgba(34,197,94,0.12); border-color: rgba(34,197,94,0.4); color: #86efac; }

/* PROGRESS */
progress.bar { appearance: none; -webkit-appearance: none; width: 100%; height: 8px; border: 0; border-radius: 999px; background: var(--panel-strong); overflow: hidden; margin: 8px 0 20px; }
progress.bar::-webkit-progress-bar { background: var(--panel-strong); border-radius: 999px; }
progress.bar::-webkit-progress-value { background: linear-gradient(90deg, var(--brand), #ffb266); border-radius: 999px; }
progress.bar::-moz-progress-bar { background: linear-gradient(90deg, var(--brand), #ffb266); border-radius: 999px; }
progress.bar.sm { height: 6px; width: 90px; margin: 0 8px 0 0; vertical-align: middle; }

/* PARTECIPANTE */
.rules { margin: 0 0 20px; padding-left: 20px; color: var(--muted); }
.rules li { margin-bottom: 4px; }
.rules strong { color: var(--text); }
.course-list { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 10px; }
.quiz-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.question-text { font-size: 1.25rem; font-weight: 600; margin-bottom: 20px; }
.options { display: grid; gap: 10px; margin-bottom: 16px; }
.option {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 16px; border-radius: var(--radius-sm);
    border: 1px solid var(--ring); background: rgba(0,0,0,0.2);
    cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.options:not(.readonly) .option:hover { border-color: rgba(255,127,0,0.5); }
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option:has(input:checked) { border-color: var(--brand); background: rgba(255,127,0,0.12); }
.option:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.option-letter {
    flex: none; width: 28px; height: 28px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--panel-strong); font-weight: 700; font-size: 0.85rem;
}
.option:has(input:checked) .option-letter { background: var(--brand); color: #111; }
.option-text { padding-top: 3px; }
.options.readonly .option { cursor: default; }
.option.is-correct { border-color: rgba(34,197,94,0.6); background: rgba(34,197,94,0.1); }
.option.is-correct .option-letter { background: var(--success); color: #062b12; }
.option.is-wrong { border-color: rgba(239,68,68,0.6); background: rgba(239,68,68,0.1); }
.option.is-wrong .option-letter { background: var(--danger); color: #fff; }
.verdict { font-weight: 700; padding: 4px 12px; border-radius: 999px; font-size: 0.85rem; }
.verdict.ok { background: rgba(34,197,94,0.18); color: #86efac; }
.verdict.ko { background: rgba(239,68,68,0.18); color: #fca5a5; }
.explain { border-left: 3px solid var(--brand); background: rgba(255,127,0,0.06); padding: 12px 16px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-bottom: 20px; }
.explain p:last-child { margin-bottom: 0; }
.done-mark { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 32px; background: rgba(34,197,94,0.18); color: #86efac; }

/* ADMIN */
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-header h1 { margin: 0; }
.back-link { display: inline-block; color: var(--muted); margin-bottom: 16px; font-size: 0.9rem; }
.course-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.course-title { font-size: 1.35rem; }
.share { display: flex; gap: 20px; align-items: flex-start; padding: 16px; border: 1px solid var(--ring); border-radius: var(--radius-sm); background: rgba(0,0,0,0.18); margin-bottom: 20px; }
.qr { width: 148px; height: 148px; border-radius: 10px; background: #fff; padding: 6px; flex: none; }
.share-body { flex: 1; min-width: 0; }
.stats { display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap; margin-bottom: 16px; }
.stat { display: flex; flex-direction: column; padding: 10px 16px; min-width: 120px; border: 1px solid var(--ring); border-radius: var(--radius-sm); background: rgba(0,0,0,0.18); }
.stat-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 0.8rem; }
.live { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.live-dot.on { background: var(--success); box-shadow: 0 0 0 0 rgba(34,197,94,0.6); animation: pulse 2s infinite; }
.live-dot.off { background: var(--danger); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(34,197,94,0.55); } 70% { box-shadow: 0 0 0 8px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }
@media (prefers-reduced-motion: reduce) { .live-dot.on { animation: none; } }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th, .data-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--ring); vertical-align: middle; }
.data-table th { color: var(--muted); font-weight: 500; font-size: 0.8rem; white-space: nowrap; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr.flash td { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: rgba(255,127,0,0.18); } to { background: transparent; } }
.progress-cell { white-space: nowrap; }
.actions { white-space: nowrap; text-align: right; }
.coming-soon { border-style: dashed; opacity: 0.75; }
.coming-soon h2::after { content: 'Coming soon'; margin-left: 10px; padding: 2px 8px; border-radius: 999px; font-size: 0.7rem; font-weight: 500; vertical-align: middle; background: rgba(125,92,255,0.18); color: #b8a7ff; }
.question-review h3 { font-weight: 600; }
.review-options { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.review-options li { display: flex; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--ring); }
.review-options li.is-correct { border-color: rgba(34,197,94,0.6); background: rgba(34,197,94,0.08); }
.review-options li.is-correct .option-letter { background: var(--success); color: #062b12; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--panel-solid); border: 1px solid var(--ring); padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow); z-index: 100; font-size: 0.9rem; }

/* MOBILE */
@media (max-width: 640px) {
    .wrap { padding: 0 16px; }
    .main { padding-top: 20px; }
    .card { padding: 18px; border-radius: 14px; }
    .grid-2 { grid-template-columns: 1fr; }
    .question-text { font-size: 1.1rem; }
    .share { flex-direction: column; align-items: center; }
    .share-body { width: 100%; }
    .copy-row { flex-direction: column; }
    .live { margin-left: 0; }
    .nav { gap: 12px; }
}
