/*
 * Grafica del gestionale (design system "Sports Team/Club" di UI UX Pro Max):
 * stile a blocchi, verde campo + oro coppa, titoli Barlow Condensed, testo Barlow.
 * File statico in public/: non serve npm run build.
 */

:root {
    --primary: #15803d;
    --primary-strong: #166534;
    --primary-deep: #052e16;
    --primary-soft: #dcfce7;
    --accent: #f59e0b;
    --accent-soft: #fef3c7;
    --bg: #f3f6f4;
    --surface: #ffffff;
    --surface-2: #f8faf9;
    --text: #0f172a;
    --muted: #475569;
    --line: #e2e8f0;
    --danger: #b91c1c;
    --danger-soft: #fee2e2;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
    --font-display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
    --font-body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
    --nav-h: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
}
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--primary-strong); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.15; letter-spacing: .01em; }
h1 { font-size: 2rem; margin: 0 0 4px; text-transform: uppercase; }
h2 { font-size: 1.375rem; margin: 0 0 12px; }
h3 { font-size: 1.125rem; margin: 0; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.icon { width: 20px; height: 20px; flex: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Testata ---------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    background: linear-gradient(135deg, var(--primary-deep), var(--primary-strong));
    color: #fff;
    box-shadow: 0 2px 12px rgba(5, 46, 22, .25);
}
.topbar-inner {
    max-width: 1100px; margin: 0 auto; padding: 10px 16px;
    display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; min-width: 0; }
.brand:hover { color: #fff; }
.brand-mark {
    width: 40px; height: 40px; border-radius: 12px; flex: none;
    display: grid; place-items: center;
    background: var(--accent); color: var(--primary-deep);
}
.brand-mark .icon { width: 24px; height: 24px; }
.brand-name {
    font-family: var(--font-display); font-weight: 700; font-size: 1.375rem;
    text-transform: uppercase; letter-spacing: .03em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topnav { display: flex; gap: 4px; margin-left: 12px; }
.topnav a {
    display: flex; white-space: nowrap; align-items: center; gap: 8px;
    min-height: 44px; padding: 0 14px; border-radius: 999px;
    color: rgba(255, 255, 255, .85); text-decoration: none; font-weight: 600;
    transition: background-color .15s ease, color .15s ease;
}
.topnav a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.topnav a.active { background: #fff; color: var(--primary-strong); }
.user-box { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-box form { margin: 0; }
.user-chip { display: flex; flex-direction: column; text-align: right; line-height: 1.2; }
.user-chip { max-width: 180px; }
.user-chip strong, .user-chip span { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip span { font-weight: 400; font-size: .8125rem; color: rgba(255, 255, 255, .75); }
.icon-btn {
    display: inline-grid; place-items: center;
    width: 44px; height: 44px; border-radius: 12px; cursor: pointer;
    border: 1px solid rgba(255, 255, 255, .35); background: rgba(255, 255, 255, .08); color: #fff;
    transition: background-color .15s ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, .2); }

/* Barra in basso (solo telefono) */
.bottomnav { display: none; }

/* Il nome utente sparisce prima che la testata si stringa */
@media (max-width: 1179px) { .user-chip { display: none; } }

/* Sotto i 1024px (telefoni e tablet) il menu passa nella barra in basso */
@media (max-width: 1023px) {
    .topnav { display: none; }
    .bottomnav {
        display: flex; position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
        background: var(--surface); border-top: 1px solid var(--line);
        box-shadow: 0 -4px 16px rgba(15, 23, 42, .08);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .bottomnav a {
        flex: 1; min-width: 0; min-height: var(--nav-h);
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
        color: var(--muted); text-decoration: none; font-size: .75rem; font-weight: 600;
    }
    .bottomnav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
    .bottomnav a .icon { width: 24px; height: 24px; }
    .bottomnav a.active { color: var(--primary); }
    .bottomnav a.active .icon-wrap { background: var(--primary-soft); }
    .icon-wrap { display: grid; place-items: center; width: 52px; height: 30px; border-radius: 999px; transition: background-color .2s ease; }
    body.has-nav main { padding-bottom: calc(var(--nav-h) + 32px + env(safe-area-inset-bottom)); }
}

/* ---------- Contenuto ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 0; }
.eyebrow {
    display: inline-block; margin-bottom: 4px;
    font-size: .8125rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary);
}

.card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head { padding: 16px 20px 0; }

.flash {
    display: flex; align-items: center; gap: 10px;
    background: var(--primary-soft); color: var(--primary-deep); border: 1px solid #bbf7d0;
    border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 20px; font-weight: 600;
}

.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty .icon { width: 36px; height: 36px; color: #94a3b8; margin-bottom: 8px; }

/* ---------- Bottoni ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 0 18px; border-radius: var(--radius-sm);
    border: 1px solid var(--primary); background: var(--primary); color: #fff;
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
    transition: background-color .15s ease, border-color .15s ease, transform .1s ease;
}
.btn:hover { background: var(--primary-strong); border-color: var(--primary-strong); color: #fff; }
.btn:active { transform: scale(.98); }
.btn.small { min-height: 44px; padding: 0 12px; font-size: .9375rem; }
.btn.secondary { background: var(--surface); color: var(--primary-strong); border-color: #bbf7d0; }
.btn.secondary:hover { background: var(--primary-soft); color: var(--primary-deep); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--primary-deep); }
.btn.accent:hover { background: #d97706; border-color: #d97706; color: #fff; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions form { margin: 0; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }

@media (max-width: 560px) {
    .page-head > .btn, .page-head > .actions { width: 100%; }
    .page-head > .btn, .page-head > .actions > .btn, .page-head > .actions form { flex: 1 1 auto; }
    .page-head > .actions form .btn { width: 100%; }
    .form-actions .btn { flex: 1 1 100%; }
}

/* ---------- Badge ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
    font-size: .8125rem; font-weight: 600; padding: 2px 10px; border-radius: 999px;
    background: var(--primary-soft); color: var(--primary-strong);
}
.badge.bench { background: #e2e8f0; color: #334155; }
.badge.gold { background: var(--accent-soft); color: #92400e; }
.badge.grey { background: #f1f5f9; color: var(--muted); }

/* ---------- Statistiche e azioni rapide ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.stat {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 16px; display: flex; align-items: center; gap: 14px;
}
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--primary-soft); color: var(--primary); }
.stat-icon.gold { background: var(--accent-soft); color: #b45309; }
.stat-icon .icon { width: 24px; height: 24px; }
.stat-value { font-family: var(--font-display); font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-label { color: var(--muted); font-size: .875rem; }
@media (max-width: 640px) {
    .stats { gap: 8px; }
    .stat { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; }
    .stat-icon { width: 40px; height: 40px; }
    .stat-value { font-size: 1.625rem; }
}

.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.quick a {
    display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 12px 14px;
    border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2);
    color: var(--text); text-decoration: none; font-weight: 600;
    transition: border-color .15s ease, background-color .15s ease;
}
.quick a:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-deep); }
.quick a .icon { color: var(--primary); }

/* ---------- Elenchi ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }
.card:not(.flush) .list-item { padding-left: 0; padding-right: 0; }
.list-main { flex: 1; min-width: 0; }
.list-title { font-weight: 600; color: var(--text); text-decoration: none; }
a.list-title:hover { color: var(--primary); text-decoration: underline; }
.list-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: .875rem; margin-top: 2px; }
.list-meta span { display: inline-flex; align-items: center; gap: 4px; }
.list-meta .icon { width: 16px; height: 16px; }
.avatar {
    width: 44px; height: 44px; border-radius: 12px; flex: none;
    display: grid; place-items: center;
    background: var(--primary-soft); color: var(--primary-strong);
    font-family: var(--font-display); font-weight: 700; font-size: 1.125rem; text-transform: uppercase;
}
.avatar.gold { background: var(--accent-soft); color: #92400e; }
/* Su telefono i bottoni delle righe restano quadrati, solo icona (il testo resta per i lettori di schermo) */
@media (max-width: 560px) {
    .list-item { padding-left: 16px; padding-right: 16px; gap: 12px; }
    .list-item > .actions { flex-wrap: nowrap; gap: 6px; }
    .list-item > .actions .btn { width: 44px; min-height: 44px; padding: 0; }
    .list-item > .actions .btn-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* Maglia con il numero */
.shirt {
    width: 44px; height: 44px; flex: none; display: grid; place-items: center;
    border-radius: 12px; background: var(--primary); color: #fff;
    font-family: var(--font-display); font-weight: 700; font-size: 1.25rem;
}
.shirt.bench { background: #64748b; }
.shirt.none { background: #e2e8f0; color: var(--muted); }

/* ---------- Partite ---------- */
.match {
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
    padding: 4px 0;
}
.match .team { font-weight: 700; font-size: 1.0625rem; min-width: 0; overflow-wrap: anywhere; }
.match .team.home { text-align: right; }
.score {
    min-width: 76px; text-align: center; padding: 6px 12px; border-radius: 10px;
    background: var(--primary-deep); color: #fff;
    font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; line-height: 1.1; letter-spacing: .04em;
}
.score.pending { background: var(--surface-2); color: var(--muted); border: 1px dashed #cbd5e1; font-size: 1rem; padding: 9px 12px; }
.game { padding: 16px 20px; border-top: 1px solid var(--line); }
.game:first-child { border-top: 0; }
.card:not(.flush) .game { padding-left: 0; padding-right: 0; }
.game-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.game-top .list-meta { margin: 0; }
.game-bottom { display: flex; justify-content: flex-end; margin-top: 10px; }
@media (max-width: 480px) {
    .match { gap: 8px; }
    .match .team { font-size: 1rem; }
    .score { min-width: 64px; font-size: 1.25rem; }
    .game-bottom .actions { width: 100%; }
    .game-bottom .actions > * { flex: 1; }
    .game-bottom .actions form .btn { width: 100%; }
}

/* ---------- Tabelle ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8125rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.actions { justify-content: flex-end; }
td.num { font-variant-numeric: tabular-nums; }
/* Su telefono ogni riga diventa una scheda */
@media (max-width: 720px) {
    table.stack thead { display: none; }
    table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
    table.stack tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
    table.stack tbody tr:last-child { border-bottom: 0; }
    table.stack tbody tr:hover td { background: transparent; }
    table.stack td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
    table.stack td::before { content: attr(data-label); color: var(--muted); font-size: .875rem; text-align: left; }
    table.stack td.title { font-size: 1.0625rem; text-align: left; }
    table.stack td.title::before, table.stack td.actions::before { content: none; }
    table.stack td.actions { justify-content: stretch; padding-top: 10px; }
    table.stack td.actions > * { flex: 1; }
    table.stack td.actions form .btn { width: 100%; }
}

/* ---------- Moduli ---------- */
label { display: block; margin: 16px 0 6px; font-weight: 600; font-size: .9375rem; }
input[type=email], input[type=password], input[type=text], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
    width: 100%; min-height: 48px; padding: 10px 14px;
    border: 1px solid #cbd5e1; border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
    font: inherit; font-size: 1rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(21, 128, 61, .2); }
input[aria-invalid=true], select[aria-invalid=true] { border-color: var(--danger); }
.error { display: flex; align-items: center; gap: 6px; color: var(--danger); font-size: .875rem; margin-top: 6px; font-weight: 500; }
.hint { color: var(--muted); font-size: .875rem; margin: 6px 0 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }
.field-group { margin-top: 16px; }
.field-group > label:first-child, .legend { margin-top: 0; }
.legend { display: block; margin: 16px 0 8px; font-weight: 600; font-size: .9375rem; }

.check, .choice {
    display: flex; align-items: center; gap: 12px; margin: 0 0 8px; min-height: 48px; padding: 10px 14px;
    border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2);
    font-weight: 500; cursor: pointer;
}
.check input, .choice input { width: 20px; height: 20px; accent-color: var(--primary); flex: none; margin: 0; }
.check:has(input:checked), .choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.choices .choice { margin: 0; }
.inline-check { display: flex; align-items: center; gap: 10px; font-weight: 500; margin: 16px 0 0; cursor: pointer; min-height: 44px; }
.inline-check input { width: 20px; height: 20px; accent-color: var(--primary); }

.card.filter { display: flex; align-items: center; gap: 12px; padding: 14px 20px; }
.filter label { margin: 0; white-space: nowrap; }
.filter select { flex: 1; }
@media (max-width: 480px) { .card.filter { flex-direction: column; align-items: stretch; gap: 6px; padding: 14px 16px; } }

.form-card { max-width: 760px; }

/* ---------- Accesso ---------- */
.auth {
    min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
    background:
        radial-gradient(circle at 50% 50%, transparent 0 88px, rgba(255, 255, 255, .08) 89px 91px, transparent 92px),
        linear-gradient(90deg, transparent calc(50% - 1px), rgba(255, 255, 255, .08) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, .03) 0 80px, transparent 80px 160px),
        linear-gradient(160deg, var(--primary-deep), var(--primary-strong));
}
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 20px; box-shadow: 0 24px 64px rgba(5, 46, 22, .45); padding: 32px 28px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-brand .brand-mark { width: 52px; height: 52px; border-radius: 14px; }
.auth-brand .brand-mark .icon { width: 30px; height: 30px; }
.auth-brand strong { display: block; font-family: var(--font-display); font-size: 1.5rem; text-transform: uppercase; letter-spacing: .03em; line-height: 1.1; }
.auth-card .btn { width: 100%; margin-top: 20px; min-height: 50px; font-size: 1.0625rem; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
