@import url("https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap");

/* ═══════════════════════════════════════════════════════════════════
   VolleyStat — tema "glass": sfondo sfumato lavanda, card in vetro
   semitrasparente, accento viola. Tema chiaro/scuro (preferenza di
   sistema, oppure scelta salvata in html[data-theme]).
   ═══════════════════════════════════════════════════════════════════ */
:root {
  --bg1: #e8ebfb; --bg2: #efe6fb; --bg3: #f6e3f6;
  --glass: rgba(255,255,255,.55);
  --glass-strong: rgba(255,255,255,.85);
  --line: rgba(255,255,255,.85);
  --hair: rgba(40,30,90,.09);
  --ink: #16142b; --ink2: #55536b; --ink3: #8e8ca3;
  --accent: #6a3cf3; --accent2: #9b7bff; --accent3: #c9b8ff;
  --accent-soft: rgba(106,60,243,.10);
  --green: #2fc85a; --red: #ff3b30; --yellow: #ffd25a; --orange: #ff8a5b;
  --shadow: 0 10px 30px rgba(80,60,160,.10);
  --shadow-sm: 0 2px 10px rgba(80,60,160,.07);
  --input-bg: rgba(255,255,255,.9);
  --tip-bg: #ffffff;
  --ok-bg: rgba(47,200,90,.13);  --ok-ink: #17713a;
  --warn-bg: rgba(255,180,0,.16); --warn-ink: #8a5a00;
  --err-bg: rgba(255,59,48,.12);  --err-ink: #b3261e;
  --off-bg: rgba(90,90,120,.10);  --off-ink: #5a5a72;
  --code-bg: #15132b;

  /* Nomi storici, usati ancora da alcune pagine */
  --blu: var(--accent); --blu-chiaro: var(--accent); --arancio: #f39c12;
  --grigio: var(--bg1); --bordo: var(--hair);

  --sb-width: 236px;
  --sb-mini: 68px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg1: #13122a; --bg2: #1b1636; --bg3: #26163a;
    --glass: rgba(40,36,72,.55); --glass-strong: rgba(60,54,104,.72);
    --line: rgba(255,255,255,.08); --hair: rgba(255,255,255,.09);
    --ink: #f2f0ff; --ink2: #bab7d4; --ink3: #85829f;
    --accent: #8a63ff; --accent2: #a98cff; --accent3: #5b48a6;
    --accent-soft: rgba(138,99,255,.18);
    --shadow: 0 10px 30px rgba(0,0,0,.35); --shadow-sm: 0 2px 10px rgba(0,0,0,.25);
    --input-bg: rgba(30,27,58,.85); --tip-bg: #2c2754;
    --ok-ink: #7be39a; --warn-ink: #ffd27a; --err-ink: #ff8a83; --off-ink: #b3b0cc;
    --code-bg: #0c0b1c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg1: #13122a; --bg2: #1b1636; --bg3: #26163a;
  --glass: rgba(40,36,72,.55); --glass-strong: rgba(60,54,104,.72);
  --line: rgba(255,255,255,.08); --hair: rgba(255,255,255,.09);
  --ink: #f2f0ff; --ink2: #bab7d4; --ink3: #85829f;
  --accent: #8a63ff; --accent2: #a98cff; --accent3: #5b48a6;
  --accent-soft: rgba(138,99,255,.18);
  --shadow: 0 10px 30px rgba(0,0,0,.35); --shadow-sm: 0 2px 10px rgba(0,0,0,.25);
  --input-bg: rgba(30,27,58,.85); --tip-bg: #2c2754;
  --ok-ink: #7be39a; --warn-ink: #ffd27a; --err-ink: #ff8a83; --off-ink: #b3b0cc;
  --code-bg: #0c0b1c;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  min-height: 100vh;
  background:
    radial-gradient(900px 600px at 85% 10%, rgba(190,170,255,.42), transparent 60%),
    radial-gradient(800px 600px at 25% 100%, rgba(240,160,230,.30), transparent 60%),
    linear-gradient(160deg, var(--bg1), var(--bg2) 55%, var(--bg3));
  background-attachment: fixed;
}
a { color: var(--accent); }

