/* ============================================================
   Campionato Gioia Padel — tema PREMIUM DARK
   Sfondo nero, testo bianco, arancione gradiente.
   ============================================================ */
:root {
  --orange: #ff7d24;
  --orange2: #ffb066;
  --grad: linear-gradient(135deg, #ff7d24, #ffb066);
  --bg: #0b0b0d;
  --bg-2: #101013;
  --card: #151519;
  --card-2: #1a1a20;
  --ink: #f6f4f1;
  --muted: #9a958d;
  --line: rgba(255, 255, 255, .08);
  --line-2: rgba(255, 255, 255, .16);
  --radius: 18px;
  --shadow: 0 12px 34px rgba(0, 0, 0, .55);
  --shadow-lg: 0 28px 70px rgba(0, 0, 0, .65);
  --glow: 0 10px 30px rgba(255, 125, 36, .30);
  /* tema squadra (sovrascritto via JS) */
  --team: #ff7d24;
  --team2: #ffb066;
  --team-grad: linear-gradient(135deg, #ff7d24, #ffb066);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.55; letter-spacing: .1px;
  background:
    radial-gradient(1100px 520px at 50% -240px, rgba(255, 125, 36, .16), transparent 70%),
    radial-gradient(800px 400px at 100% 0%, rgba(255, 125, 36, .06), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
}
a { color: var(--orange); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.18; letter-spacing: -.02em; }
h1 { font-size: 27px; }
h2 { font-size: 21px; }
h3 { font-size: 16px; }
p { margin: 0 0 .8em; }
small { color: var(--muted); }

.wrap { max-width: 1000px; margin: 0 auto; padding: 20px 18px 96px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.stack { display: grid; gap: 14px; }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(11, 11, 13, .72); backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}
.topbar .inner { max-width: none; margin: 0; padding: 13px 20px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.topbar .inner .row { flex-wrap: nowrap; justify-content: flex-end; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; }
.brand .dot { width: 32px; height: 32px; border-radius: 10px; background: var(--team-grad); display: grid; place-items: center; color: #fff; font-size: 16px; box-shadow: var(--glow); }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 44px 8px 8px; }
.hero h1 {
  font-size: clamp(30px, 8vw, 50px); font-weight: 850; letter-spacing: -.03em;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 40px rgba(255, 125, 36, .25);
}
.hero p { color: var(--muted); font-size: 16.5px; }
/* spazio tra i pulsanti dell'hero e il primo blocco (home) */
#adminBox { margin-top: 46px; }

/* ---------- card ---------- */
.card {
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .2s ease, border-color .2s ease;
}
.card:hover { border-color: var(--line-2); }

/* più spazio + titoli sezione chiari */
.section-title {
  display: flex; align-items: center; gap: 10px;
  margin: 46px 4px 16px; font-size: 12.5px; font-weight: 800; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
}
.section-title::before { content: ""; width: 22px; height: 4px; border-radius: 4px; background: var(--grad); box-shadow: var(--glow); }
.section-title::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }
section[data-panel] { animation: fadeIn .35s ease both; }

/* ---------- bottoni ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 700; font-size: 15px;
  padding: 12px 20px; border-radius: 13px; background: rgba(255, 255, 255, .06); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .1s ease, box-shadow .18s ease, opacity .15s ease, background .2s ease; text-decoration: none;
  border: 1px solid var(--line);
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--grad); color: #201200; border-color: transparent; box-shadow: var(--glow); font-weight: 800; }
.btn.team { background: var(--team-grad); color: #17110a; border-color: transparent; box-shadow: 0 10px 26px rgba(0, 0, 0, .4); font-weight: 800; }
.btn.ghost { background: transparent; }
.btn.ok { background: linear-gradient(135deg, #2ff08f, #10d46f); color: #04231a; border-color: transparent; font-weight: 800; box-shadow: 0 8px 22px rgba(38, 224, 130, .32); }
.btn.ok:hover { background: linear-gradient(135deg, #45f79e, #18e07a); }
.btn.warn { background: rgba(255, 90, 82, .12); color: #ff9a93; border: 1px solid rgba(255, 90, 82, .36); font-weight: 700; }
.btn.warn:hover { background: rgba(255, 90, 82, .2); }
.btn.sm { padding: 9px 14px; border-radius: 11px; font-size: 13.5px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- form ---------- */
label { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin: 0 0 6px; letter-spacing: .02em; }
input, select, textarea {
  width: 100%; font: inherit; padding: 12px 13px; border: 1px solid var(--line);
  border-radius: 12px; background: #0e0e11; color: var(--ink);
}
input::placeholder { color: #6b665f; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--orange); outline-offset: 1px; border-color: transparent; }
input[type="color"] { padding: 4px; height: 46px; cursor: pointer; }
select option { background: #151519; }
.field { margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- badge / stati ---------- */
.badge { display: inline-block; padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 800; letter-spacing: .02em; border: 1px solid transparent; }
.badge.s-ok   { background: rgba(38, 192, 122, .14); color: #58e0a3; border-color: rgba(38, 192, 122, .3); }
.badge.s-wait { background: rgba(255, 176, 60, .14); color: #ffc06b; border-color: rgba(255, 176, 60, .3); }
.badge.s-appr { background: rgba(90, 150, 255, .16); color: #8fb4ff; border-color: rgba(90, 150, 255, .3); }
.badge.s-done { background: rgba(38, 192, 122, .2); color: #6ef0b4; border-color: rgba(38, 192, 122, .45); }
.badge.s-off  { background: rgba(255, 255, 255, .07); color: var(--muted); border-color: var(--line); }
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 800; background: rgba(255, 255, 255, .07); color: var(--muted); border: 1px solid var(--line); }
.pill.leg { background: rgba(180, 130, 255, .16); color: #c6a8ff; border-color: rgba(180, 130, 255, .32); }
.pill.draft { background: rgba(255, 90, 82, .16); color: #ff8f88; border-color: rgba(255, 90, 82, .42); }

/* avviso rosso "pubblica la bozza" */
.warn-banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  border: 1px solid rgba(255, 90, 82, .5); background: rgba(255, 90, 82, .10); color: #ffb4af;
  border-radius: 14px; padding: 14px 16px; font-weight: 700; box-shadow: var(--shadow); }
.warn-banner .btn { flex: 0 0 auto; }

/* ---------- team chip ---------- */
.team-chip { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.team-chip::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 26%, transparent), 0 0 12px color-mix(in srgb, var(--c) 60%, transparent); }

/* ---------- slot / partita = "carta" ---------- */
.slot {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 16px 18px 16px 20px; border: 1px solid var(--line); border-radius: 15px;
  background: linear-gradient(180deg, var(--card-2), var(--card)); box-shadow: var(--shadow);
  overflow: hidden; transition: transform .18s ease, box-shadow .2s ease, border-color .2s ease;
}
.slot::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, var(--grad)); }
.slot:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--line-2); }
.slot .when { font-weight: 800; }
.slot .time { font-variant-numeric: tabular-nums; }
.daygroup { margin-top: 18px; }
.dayhead { font-weight: 800; text-transform: capitalize; margin: 0 2px 10px; display: flex; align-items: center; gap: 8px; }
.dayhead .date-big { font-size: 18px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- griglia stato campionato ---------- */
.champ-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.champ-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(180deg, var(--card-2), var(--card)); box-shadow: var(--shadow); transition: transform .16s ease, border-color .2s; }
.champ-row:hover { transform: translateY(-2px); border-color: var(--line-2); }
.champ-row .legs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.leg-ind { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; padding: 6px 12px; border-radius: 999px; min-width: 96px; justify-content: center; border: 1px solid transparent; }
.leg-ind.done { background: rgba(38, 192, 122, .18); color: #6ef0b4; border-color: rgba(38, 192, 122, .4); }
.leg-ind.todo { background: rgba(255, 255, 255, .05); color: #6f6a63; border-color: var(--line); }
.leg-ind .mk { font-size: 13px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; background: rgba(255, 255, 255, .05); padding: 6px; border-radius: 15px; border: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; background: transparent; padding: 11px 8px; border-radius: 11px; font: inherit; font-weight: 700; font-size: 14px; color: var(--muted); cursor: pointer; transition: all .18s ease; }
.tabs button.active { background: var(--team-grad); color: #17110a; box-shadow: var(--glow); font-weight: 800; }

/* ---------- creazione slot (stile "Cassaforti") ---------- */
.mode-tabs { display: flex; gap: 6px; background: rgba(255, 255, 255, .05); padding: 5px; border-radius: 12px; border: 1px solid var(--line); margin-bottom: 14px; }
.mode-tabs button { flex: 1; border: 0; background: transparent; padding: 10px; border-radius: 9px; font: inherit; font-weight: 700; color: var(--muted); cursor: pointer; transition: all .18s; }
.mode-tabs button.active { background: var(--team-grad); color: #17110a; font-weight: 800; }
.time-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 8px; margin-top: 8px; }
.time-chip { position: relative; display: block; text-align: center; padding: 11px 6px; border: 1px solid var(--line); border-radius: 11px; background: #0e0e11; cursor: pointer; font-weight: 700; font-variant-numeric: tabular-nums; transition: all .15s; user-select: none; }
.time-chip input { position: absolute; opacity: 0; pointer-events: none; }
.time-chip:has(input:checked) { background: var(--team-grad); color: #17110a; border-color: transparent; box-shadow: var(--glow); }
.check-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-weight: 600; color: var(--ink); cursor: pointer; }
.check-row input { width: auto; margin: 0; }

/* ---------- modale ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .66); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fadeIn .18s ease both; }
.modal { background: linear-gradient(180deg, var(--card-2), var(--card)); border: 1px solid var(--line-2); border-radius: 20px; padding: 24px; max-width: 460px; width: 100%; box-shadow: var(--shadow-lg); animation: pop .24s cubic-bezier(.2, .8, .3, 1.1) both; }

/* ---------- login ---------- */
.login { max-width: 410px; margin: 6vh auto 0; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: -90px; transform: translateX(-50%); background: #17171b; color: #fff; padding: 13px 20px; border-radius: 13px; box-shadow: var(--shadow-lg); border: 1px solid var(--line-2); transition: bottom .32s cubic-bezier(.2, .8, .3, 1); z-index: 100; max-width: 92vw; font-weight: 600; }
.toast.show { bottom: 24px; }
.toast.err { background: #2a1210; border-color: rgba(255, 90, 82, .5); }

/* ---------- footer ---------- */
.foot { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 56px; }

/* ---------- squadre grid (home) ---------- */
.teams-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); grid-auto-rows: 1fr; gap: 12px; }
.team-card { position: relative; display: flex; align-items: center; gap: 11px; padding: 16px; border-radius: 15px; color: #fff; font-weight: 800; box-shadow: var(--shadow); border: 1px solid rgba(255, 255, 255, .14); overflow: hidden; transition: transform .18s ease, box-shadow .2s ease; }
.team-card:hover { transform: translateY(-3px) scale(1.01); box-shadow: var(--shadow-lg); }
.team-card .em { width: 26px; height: 26px; flex: 0 0 auto; border-radius: 50%; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); background: center/contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle cx='16' cy='16' r='15' fill='%23cfe84a'/%3E%3Cpath d='M6 3 C 13 10 13 22 6 29' fill='none' stroke='%23fcffe8' stroke-width='2'/%3E%3Cpath d='M26 3 C 19 10 19 22 26 29' fill='none' stroke='%23fcffe8' stroke-width='2'/%3E%3C/svg%3E"); }

/* ---------- animazioni ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }

.stack > *, .teams-grid > *, .champ-grid > *, #slotsBox > *, #findBox > * , .daygroup {
  animation: fadeUp .5s cubic-bezier(.22, .61, .36, 1) both;
}
.stack > *:nth-child(1),  .teams-grid > *:nth-child(1),  .champ-grid > *:nth-child(1)  { animation-delay: .03s; }
.stack > *:nth-child(2),  .teams-grid > *:nth-child(2),  .champ-grid > *:nth-child(2)  { animation-delay: .07s; }
.stack > *:nth-child(3),  .teams-grid > *:nth-child(3),  .champ-grid > *:nth-child(3)  { animation-delay: .11s; }
.stack > *:nth-child(4),  .teams-grid > *:nth-child(4),  .champ-grid > *:nth-child(4)  { animation-delay: .15s; }
.stack > *:nth-child(5),  .teams-grid > *:nth-child(5),  .champ-grid > *:nth-child(5)  { animation-delay: .19s; }
.stack > *:nth-child(6),  .teams-grid > *:nth-child(6),  .champ-grid > *:nth-child(6)  { animation-delay: .23s; }
.stack > *:nth-child(7),  .teams-grid > *:nth-child(7),  .champ-grid > *:nth-child(7)  { animation-delay: .27s; }
.stack > *:nth-child(8),  .teams-grid > *:nth-child(8),  .champ-grid > *:nth-child(8)  { animation-delay: .31s; }
.stack > *:nth-child(9),  .teams-grid > *:nth-child(9),  .champ-grid > *:nth-child(9)  { animation-delay: .35s; }
.stack > *:nth-child(n+10), .teams-grid > *:nth-child(n+10), .champ-grid > *:nth-child(n+10) { animation-delay: .39s; }

/* slot dentro i daygroup: leggero stagger */
#slotsBox .slot, #findBox .slot { animation: fadeUp .45s cubic-bezier(.22, .61, .36, 1) both; }

/* ============================================================
   MOBILE — layout più ordinato su telefono
   ============================================================ */
@media (max-width: 560px) {
  .wrap { padding: 14px 13px 90px; }
  .topbar .inner { padding: 10px 13px; }
  .brand { font-size: 15px; }
  .brand .dot { width: 28px; height: 28px; font-size: 14px; }
  .topbar .btn.sm { padding: 8px 10px; font-size: 12.5px; }
  .hide-mobile { display: none; }               /* su telefono i pulsanti topbar mostrano solo l'icona */
  .topbar .inner { gap: 8px; }
  .brand { min-width: 0; }
  #brandName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 42vw; }

  .hero { padding: 30px 4px 4px; }
  .hero h1 { margin-bottom: 14px; }
  .hero p { font-size: 15px; margin-bottom: 26px; }
  .hero .row { margin-top: 8px; gap: 14px; }
  .hero .row .btn { flex: 1 1 100%; }   /* pulsanti hero a tutta larghezza, impilati */
  #adminBox { margin-top: 42px; }        /* più aria prima di "Organizzatore" */

  .section-title { margin: 54px 2px 14px; font-size: 11.5px; }
  .section-title:first-of-type { margin-top: 34px; }
  .card { padding: 16px; }
  section[data-panel] .section-title:first-child { margin-top: 30px; }
  .stack { gap: 16px; }

  /* tabs: 2 per riga invece di 4 strette */
  .tabs { flex-wrap: wrap; }
  .tabs button { flex: 1 1 calc(50% - 4px); padding: 10px 6px; font-size: 13px; }

  /* squadre: 2 colonne pulite */
  .teams-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .team-card { padding: 13px; font-size: 14px; }

  /* stato campionato: nome sopra, indicatori sotto */
  .champ-row { grid-template-columns: 1fr; gap: 10px; }
  .champ-row .legs { justify-content: flex-start; }
  .leg-ind { flex: 1; min-width: 0; }

  /* slot / partita: azione sotto invece che a fianco */
  .slot { flex-wrap: wrap; }
  .slot .btn { width: 100%; }

  /* schede con azioni: bottoni a tutta larghezza e impilati bene */
  .card .row .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
