/* ============================================================
   MR. PARKINSON — Foglio di stile globale
   ============================================================ */

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --teal:         #2A7F7F;
  --teal-light:   #E8F4F4;
  --teal-dim:     #1F6060;
  --on-green:     #2E7D52;
  --on-green-bg:  #EAF5EE;
  --disc-amber:   #B8650A;
  --disc-bg:      #FEF3DC;
  --off-slate:    #4A5568;
  --off-bg:       #EDF2F7;
  --crampo:       #C05E00;
  --crampo-bg:    #FFF0E6;
  --red:          #C0392B;
  --red-bg:       #FDECEA;
  --red-accent:   #E03030;
  --amber:        #D4890A;
  --amber-light:  #FEF3DC;
  --violet:       #5B4FCF;
  --violet-light: #F0ECFF;
  --bg:           #F7F5F0;
  --surface:      #FFFFFF;
  --border:       #E8E3DC;
  --border-hover: #D0C8BC;
  --ink:          #1A1714;
  --ink-soft:     #6B6460;
  --ink-xsoft:    #A09890;
  --radius-sm:    10px;
  --radius-md:    16px;
  --radius-lg:    20px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.07);
  --shadow-md:    0 4px 12px rgba(0,0,0,0.10);
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
}

a { color: var(--teal); text-decoration: none; }