/* Superficie in vetro, riusabile */
.glass, .card, .sidebar, header.topbar, .ctxbar {
  background: var(--glass);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
}

/* ─── Barra in alto per ospiti (login, registrazione) ─────────────── */
header.topbar {
  margin: 12px 16px 0;
  border-radius: 20px;
  padding: 10px 14px 10px 18px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
}
header.topbar h1 { font-size: 1.05rem; margin: 0; font-weight: 600; }
header.topbar nav { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
header.topbar nav a {
  color: var(--ink2); text-decoration: none; font-size: .93rem;
  padding: 8px 14px; border-radius: 16px;
}
header.topbar nav a:hover { background: var(--glass-strong); color: var(--ink); }
header.topbar nav a.active { background: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(106,60,243,.35); }

main { max-width: 720px; margin: 36px auto; padding: 0 16px; }

.card {
  border-radius: 22px;
  padding: 26px 30px;
}
.card h2 { margin-top: 0; font-weight: 600; font-size: 1.2rem; color: var(--ink); }

label { display: block; margin: 14px 0 6px; font-weight: 500; font-size: .9rem; color: var(--ink2); }

input[type=text], input[type=email], input[type=password], input[type=file], input[type=number], input[type=date], textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font: inherit; font-size: .98rem;
  background: var(--input-bg); color: var(--ink);
  box-shadow: var(--shadow-sm);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }

button, .btn {
  display: inline-block;
  margin-top: 18px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 22px;
  padding: 11px 24px;
  font: inherit; font-size: .96rem; font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 6px 16px rgba(106,60,243,.32);
  transition: filter .15s, transform .15s;
}
button:hover, .btn:hover { filter: brightness(1.08); }
button:active, .btn:active { transform: translateY(1px); }
button:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.msg-error, .msg-ok {
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
  border-left: 3px solid;
}
.msg-error { background: var(--err-bg); color: var(--err-ink); border-color: var(--red); }
.msg-ok    { background: var(--ok-bg);  color: var(--ok-ink);  border-color: var(--green); }

.linkline { margin-top: 18px; font-size: .92rem; color: var(--ink2); }
.import-log {
  background: var(--code-bg);
  color: #cde3ff;
  font-family: ui-monospace, Consolas, monospace;
  font-size: .85rem;
  padding: 16px;
  border-radius: 14px;
  overflow-x: auto;
  margin-top: 20px;
}

