/* Nasconde il pannello di riconnessione Blazor */
#components-reconnect-modal { display: none !important; }
#blazor-error-ui            { display: none !important; }

/* ── Tokens ─────────────────────────────────────────────────── */
:root {
  --bg:        #0d1117;
  --surf:      #161b22;
  --surf2:     #21262d;
  --surf3:     #30363d;
  --border:    rgba(240,246,252,.1);
  --text:      #e6edf3;
  --muted:     #8b949e;
  --accent:    #58a6ff;
  --green:     #3fb950;
  --yellow:    #d29922;
  --red:       #f85149;
  --sidebar-w: 240px;
  --topbar-h:  52px;
  --tabbar-h:  60px;
}

[data-theme="light"] {
  --bg:        #f6f8fa;
  --surf:      #ffffff;
  --surf2:     #f0f2f5;
  --surf3:     #e4e7eb;
  --border:    rgba(0,0,0,.1);
  --text:      #1c1e21;
  --muted:     #6b7280;
  --accent:    #0969da;
  --green:     #1a7f37;
  --yellow:    #9a6700;
  --red:       #cf222e;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  /* override app.css */
  display: block !important;
  justify-content: unset !important;
  align-items: unset !important;
}

a { color: inherit; text-decoration: none; }

/* ── Shell ──────────────────────────────────────────────────── */
.wa-shell {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.wa-sidebar {
  width: var(--sidebar-w);
  background: var(--surf);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.wa-sidebar-brand {
  padding: 1.25rem 1rem 0.5rem;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -.025em;
  color: var(--text);
}

.wa-sidebar-section {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding: 1rem 1rem 0.3rem;
}

.wa-nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.875rem;
  margin: 0 0.5rem;
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--muted);
  transition: background .12s, color .12s;
  cursor: pointer;
}
.wa-nav-link:hover  { background: var(--surf2); color: var(--text); }
.wa-nav-link.active { background: rgba(88,166,255,.12); color: var(--accent); font-weight: 600; }
.wa-nav-icon { font-size: 1rem; width: 1.25rem; text-align: center; flex-shrink: 0; }

.wa-sidebar-footer {
  margin-top: auto;
  padding: 0.875rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.wa-sidebar-footer strong { color: var(--text); font-weight: 500; }

/* ── Main area ──────────────────────────────────────────────── */
.wa-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Topbar (mobile) ────────────────────────────────────────── */
.wa-topbar {
  height: var(--topbar-h);
  background: var(--surf);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  flex-shrink: 0;
}
.wa-topbar-brand { font-weight: 800; font-size: 1.05rem; }
.wa-topbar-user  { font-size: 0.78rem; color: var(--muted); }

/* ── Content ────────────────────────────────────────────────── */
.wa-content {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.25rem 1rem;
}
@media (min-width: 768px) {
  .wa-content { padding: 2rem 2.5rem; max-width: 900px; }
}

/* ── Bottom tabbar (mobile) ─────────────────────────────────── */
.wa-tabbar {
  height: var(--tabbar-h);
  background: var(--surf);
  border-top: 1px solid var(--border);
  display: flex;
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom);
}
.wa-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.6rem;
  color: var(--muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color .12s;
}
.wa-tab .ti { font-size: 1.2rem; line-height: 1; }
.wa-tab.active { color: var(--accent); }

/* ── Page header ────────────────────────────────────────────── */
.wa-page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: .5rem;
}
.wa-page-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.02em;
}
.wa-page-sub { font-size: 0.82rem; color: var(--muted); }

/* ── Cards ──────────────────────────────────────────────────── */
.wa-card {
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: .75rem;
}
.wa-card-title { font-weight: 600; font-size: .9rem; margin-bottom: .125rem; }
.wa-card-sub   { font-size: .78rem; color: var(--muted); }

/* ── Progress bar ───────────────────────────────────────────── */
.wa-progress-wrap {
  background: var(--surf2);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
}
.wa-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width .4s ease;
}