/* ── Header ────────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  border-left: 4px solid var(--red-accent);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo {
  width: 38px; height: 38px;
  object-fit: contain;
  flex-shrink: 0;
}

.header-brand { flex: 1; line-height: 1.25; }
.header-brand-name {
  font-size: 17px; font-weight: 500;
  color: var(--ink); letter-spacing: 0.01em;
}
.header-brand-sub {
  font-size: 11px; color: var(--ink-soft);
  font-style: italic;
}

.header-title {
  font-size: 17px; font-weight: 600;
  color: var(--ink); flex: 1;
}

.header-right { display: flex; gap: 6px; }

.back-btn {
  width: 36px; height: 36px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--ink);
  text-decoration: none; flex-shrink: 0;
}
.back-btn:hover { background: var(--border); }

.icon-btn {
  width: 34px; height: 34px;
  background: var(--bg);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--ink);
  text-decoration: none; flex-shrink: 0;
}
.icon-btn:hover { background: var(--border); }

/* ── Main ──────────────────────────────────────────────────── */
main {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Card ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

/* ── Section label ─────────────────────────────────────────── */
.section-label {
  font-size: 11px; font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 4px;
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 8px; }

.form-label {
  font-size: 12px; font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-input {
  width: 100%; padding: 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 15px; color: var(--ink);
  font-family: inherit;
  transition: border-color 0.15s;
}
.form-input:focus { outline: none; border-color: var(--teal); }

textarea.form-input { resize: none; height: 88px; }

select.form-input { cursor: pointer; }

.datetime-row { display: flex; gap: 8px; }
.datetime-row .form-input { flex: 1; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn-save {
  width: 100%; padding: 18px;
  border-radius: var(--radius-md);
  border: none; background: var(--teal);
  color: white; font-size: 16px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  margin-top: 4px;
  transition: opacity 0.15s;
}
.btn-save:active { opacity: 0.88; }

.btn-danger {
  width: 100%; padding: 16px;
  border-radius: var(--radius-md);
  border: none; background: var(--red-bg);
  color: var(--red); font-size: 15px; font-weight: 700;
  cursor: pointer; font-family: inherit;
}

.btn-secondary {
  display: block; text-align: center;
  padding: 12px; border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px; font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
}

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.alert-ok    { background: var(--on-green-bg); color: var(--on-green); border-left: 4px solid var(--on-green); }
.alert-error { background: var(--red-bg);      color: var(--red);      border-left: 4px solid var(--red); }

/* ── Bottom nav ────────────────────────────────────────────── */
.bottom-nav {
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 8px 0 16px;
  position: sticky;
  bottom: 0;
  z-index: 100;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 3px;
  text-decoration: none; padding: 6px 0;
}
.nav-icon  { font-size: 22px; }
.nav-label { font-size: 10px; font-weight: 600; color: var(--ink-soft); }
.nav-item.active .nav-label { color: var(--teal); }

/* ── Stati motori ──────────────────────────────────────────── */
.stato-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.stato-btn {
  border-radius: var(--radius-md);
  padding: 20px 14px;
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
  cursor: pointer; border: 2px solid transparent;
  text-align: center;
  opacity: 0.55;
  transition: opacity 0.15s;
}
.stato-btn.full-width { grid-column: 1 / -1; flex-direction: row; justify-content: center; gap: 12px; padding: 18px; }
.stato-btn.selected { opacity: 1; }

.stato-btn.on      { background: var(--on-green-bg); border-color: var(--on-green); }
.stato-btn.on_d    { background: var(--disc-bg);     border-color: var(--disc-amber); }
.stato-btn.off     { background: var(--off-bg);      border-color: var(--off-slate); }
.stato-btn.crampo  { background: var(--crampo-bg);   border-color: var(--crampo); }
.stato-btn.crisi   { background: var(--red-bg);      border-color: var(--red); }

.stato-btn-icon  { font-size: 30px; }
.stato-btn-label { font-size: 13px; font-weight: 700; }
.stato-btn.on     .stato-btn-label { color: var(--on-green); }
.stato-btn.on_d   .stato-btn-label { color: var(--disc-amber); }
.stato-btn.off    .stato-btn-label { color: var(--off-slate); }
.stato-btn.crampo .stato-btn-label { color: var(--crampo); }
.stato-btn.crisi  .stato-btn-label { color: var(--red); }

/* ── Intensità ─────────────────────────────────────────────── */
.intensita-row { display: flex; gap: 8px; }

.int-btn {
  flex: 1; text-align: center; padding: 14px 0;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--surface);
  font-size: 16px; font-weight: 700;
  color: var(--ink-soft); cursor: pointer;
  transition: all 0.15s;
}
.int-btn.sel { background: var(--teal); border-color: var(--teal); color: white; }

/* ── Select list ───────────────────────────────────────────── */
.select-item {
  padding: 14px 18px;
  display: flex; align-items: center; gap: 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.select-item:last-child { border-bottom: none; }
.select-item.sel { background: var(--teal-light); }
.select-item-icon { font-size: 22px; flex-shrink: 0; }
.select-item-name { font-size: 15px; font-weight: 600; }
.select-item-sub  { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.select-check     { color: var(--teal); font-size: 18px; display: none; }
.select-item.sel .select-check { display: block; }

/* ── Toggle stomaco ────────────────────────────────────────── */
.toggle-row { display: flex; gap: 8px; }
.toggle-btn {
  flex: 1; text-align: center; padding: 14px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--surface);
  font-size: 14px; font-weight: 600;
  color: var(--ink-soft); cursor: pointer;
  transition: all 0.15s;
}
.toggle-btn.sel { background: var(--teal-light); border-color: var(--teal); color: var(--teal-dim); }

/* ── Durata attività ───────────────────────────────────────── */
.durata-row { display: flex; gap: 8px; flex-wrap: wrap; }
.durata-btn {
  padding: 10px 14px; border-radius: var(--radius-sm);
  border: 2px solid var(--border); background: var(--surface);
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
  cursor: pointer; font-family: inherit;
  transition: all 0.15s;
}
.durata-btn.sel { background: var(--violet-light); border-color: var(--violet); color: var(--violet); }

/* ── Intervallo monitoraggio ───────────────────────────────── */
.interval-btn {
  padding: 8px 14px; border-radius: 20px;
  border: 2px solid var(--border); background: var(--surface);
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
  cursor: pointer; font-family: inherit;
}
.interval-btn.sel { background: var(--teal-light); border-color: var(--teal); color: var(--teal-dim); }

/* ── Dose stepper ──────────────────────────────────────────── */
.dose-row { display: flex; align-items: center; gap: 12px; }
.dose-btn {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 20px; font-weight: 700;
  color: var(--ink); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.dose-val  { flex: 1; text-align: center; font-size: 20px; font-weight: 700; }
.dose-unit { font-size: 13px; color: var(--ink-soft); font-weight: 500; }

/* ── Storico entries ───────────────────────────────────────── */
.entry {
  padding: 12px 18px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border);
}
.entry:last-child { border-bottom: none; }
.entry-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.entry-info { flex: 1; }
.entry-type   { font-size: 11px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.05em; }
.entry-detail { font-size: 14px; font-weight: 500; color: var(--ink); margin-top: 1px; }
.entry-time   { font-size: 12px; color: var(--ink-soft); font-weight: 500; flex-shrink: 0; }

/* ── Settings rows ─────────────────────────────────────────── */
.settings-row {
  padding: 14px 18px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.settings-row:last-child { border-bottom: none; }
.settings-row-icon  { font-size: 20px; flex-shrink: 0; }
.settings-row-label { font-size: 15px; font-weight: 600; color: var(--ink); flex: 1; }
.settings-row-sub   { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.settings-row-arrow { color: var(--ink-xsoft); font-size: 14px; }

/* ── Badge categorie ───────────────────────────────────────── */
.cat-badge {
  display: inline-block; padding: 2px 8px;
  border-radius: 20px; font-size: 11px; font-weight: 700;
}
.cat-alta     { background: var(--red-bg);      color: var(--red); }
.cat-moderata { background: var(--disc-bg);      color: var(--disc-amber); }
.cat-neutra   { background: var(--on-green-bg);  color: var(--on-green); }
.cat-zuccheri { background: #F3E8FF;             color: #7B3FA0; }
.cat-fibre    { background: #F0F5E6;             color: #6B8E23; }
.cat-grassi   { background: #FBEEE6;             color: #A0522D; }

/* ── Hero card ─────────────────────────────────────────────── */
.hero-card {
  background: linear-gradient(135deg, var(--teal) 0%, #1F6B6B 100%);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  display: flex; align-items: center; gap: 20px;
  box-shadow: var(--shadow-md);
}
.hero-number {
  font-size: 72px; font-weight: 800;
  color: white; line-height: 1; min-width: 90px; text-align: center;
}
.hero-label-top  { font-size: 11px; font-weight: 600; color: rgba(255,255,255,0.65); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; }
.hero-label-main { font-size: 17px; font-weight: 600; color: white; line-height: 1.3; }
.hero-label-sub  { font-size: 12px; color: rgba(255,255,255,0.60); margin-top: 6px; }

/* ── Registra grid (home) ──────────────────────────────────── */
.reg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.reg-btn {
  border-radius: var(--radius-md);
  padding: 18px 14px;
  display: flex; flex-direction: column;
  align-items: flex-start; gap: 8px;
  text-decoration: none;
  transition: filter 0.15s;
}
.reg-btn:active { filter: brightness(0.94); }
.reg-btn-icon  { font-size: 28px; }
.reg-btn-label { font-size: 13px; font-weight: 700; line-height: 1.2; }

.reg-btn.stato    { background: var(--on-green-bg); }
.reg-btn.farmaco  { background: var(--teal-light); }
.reg-btn.pasto    { background: var(--amber-light); }
.reg-btn.attivita { background: var(--violet-light); }
.reg-btn.stato    .reg-btn-label { color: var(--on-green); }
.reg-btn.farmaco  .reg-btn-label { color: var(--teal-dim); }
.reg-btn.pasto    .reg-btn-label { color: var(--amber); }
.reg-btn.attivita .reg-btn-label { color: var(--violet); }

/* ── Reminder tag ──────────────────────────────────────────── */
.reminder-tag {
  padding: 3px 10px; border-radius: 20px;
  background: var(--teal-light); color: var(--teal-dim);
  font-size: 12px; font-weight: 600;
}

/* ── Switch toggle ─────────────────────────────────────────── */
.switch-ui {
  width: 48px; height: 28px; border-radius: 14px;
  position: relative; cursor: pointer;
  transition: background 0.2s;
}
.switch-ui .knob {
  position: absolute; width: 22px; height: 22px;
  border-radius: 50%; background: white; top: 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: all 0.2s;
}

/* ── Login page ────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 32px 24px; max-width: 480px; margin: 0 auto;
  background: var(--bg);
}
.login-logo    { width: 180px; max-width: 75%; margin-bottom: 20px; }
.login-title   { font-size: 28px; font-weight: 700; color: var(--ink); margin-bottom: 6px; text-align: center; }
.login-sub     { font-size: 15px; color: var(--ink-soft); text-align: center; line-height: 1.6; margin-bottom: 44px; }
.btn-google {
  width: 100%; padding: 18px 24px;
  border-radius: var(--radius-md); border: 2px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center; gap: 14px;
  font-size: 16px; font-weight: 700; color: var(--ink);
  text-decoration: none; box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.btn-google:active { opacity: 0.85; }
.login-note { font-size: 12px; color: var(--ink-soft); text-align: center; line-height: 1.6; }

/* ── Console SQL ───────────────────────────────────────────── */
.sql-console {
  background: #1E1C1A; border-radius: var(--radius-sm);
  padding: 16px; margin-bottom: 12px;
}
.sql-console textarea {
  width: 100%; background: #2D2A27; color: #E8E3DC;
  border: 1.5px solid #3D3A37; border-radius: 8px;
  padding: 13px; font-family: monospace; font-size: 13px;
  line-height: 1.6; resize: vertical; min-height: 80px;
}
.sql-console textarea:focus { outline: none; border-color: var(--teal); }
.sql-run-btn {
  margin-top: 10px; padding: 11px 24px;
  border-radius: 8px; border: none;
  background: var(--teal); color: white;
  font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit;
}

/* ── Utility ───────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-muted  { color: var(--ink-soft); }
.mt-4        { margin-top: 4px; }
.mt-8        { margin-top: 8px; }
.mt-12       { margin-top: 12px; }
.fw-700      { font-weight: 700; }
.fs-12       { font-size: 12px; }
.fs-13       { font-size: 13px; }
.fs-14       { font-size: 14px; }
