/* ── MARCHIO: Mayhem Fitness ────────────────────────────────────────────────
   Giallo e nero presi dal logo (il giallo e' campionato dall'immagine:
   #f0c040). Tre famiglie di colore tenute SEPARATE di proposito:
     --brand  = marchio e azioni (bottoni, fuoco, sottolineature)
     --danger = errori e "pieno"          } significato, NON estetica:
     --ok     = conferme e "disponibile"  } non seguono il marchio
   Prima esisteva un solo `--red` che faceva sia da marchio sia da errore:
   ridipingendolo di giallo, i messaggi d'errore sarebbero diventati gialli. */
:root {
  --brand: #f0c040;
  --brand-dark: #d4a626;
  --on-brand: #17130a;      /* testo sopra il giallo: il bianco non si leggerebbe */
  --plate: #0e0e0e;         /* nero della targa del logo, per barra e sfondi */
  --danger: #d32027;
  --danger-dark: #a81820;
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1d1f;
  --muted: #6b7280;
  --border: #e5e7eb;
  --green: #1faa59;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
/* Foto della palestra sfumata e scurita in Pillow, non con un filter CSS: un
   filtro sul body sfumerebbe anche i contenuti sopra, e farlo con uno
   pseudo-elemento a tutto schermo costa una ridipintura a ogni scroll. Il file
   pesa 75 KB. `background-color` si vede prima che la foto sia caricata. */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--plate);
  background-image: url('sfondo.jpg');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
}
/* Su mobile "fixed" fa scattare lo scorrimento e su iOS spesso non funziona. */
@media (max-width: 768px) {
  body { background-attachment: scroll; }
}

/* ---------------------------------------------------------- app shell */
/* Colonna opaca sopra la foto: senza, il testo finirebbe sopra i bilancieri e
   diventerebbe illeggibile. L'ombra la stacca dallo sfondo. */
.app {
  max-width: 640px; margin: 0 auto; min-height: 100vh;
  background: var(--bg);
  box-shadow: 0 0 60px rgba(0,0,0,.55);
}

/* La foto della palestra come fascia dietro la barra, su OGNI schermata (anche
   le viste a tutto schermo, che riusano .topbar). Perche' qui e non dietro tutto
   il contenuto: `.app` e `.view` sono superfici opache che sul telefono coprono
   l'intero schermo, e una foto sotto elenchi di orari e prezzi rende il testo
   faticoso da leggere. Qui il marchio si vede sempre e non intralcia nulla.
   La velatura scura serve al contrasto del logo e delle icone bianche. */
.topbar {
  background-color: var(--plate);
  background-image:
    linear-gradient(rgba(10,10,10,.70), rgba(10,10,10,.88)),
    url('sfondo.jpg');
  background-size: cover, cover;
  background-position: center 35%;
  background-repeat: no-repeat;
  color: #fff;
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .title { flex: 1; }
.topbar .userbadge {
  font-size: 13px; font-weight: 600; color: #fff;
  background: rgba(255,255,255,.18); padding: 6px 12px; border-radius: 999px;
  white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis;
}
.topbar .title small { display: block; opacity: .85; font-size: 12px; }
.topbar .title strong { font-size: 18px; }
.topbar .iconbtn {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 40px; height: 40px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  position: relative;
  display: grid; place-items: center;
}
.topbar .iconbtn .badge {
  position: absolute; top: -2px; right: -2px;
  background: var(--brand); color: var(--on-brand);
  font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px;
  display: grid; place-items: center; padding: 0 4px;
}

.content { padding: 16px; }

.alert {
  background: #fdecec;
  border: 1px solid #f5c2c2;
  color: var(--danger-dark);
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}

.section { margin-bottom: 24px; }
.section > h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 10px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

/* abbonamenti orizzontali */
.hscroll { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; }
.hscroll::-webkit-scrollbar { display: none; }
.sub-card {
  min-width: 220px;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--green);
  border-radius: var(--radius);
  padding: 14px;
}
.sub-card .name { font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.sub-card .meta { font-size: 13px; color: var(--muted); }
.sub-card .status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--green); font-weight: 600; margin-top: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; }