/* Ruoli */
.badge-role {
  display: inline-block; border-radius: 10px; padding: 2px 9px; font-size: .7rem; font-weight: 600;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.badge-superadmin { background: var(--err-bg); color: var(--err-ink); }
.badge-orgadmin   { background: var(--warn-bg); color: var(--warn-ink); }
.badge-admin { background: var(--warn-bg); color: var(--warn-ink); border-radius: 10px; padding: 2px 9px; font-size: .72rem; margin-left: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ─── Menu laterale (utenti loggati, layout.php) ──────────────────── */
body:has(> .sidebar) { padding-left: calc(var(--sb-width) + 24px); padding-right: 12px; transition: padding-left .25s; }
html.sb-mini body:has(> .sidebar) { padding-left: calc(var(--sb-mini) + 24px); }

.sidebar {
  position: fixed; top: 12px; bottom: 12px; left: 12px; width: var(--sb-width); z-index: 40;
  border-radius: 22px;
  display: flex; flex-direction: column; overflow: hidden;
  transition: width .25s;
}
html.sb-mini .sidebar { width: var(--sb-mini); }
.sidebar button { margin: 0; background: none; box-shadow: none; color: inherit; padding: 0; border-radius: 10px; }
.sidebar button:hover { filter: none; }

.sb-head { display: flex; align-items: center; gap: 8px; padding: 16px 12px 14px 14px; border-bottom: 1px solid var(--hair); }
.sb-brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--ink); text-decoration: none; }
.sb-logo {
  flex: none; width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 20px;
  background: linear-gradient(135deg, #2b2350, #5a35d6); box-shadow: 0 4px 12px rgba(80,50,200,.35);
}
.sb-brand-txt { min-width: 0; line-height: 1.25; }
.sb-brand-txt b { display: block; font-size: .95rem; }
.sb-brand-txt small { display: block; font-size: .76rem; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-collapse, .sb-toggle {
  flex: none; margin-left: auto !important; width: 28px; height: 28px; display: grid !important; place-items: center;
  background: var(--glass-strong) !important; box-shadow: var(--shadow-sm) !important;
}
.sb-collapse svg { transition: transform .25s; }
html.sb-mini .sb-collapse svg { transform: rotate(180deg); }
.sb-toggle { display: none !important; width: 38px; height: 38px; }

.sb-menu { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 4px 0 12px; scrollbar-width: thin; }
.sb-group {
  margin: 18px 22px 6px; font-size: .68rem; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar nav a {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 22px; margin: 1px 0;
  color: var(--ink2); text-decoration: none; font-size: .95rem; white-space: nowrap;
  transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: var(--glass-strong); color: var(--ink); }
.sidebar nav a.active { color: var(--ink); font-weight: 600; }
.sidebar nav a.active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
/* Voce con sottomenu (details/summary) */
.sb-sub > summary {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 22px; margin: 1px 0;
  color: var(--ink2); font-size: .95rem; white-space: nowrap; cursor: pointer; list-style: none;
  transition: background .15s, color .15s;
}
.sb-sub > summary::-webkit-details-marker { display: none; }
.sb-sub > summary:hover { background: var(--glass-strong); color: var(--ink); }
.sb-sub > summary.active { color: var(--ink); font-weight: 600; }
.sb-caret { margin-left: auto; flex: none; color: var(--ink3); transition: transform .2s; }
.sb-sub[open] > summary .sb-caret { transform: rotate(90deg); }
.sidebar nav a.sb-subitem { padding: 8px 22px 8px 54px; font-size: .9rem; }
.sb-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--ink3); }
.sb-subitem.active .sb-dot { background: var(--accent); }
.sidebar summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
html.sb-mini .sb-sub > summary span, html.sb-mini .sb-sub > summary .sb-caret { display: none; }
html.sb-mini .sb-sub > summary { justify-content: center; padding: 10px 0; }
html.sb-mini .sidebar nav a.sb-subitem { padding: 8px 0; }
@media (max-width: 860px) {
  html.sb-mini .sb-sub > summary span, html.sb-mini .sb-sub > summary .sb-caret { display: inline; }
  html.sb-mini .sb-sub > summary { justify-content: flex-start; padding: 10px 22px; }
  html.sb-mini .sidebar nav a.sb-subitem { padding: 8px 22px 8px 54px; }
}
.sidebar a:focus-visible, .sidebar button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.nav-ico { flex: none; }

.sb-foot { margin-top: auto; padding: 14px 10px 0; display: flex; flex-direction: column; gap: 10px; }
.sb-cta {
  display: flex; align-items: center; justify-content: center; gap: 10px; height: 44px; border-radius: 22px;
  background: linear-gradient(90deg, var(--accent), #7b55ff); color: #fff; text-decoration: none; font-weight: 500;
  box-shadow: 0 8px 22px rgba(106,60,243,.4); white-space: nowrap;
}
.sb-cta:hover { filter: brightness(1.08); }
.sb-cta.active { outline: 2px solid var(--accent3); outline-offset: 2px; }

.sb-theme { display: flex; padding: 3px; border-radius: 22px; background: var(--glass); border: 1px solid var(--line); align-self: stretch; }
.sb-theme button { flex: 1; height: 36px; border-radius: 18px !important; display: grid; place-items: center; color: var(--ink3); }
.sb-theme button[aria-pressed="true"] { background: var(--glass-strong); color: var(--ink); box-shadow: var(--shadow-sm); }

.sb-link {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 14px;
  color: var(--ink2); text-decoration: none; font-size: .93rem; white-space: nowrap;
  transition: background .15s, color .15s;
}
.sb-link:hover { background: var(--glass-strong); color: var(--ink); }
.sb-link.active { background: var(--glass-strong); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }
.sb-link.active .nav-ico { color: var(--accent); }

.sb-user { display: flex; align-items: center; gap: 10px; margin: 0 10px; padding: 12px 4px; border-bottom: 1px solid var(--hair); }
.sb-avatar {
  flex: none; width: 38px; height: 38px; border-radius: 50%; color: #fff;
  background: linear-gradient(135deg, #f0a35e, #c2563a); display: grid; place-items: center; font-weight: 600; font-size: .85rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.sb-user-txt { min-width: 0; flex: 1; }
.sb-name { font-size: .88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px; }
.sb-logout {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  color: var(--ink2); text-decoration: none;
}
.sb-logout:hover { background: var(--glass-strong); color: var(--red); }

/* Menu ridotto a icone */
html.sb-mini .sb-head { flex-direction: column; padding: 14px 0; gap: 10px; }
html.sb-mini .sb-brand-txt,
html.sb-mini .sidebar nav a span,
html.sb-mini .sb-cta span,
html.sb-mini .sb-link span,
html.sb-mini .sb-user-txt { display: none; }
html.sb-mini .sb-collapse { margin: 0 !important; }
html.sb-mini .sb-group { margin: 16px 0 6px; text-align: center; font-size: .6rem; }
html.sb-mini .sidebar nav a { justify-content: center; padding: 10px 0; }
html.sb-mini .sb-cta { width: 44px; align-self: center; }
html.sb-mini .sb-link { justify-content: center; padding: 9px 0; }
html.sb-mini .sb-theme { flex-direction: column; align-self: center; width: 44px; }
html.sb-mini .sb-theme button { flex: none; width: 36px; }
html.sb-mini .sb-user { flex-direction: column; padding: 12px 0; margin: 0 8px; }

/* Mobile: barra in alto, menu a scomparsa */
@media (max-width: 860px) {
  body:has(> .sidebar), html.sb-mini body:has(> .sidebar) { padding: 0; }
  .sidebar, html.sb-mini .sidebar { position: sticky; top: 8px; left: auto; bottom: auto; width: auto; margin: 8px 12px 0; max-height: calc(100vh - 16px); }
  .sb-head, html.sb-mini .sb-head { flex-direction: row; padding: 10px 10px 10px 12px; border-bottom: 0; }
  html.sb-mini .sb-brand-txt { display: block; }
  .sb-collapse { display: none !important; }
  .sb-toggle { display: grid !important; }
  .js .sidebar:not(.open) .sb-menu { display: none; }
  .sidebar.open .sb-head { border-bottom: 1px solid var(--hair); }
  html.sb-mini .sidebar nav a span, html.sb-mini .sb-cta span, html.sb-mini .sb-link span, html.sb-mini .sb-user-txt { display: inline; }
  html.sb-mini .sb-link { justify-content: flex-start; padding: 9px 12px; }
  html.sb-mini .sidebar nav a { justify-content: flex-start; padding: 10px 22px; }
  html.sb-mini .sb-group { margin: 18px 22px 6px; text-align: left; font-size: .68rem; }
  html.sb-mini .sb-cta { width: auto; align-self: stretch; }
  html.sb-mini .sb-theme { flex-direction: row; align-self: stretch; width: auto; }
  html.sb-mini .sb-theme button { flex: 1; width: auto; }
  html.sb-mini .sb-user { flex-direction: row; padding: 12px 4px; margin: 0 10px; }
  .card { padding: 20px 18px; }
}

.ctxbar {
  margin: 12px 0 0; border-radius: 16px;
  color: var(--ink2); font-size: .88rem;
  padding: 10px 18px;
}
.ctxbar b { color: var(--ink); }
.ctxbar.warn { background: var(--warn-bg); color: var(--warn-ink); }
.ctxbar a { color: var(--accent); font-weight: 600; }
.ctxbar.warn a { color: inherit; }
@media (max-width: 860px) { .ctxbar { margin: 10px 12px 0; } }

/* ─── Pagine di gestione ──────────────────────────────────────────── */
main.wide { max-width: 1440px; margin: 16px auto 40px; padding: 0; }
@media (max-width: 860px) { main.wide { padding: 0 12px; } }
.card + .card { margin-top: 16px; }
table.list { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.list th { text-align: left; font-weight: 500; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink3); padding: 8px 10px; border-bottom: 1px solid var(--hair); white-space: nowrap; }
table.list td { padding: 10px 10px; border-bottom: 1px solid var(--hair); vertical-align: middle; }
table.list tbody tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: var(--glass-strong); }
table.list .muted, .muted { color: var(--ink3); font-size: .85rem; }
.scroll { overflow-x: auto; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.inline-form select, select.input, input.input, select {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; font: inherit; font-size: .9rem;
  background: var(--input-bg); color: var(--ink); box-shadow: var(--shadow-sm);
}
input.input { width: auto; }
button.small, .btn.small { margin-top: 0; padding: 6px 14px; font-size: .84rem; box-shadow: none; }
button.ghost { background: var(--glass-strong); color: var(--accent); border: 1px solid var(--line); box-shadow: none; }
button.ghost:hover { background: var(--accent-soft); filter: none; }
button.danger { background: var(--red); box-shadow: 0 6px 16px rgba(255,59,48,.25); }
.pill { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: .76rem; font-weight: 600; white-space: nowrap; }
.pill-ok   { background: var(--ok-bg);   color: var(--ok-ink); }
.pill-warn { background: var(--warn-bg); color: var(--warn-ink); }
.pill-err  { background: var(--err-bg);  color: var(--err-ink); }
.pill-off  { background: var(--off-bg);  color: var(--off-ink); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; align-items: end; }
.form-grid label { margin-top: 10px; }
.form-grid input, .form-grid select { width: 100%; }

/* ─── Colori dei ruoli (numeri delle giocatrici) ──────────────────────
   P palleggiatore rosso · O opposto nero · S schiacciatore blu · C centrale verde · L libero arancio */
:root { --role-P: #e5322d; --role-O: #1b1b1f; --role-S: #1f6fe5; --role-C: #1fa456; --role-L: #f28a00; }
.rl-P, .rl-O, .rl-S, .rl-C, .rl-L { color: #fff !important; }
.rl-P { background: var(--role-P) !important; }
.rl-O { background: var(--role-O) !important; }
.rl-S { background: var(--role-S) !important; }
.rl-C { background: var(--role-C) !important; }
.rl-L { background: var(--role-L) !important; }
/* nel tema scuro il nero dell'opposto ha un bordo chiaro per staccarsi dallo sfondo */
:root[data-theme="dark"] .rl-O { box-shadow: 0 0 0 1.5px rgba(255,255,255,.55); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .rl-O { box-shadow: 0 0 0 1.5px rgba(255,255,255,.55); } }
.role-legend { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; margin-right: 10px; }
.role-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; vertical-align: -1px; margin-right: 5px; }

/* ─── Elementi del tema riusabili (dashboard) ─────────────────────── */
.note {
  border-left: 1.5px solid var(--accent); padding: 1px 0 1px 9px;
  font-size: .78rem; font-style: italic; color: var(--ink2); line-height: 1.35;
}
.delta { display: inline-block; font-size: .68rem; font-weight: 600; color: #fff; padding: 3px 8px; border-radius: 10px; line-height: 1.2; font-style: normal; }
.delta.up { background: var(--green); } .delta.dn { background: var(--red); } .delta.eq { background: var(--ink3); }