/* ── Habit row ──────────────────────────────────────────────── */
.wa-habit {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .75rem .875rem;
  margin-bottom: .5rem;
  transition: border-color .15s;
}
.wa-habit.done   { border-color: rgba(63,185,80,.3); }
.wa-habit.skipped{ border-color: rgba(139,148,158,.2); opacity: .7; }
.wa-habit-info   { flex: 1; min-width: 0; }
.wa-habit-name   { font-size: .9rem; font-weight: 500; white-space: normal; overflow: hidden; }
.wa-habit-meta   { font-size: .73rem; color: var(--muted); margin-top: 1px; }
.wa-habit-actions{ display: flex; gap: .375rem; flex-shrink: 0; }
.wa-emoji-edit-btn { background: none; border: none; cursor: pointer; font-size: .75rem; opacity: .35; padding: 0 .2rem; vertical-align: middle; line-height: 1; }
.wa-emoji-edit-btn:hover { opacity: 1; }
.wa-emoji-row .wa-input-sm { padding: .2rem .4rem; font-size: 1.2rem; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge-done    { background: rgba(63,185,80,.15);   color: var(--green);  border-radius: 6px; padding: .25rem .6rem; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.badge-skip    { background: rgba(139,148,158,.15); color: var(--muted);  border-radius: 6px; padding: .25rem .6rem; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.badge-rest    { background: rgba(139,148,158,.1);  color: var(--surf3);  border-radius: 6px; padding: .25rem .6rem; font-size: .75rem; font-weight: 600; white-space: nowrap; }

/* ── Buttons ────────────────────────────────────────────────── */
.wa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding: .45rem .9rem;
  border-radius: 6px;
  font-size: .82rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity .12s, background .12s;
  white-space: nowrap;
}
.wa-btn:active { opacity: .7; }
.wa-btn-sm  { padding: .3rem .65rem; font-size: .75rem; }
.wa-btn-lg  { padding: .65rem 1.25rem; font-size: .95rem; }
.wa-btn-full{ width: 100%; }

.wa-btn-primary { background: var(--accent);  color: #0d1117; border-color: var(--accent); }
.wa-btn-primary:hover { background: #79bafb; }
.wa-btn-success { background: var(--green);   color: #0d1117; border-color: var(--green); }
.wa-btn-success:hover { background: #57d468; }
.wa-btn-danger  { background: var(--red);     color: #fff;    border-color: var(--red); }
.wa-btn-ghost   { background: var(--surf2);   color: var(--text); border-color: var(--border); }
.wa-btn-ghost:hover { background: var(--surf3); }
.wa-btn-outline { background: transparent;    color: var(--muted); border-color: var(--border); }
.wa-btn-outline:hover { color: var(--text); border-color: var(--surf3); background: var(--surf2); }

/* ── Inputs ─────────────────────────────────────────────────── */
.wa-input, .wa-select {
  width: 100%;
  background: var(--surf2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: .55rem .75rem;
  font-size: .875rem;
  outline: none;
  transition: border-color .15s;
}
.wa-input:focus, .wa-select:focus { border-color: var(--accent); }
.wa-input-no-spin::-webkit-outer-spin-button,
.wa-input-no-spin::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.wa-input-no-spin { -moz-appearance: textfield; }
.wa-label { font-size: .78rem; color: var(--muted); margin-bottom: .3rem; display: block; }

/* ── Toggle ─────────────────────────────────────────────────── */
.wa-toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.wa-toggle input { opacity: 0; width: 0; height: 0; }
.wa-toggle-track {
  position: absolute; inset: 0;
  background: var(--surf3); border-radius: 99px; cursor: pointer;
  transition: background .2s;
}
.wa-toggle-track::before {
  content: ''; position: absolute;
  left: 3px; top: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--muted);
  transition: transform .2s, background .2s;
}
.wa-toggle input:checked + .wa-toggle-track { background: var(--accent); }
.wa-toggle input:checked + .wa-toggle-track::before { transform: translateX(18px); background: #fff; }

/* ── Setting row ────────────────────────────────────────────── */
.wa-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .7rem 0;
  border-bottom: 1px solid var(--border);
}
.wa-setting-row:last-child { border-bottom: none; }
.wa-setting-label { font-size: .875rem; }
.wa-setting-value { font-size: .8rem; color: var(--muted); text-align: right; }

/* ── Status dot ─────────────────────────────────────────────── */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot-green { background: var(--green); }
.dot-red   { background: var(--red); }
.dot-muted { background: var(--muted); }

/* ── Divider ────────────────────────────────────────────────── */
.wa-divider { height: 1px; background: var(--border); margin: .75rem 0; }

/* ── Empty state ────────────────────────────────────────────── */
.wa-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.wa-empty-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.wa-empty p { font-size: .875rem; line-height: 1.6; }

/* ── Quick preset pills ─────────────────────────────────────── */
.wa-presets { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.wa-preset  {
  padding: .35rem .75rem; border-radius: 99px;
  background: var(--surf2); border: 1px solid var(--border);
  font-size: .8rem; color: var(--muted); cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.wa-preset:hover, .wa-preset.sel { background: rgba(88,166,255,.15); color: var(--accent); border-color: var(--accent); }

/* ── Timer card ─────────────────────────────────────────────── */
.wa-timer-card {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .75rem .875rem;
  margin-bottom: .5rem;
}
.wa-timer-time {
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  min-width: 3.5rem;
}

/* ── Meal card ──────────────────────────────────────────────── */
.wa-meal-card {
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.wa-meal-pick {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  padding: .5rem;
  background: rgba(88,166,255,.08);
  border-radius: 6px;
  text-align: center;
  animation: pop .25s ease;
}
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ── Sleep quick action ─────────────────────────────────────── */
.wa-sleep-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  padding: 1.5rem;
  border-radius: 12px;
  background: var(--surf);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  text-align: center;
  flex: 1;
}
.wa-sleep-btn:hover { border-color: var(--accent); background: rgba(88,166,255,.05); }
.wa-sleep-btn .icon { font-size: 2.5rem; }
.wa-sleep-btn .label { font-size: .85rem; font-weight: 600; color: var(--text); }
.wa-sleep-btn .sub   { font-size: .75rem; color: var(--muted); }

/* ── Page loader overlay ─────────────────────────────────────── */
.wa-loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,17,23,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}
.wa-loader-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--surf3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: wa-spin .75s linear infinite;
}
@keyframes wa-spin { to { transform: rotate(360deg); } }

/* ── Section card grid ──────────────────────────────────────── */
.wa-section-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .875rem;
  padding: .25rem 0 1rem;
}
.wa-section-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  padding: 1.75rem 1rem;
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
  text-align: center;
  color: var(--text);
  text-decoration: none;
}
.wa-section-card:hover  { background: var(--surf2); border-color: var(--accent); color: var(--text); }
.wa-section-card:active { transform: scale(.97); }
.wa-section-card .sc-icon  { font-size: 2.25rem; line-height: 1; }
.wa-section-card .sc-label { font-size: .875rem; font-weight: 600; }
.wa-section-card .sc-sub   { font-size: .73rem; color: var(--muted); }

/* ── Section nav select ─────────────────────────────────────── */
.wa-nav-select-wrap {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.25rem;
}
.wa-nav-back {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  padding: .35rem .6rem;
  font-size: 1rem;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  flex-shrink: 0;
}
.wa-nav-back:hover { border-color: var(--accent); color: var(--accent); }
.wa-nav-select {
  flex: 1;
  background: var(--surf2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: .9rem;
  font-weight: 600;
  padding: .45rem .75rem;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238b949e' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2rem;
  cursor: pointer;
}
.wa-nav-select:focus { outline: none; border-color: var(--accent); }
.wa-nav-select option { background: var(--surf2); }

/* ── Feedback toast ─────────────────────────────────────────── */
.wa-toast {
  position: fixed;
  bottom: calc(var(--tabbar-h) + 1rem);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surf2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .6rem 1.25rem;
  font-size: .85rem;
  z-index: 1000;
  animation: slideUp .2s ease;
  white-space: nowrap;
}
@media (min-width: 768px) {
  .wa-toast { bottom: 1.5rem; }
}
@keyframes slideUp { from { transform: translateX(-50%) translateY(10px); opacity: 0; } to { transform: translateX(-50%) translateY(0); opacity: 1; } }
.wa-toast-ok  { border-color: rgba(63,185,80,.4);  color: var(--green); }
.wa-toast-err { border-color: rgba(248,81,73,.4);  color: var(--red); }

/* ── Archiviatore ───────────────────────────────────────────── */
.archiviatore-section .card,
.archiviatore-section .list-group-item {
  background: var(--surf);
  border-color: var(--border);
  color: var(--text);
}

.archiviatore-section .list-group-item {
  border-radius: 10px !important;
  margin-bottom: .5rem;
  border: 1px solid var(--border);
}

.archiviatore-section .list-group {
  gap: .5rem;
  display: flex;
  flex-direction: column;
}

.archiviatore-section .doc-row {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  min-width: 0;
}

.archiviatore-section .doc-info {
  flex: 1;
  min-width: 0;
}

.archiviatore-section .doc-info .fw-semibold {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archiviatore-section .doc-actions {
  display: flex;
  gap: .25rem;
  flex-shrink: 0;
  align-items: center;
}

.archiviatore-section .text-muted { color: var(--muted) !important; }
.archiviatore-section .card-title { color: var(--text); }
.archiviatore-section .form-control {
  background: var(--surf2);
  border-color: var(--border);
  color: var(--text);
}
.archiviatore-section .form-control:focus {
  background: var(--surf2);
  border-color: var(--accent);
  color: var(--text);
  box-shadow: none;
}

/* ── Landing ────────────────────────────────────────────────── */
.wa-landing {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--bg);
}
.wa-landing-box {
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.wa-landing-logo  { font-size: 3.5rem; margin-bottom: 1rem; }
.wa-landing-title { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; margin-bottom: .5rem; }
.wa-landing-sub   { color: var(--muted); font-size: .9rem; margin-bottom: 2rem; line-height: 1.7; }
.wa-landing-step  {
  display: flex;
  align-items: center;
  gap: .875rem;
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75rem 1rem;
  margin-bottom: .5rem;
  font-size: .875rem;
  text-align: left;
}
.wa-step-num {
  width: 24px; height: 24px;
  background: rgba(88,166,255,.15);
  color: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700;
  flex-shrink: 0;
}