/* lista dati personali */
.list { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.list .row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.list .row:last-child { border-bottom: none; }
.list .row .ico { font-size: 20px; width: 26px; text-align: center; }
.list .row .lbl { flex: 1; }
.list .row .chev { color: var(--muted); }

/* chip attività */
.chips { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  min-width: 96px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
}
.chip .emoji { font-size: 26px; display: block; margin-bottom: 6px; }
.chip .cname { font-size: 13px; font-weight: 600; }

/* ---------------------------------------------------------- login */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(rgba(8,8,8,.62), rgba(8,8,8,.78));
}
.login-box {
  width: 100%; max-width: 360px;
  background: #fff; border-radius: 18px; padding: 28px 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
/* Il logo e' un'immagine con la targa nera inclusa: si appoggia su un fondo
   dello stesso nero (--plate) perche' la targa non si veda come un rettangolo
   incollato. `height:auto` con `width` in percentuale mantiene le proporzioni
   2.5:1 senza schiacciarlo. */
.brandmark {
  display: block; width: 100%; max-width: 260px; height: auto;
  margin: 0 auto 18px; border-radius: 6px;
}
.topbar .brandmark {
  width: auto; height: 30px; max-width: none; margin: 0; border-radius: 3px;
  flex: 0 0 auto;
}
.login-box h1 { margin: 0 0 4px; font-size: 22px; }
.login-box p.sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px 14px; font-size: 16px;
  border: 1px solid var(--border); border-radius: 10px;
}
.field input:focus { outline: 2px solid var(--brand); border-color: var(--brand-dark); }
.btn {
  width: 100%; padding: 13px; font-size: 16px; font-weight: 700;
  background: var(--brand); color: var(--on-brand); border: none; border-radius: 10px; cursor: pointer;
}
.btn:active { background: var(--brand-dark); }
.err { color: var(--danger); font-size: 14px; margin-bottom: 12px; min-height: 18px; }
.hint { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.6; }
.muted { color: var(--muted); }
.empty { color: var(--muted); font-style: italic; padding: 8px 0; }

/* ---------------------------------------------------------- gestore */
/* top: allineato all'altezza della barra (padding 18*2 + 40 del bottone tondo,
   che e' l'elemento piu alto). Era 68px quando il padding era 14px: cambiando
   il padding qui va rifatto il conto, o resta una fessura fra barra e schede. */
.tabs { display: flex; gap: 4px; background: #fff; border-bottom: 1px solid var(--border); overflow-x: auto; position: sticky; top: 76px; z-index: 9; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1; min-width: 96px; padding: 12px 8px; text-align: center;
  font-size: 14px; font-weight: 600; color: var(--muted);
  background: none; border: none; border-bottom: 3px solid transparent; cursor: pointer;
}
.tab.active { color: var(--text); font-weight: 700; border-bottom-color: var(--brand); }
.panel { display: none; }
.panel.active { display: block; }

.form-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 20px;
}
.form-card h3 { margin: 0 0 12px; font-size: 16px; }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.form-row > div { flex: 1; min-width: 130px; }
label.fl { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; font-size: 15px;
  border: 1px solid var(--border); border-radius: 9px; background: #fff; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); border-color: var(--brand-dark); }
.btn-sm { padding: 9px 16px; font-size: 14px; width: auto; border-radius: 9px; }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--brand-dark); }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid #f0b6b6; padding: 6px 10px; font-size: 13px; width: auto; border-radius: 8px; cursor: pointer; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; }
.check-grid label { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; }
.check-grid input { width: auto; }

.item {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px; display: flex; align-items: center; gap: 10px;
}
.item .grow { flex: 1; }
.item .t { font-weight: 600; }
.item .s { font-size: 13px; color: var(--muted); }
.pill { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.pill.ok { background: #e6f6ec; color: var(--green); }
.pill.full { background: #fdecec; color: var(--danger); }
.pill.warn { background: #fff4e0; color: #b26b00; }
.pill.off { background: #eee; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1c1d1f; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; opacity: 0; transition: opacity .2s; z-index: 50; }
.toast.show { opacity: 1; }

/* ---------------------------------------------------------- viste utente */
.view {
  display: none;
  position: fixed; inset: 0; z-index: 20;
  background: var(--bg); overflow-y: auto;
}
.view.show { display: block; }
.view .topbar .back { background: rgba(255,255,255,.15); border: none; color: #fff; width: 40px; height: 40px; border-radius: 50%; font-size: 20px; cursor: pointer; }
.view .inner { max-width: 640px; margin: 0 auto; padding: 16px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters > div { flex: 1; min-width: 120px; }

.slot {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 10px; display: flex; align-items: center; gap: 12px;
}
.slot .emoji { font-size: 24px; }
.slot .grow { flex: 1; }
.slot .t { font-weight: 700; }
.slot .s { font-size: 13px; color: var(--muted); }
.slot .act { text-align: right; }
.slot button { white-space: nowrap; }
.mini { padding: 8px 12px; font-size: 13px; font-weight: 700; border: none; border-radius: 8px; cursor: pointer; }
.mini.book { background: var(--brand); color: var(--on-brand); }
.mini.wait { background: #fff; color: #b26b00; border: 1px solid #e8c98a; }
.mini.cancel { background: #fff; color: var(--danger); border: 1px solid #f0b6b6; }
.mini.done { background: #e6f6ec; color: var(--green); cursor: default; }
.mini:disabled { opacity: .5; cursor: not-allowed; }

.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.subtab { flex: 1; padding: 10px; text-align: center; font-weight: 600; font-size: 14px; color: var(--muted); background: none; border: none; border-bottom: 3px solid transparent; cursor: pointer; }
.subtab.active { color: var(--text); font-weight: 700; border-bottom-color: var(--brand); }

.notif { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.notif.unread { border-left: 4px solid var(--brand); }
.notif .nt { font-weight: 700; }
.notif .nb { font-size: 14px; color: #444; margin-top: 2px; }
.notif .nd { font-size: 12px; color: var(--muted); margin-top: 4px; }
