/* Elezioni ITT Jannuzzi - stile unico, pensato prima per lo smartphone */

:root {
    --bg: #f4f6fa;
    --surface: #ffffff;
    --text: #1d2433;
    --muted: #5f6b7d;
    --border: #dde2ea;
    --primary: #1f5fbf;
    --primary-dark: #174a96;
    --primary-soft: #e8f0fc;
    --ok: #237a52;
    --ok-soft: #e3f4ec;
    --warn: #9a6200;
    --warn-soft: #fdf1dc;
    --danger: #b3303a;
    --danger-soft: #fbe6e8;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 4px 16px rgba(20, 30, 50, .05);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #11151d;
        --surface: #1b2230;
        --text: #e6e9ef;
        --muted: #9aa5b5;
        --border: #2c3546;
        --primary: #5b95ec;
        --primary-dark: #7aaaf0;
        --primary-soft: #1d2d47;
        --ok: #5cc493;
        --ok-soft: #173327;
        --warn: #e5b45a;
        --warn-soft: #3a2e17;
        --danger: #ef7a83;
        --danger-soft: #3d1e22;
        --shadow: none;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a { color: var(--primary); }
h1 { font-size: 1.6rem; line-height: 1.25; margin: .5rem 0 .25rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
code { background: var(--primary-soft); padding: .1em .35em; border-radius: 4px; font-size: .9em; }

.container { width: 100%; max-width: 960px; margin: 0 auto; padding: 1.25rem 1rem 3rem; flex: 1; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.narrow { max-width: 460px; margin-left: auto; margin-right: auto; }

/* --- Barra in alto --- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner {
    max-width: 960px; margin: 0 auto; padding: .7rem 1rem;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.brand { display: flex; align-items: center; gap: .6rem; color: var(--text); text-decoration: none; font-weight: 600; }
.brand-mark {
    background: var(--primary); color: #fff; font-size: .75rem; font-weight: 700;
    padding: .3rem .45rem; border-radius: 6px; letter-spacing: .04em;
}
.user { display: flex; align-items: center; gap: .6rem; }
.user form { margin: 0; }
.user-name { font-size: .875rem; color: var(--muted); text-align: right; }
.adminnav {
    max-width: 960px; margin: 0 auto; padding: 0 1rem;
    display: flex; gap: 1.25rem; overflow-x: auto; white-space: nowrap;
}
.adminnav a { color: var(--muted); text-decoration: none; font-size: .9rem; padding: .55rem 0; border-bottom: 2px solid transparent; }
.adminnav a:hover { color: var(--primary); border-bottom-color: var(--primary); }

.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem; }

/* --- Card e griglie --- */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1.25rem; margin: 1rem 0;
}
.grid-2 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-2 > .card { margin: 0; } }
.grid-2 { margin: 1rem 0; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin: 1rem 0; }
.row form { margin: 0; }
.stack { display: grid; gap: .6rem; margin-top: 1.25rem; }

/* --- Pulsanti --- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    padding: .7rem 1.1rem; border-radius: 10px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font: inherit; font-weight: 600;
    text-decoration: none; cursor: pointer; min-height: 44px;
}
.btn:hover { border-color: var(--primary); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; }
.btn-small { padding: .35rem .7rem; min-height: 34px; font-size: .875rem; }
.btn-block { width: 100%; margin-top: .75rem; }

/* --- Login --- */
.login { display: grid; place-items: center; min-height: 60vh; }
.login-card { max-width: 420px; width: 100%; text-align: center; padding: 2rem 1.5rem; }
.btn-google { width: 100%; margin: 1.5rem 0 1rem; background: var(--surface); }

/* --- Elezioni (home studente) --- */
.election { display: flex; flex-direction: column; }
.election p { flex: 1; }
.election .badge { align-self: flex-start; }
.election-classe { border-top: 4px solid var(--primary); }
.election-provincia { border-top: 4px solid #e8913a; }

/* --- Badge e avvisi --- */
.badge {
    display: inline-block; font-size: .78rem; font-weight: 600; padding: .2rem .55rem;
    border-radius: 999px; background: var(--primary-soft); color: var(--primary); vertical-align: middle;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-live { background: var(--ok); color: #fff; }

.alert { padding: .8rem 1rem; border-radius: 10px; margin: 1rem 0; border: 1px solid transparent; }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.alert-errore { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.alert-info { background: var(--primary-soft); color: var(--text); border-color: var(--primary); }

/* --- Scheda di voto --- */
.option {
    display: flex; align-items: center; gap: .8rem; padding: .85rem 1rem; margin: .5rem 0;
    border: 1px solid var(--border); border-radius: 10px; cursor: pointer; background: var(--surface);
}
.option:hover { border-color: var(--primary); }
.option:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.option input { width: 1.2rem; height: 1.2rem; accent-color: var(--primary); flex-shrink: 0; }
.option-name { flex: 1; font-weight: 500; }
.option-meta { color: var(--muted); font-size: .875rem; }
.option-blank { border-style: dashed; margin-top: 1rem; }
.choice { font-size: 1.4rem; font-weight: 700; margin: 1.25rem 0; }
.checklist { display: grid; gap: 0 .75rem; grid-template-columns: 1fr; margin-bottom: 1rem; }
@media (min-width: 720px) { .checklist { grid-template-columns: 1fr 1fr; } }

/* --- Pannello admin --- */
.status { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; }
.status p { margin: 0; }
.status form { margin: 0; }
.status-label { font-size: 1.3rem; font-weight: 700; }
.status-aperta { border-left: 5px solid var(--ok); }
.status-bozza { border-left: 5px solid var(--primary); }
.status-chiusa { border-left: 5px solid var(--muted); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin: 1rem 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.stat-value { display: block; font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: .85rem; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .6rem .5rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; font-size: .82rem; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tfoot th { color: var(--text); border-bottom: 0; }

progress.bar {
    width: 90px; height: 8px; vertical-align: middle; border: 0; border-radius: 99px;
    background: var(--border); overflow: hidden; appearance: none;
}
progress.bar::-webkit-progress-bar { background: var(--border); border-radius: 99px; }
progress.bar::-webkit-progress-value { background: var(--primary); border-radius: 99px; }
progress.bar::-moz-progress-bar { background: var(--primary); border-radius: 99px; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.list li form { margin: 0; }

input[type="search"], input[type="file"], select {
    font: inherit; color: var(--text); background: var(--surface);
    border: 1px solid var(--border); border-radius: 10px; padding: .6rem .8rem; min-height: 44px;
}
input[type="search"] { width: 100%; margin-bottom: .75rem; }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { border: 1px solid var(--border); border-radius: 999px; padding: .25rem .7rem; font-size: .875rem; }
.errors { max-height: 320px; overflow-y: auto; font-size: .875rem; color: var(--danger); padding-left: 1.2rem; }

/* --- Risultati --- */
.result { display: grid; gap: 1.5rem; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 720px) { .result { grid-template-columns: minmax(240px, 320px) 1fr; } }
.result-chart { max-width: 320px; margin: 0 auto; width: 100%; }
.details summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.details[open] summary { margin-bottom: 1rem; }

.error-code { font-size: 3rem; font-weight: 800; color: var(--primary); margin: 0; }
