/* GYMBRO — base.css
   Layout e componenti condivisi da tutti i temi. Ogni colore/raggio/ombra
   proviene dalle variabili definite in themes.css: cambiare tema non richiede
   ricaricare questo file. */

@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@400;500;600;700&family=Baloo+2:wght@500;600;700&display=swap');

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
  padding-bottom: 84px; /* spazio per tab bar */
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.02em; margin: 0 0 8px; }
p { margin: 0 0 12px; color: var(--text-muted); }
a { color: var(--accent); text-decoration: none; }

.container { max-width: 720px; margin: 0 auto; padding: 20px 16px 40px; }
.container-wide { max-width: 1080px; margin: 0 auto; padding: 20px 16px 40px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  background: var(--nav-bg);
  backdrop-filter: var(--surface-blur);
  -webkit-backdrop-filter: var(--surface-blur);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { font-family: var(--font-display); font-weight: 800; font-size: 20px; }
.topbar .brand span { color: var(--accent); }
.topbar .actions { display: flex; gap: 10px; align-items: center; }

/* ---------- Tab bar mobile ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; justify-content: space-around; align-items: center;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  background: var(--nav-bg);
  backdrop-filter: var(--surface-blur);
  -webkit-backdrop-filter: var(--surface-blur);
  border-top: 1px solid var(--border);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-muted); font-size: 11px; font-weight: 600;
  padding: 4px 10px; border-radius: var(--radius-s);
  transition: color var(--transition), transform var(--transition);
}
.tabbar a.active { color: var(--accent); }
.tabbar a:active { transform: scale(0.92); }
.tabbar svg { width: 24px; height: 24px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  backdrop-filter: var(--surface-blur);
  -webkit-backdrop-filter: var(--surface-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-card);
  padding: 20px;
  margin-bottom: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
}
.card-tap { cursor: pointer; }
.card-tap:active { transform: scale(0.98); }
.card-solid { background: var(--surface-solid); backdrop-filter: none; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 560px) { .grid-3 { grid-template-columns: 1fr 1fr; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-body); font-weight: 600; font-size: 15px;
  padding: 13px 20px; border-radius: var(--radius-pill);
  border: none; cursor: pointer;
  transition: transform var(--transition), opacity var(--transition), box-shadow var(--transition);
  text-align: center;
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-float); }
.btn-primary:hover { opacity: 0.92; }
.btn-secondary { background: var(--surface-solid); color: var(--text); border: 1px solid var(--border); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-icon { width: 42px; height: 42px; padding: 0; border-radius: 50%; background: var(--surface-solid); border: 1px solid var(--border); color: var(--text); }

.fab {
  position: fixed; right: 20px; bottom: 96px; z-index: 45;
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none;
  box-shadow: var(--shadow-float); font-size: 28px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: transform var(--transition);
}
.fab:active { transform: scale(0.9) rotate(90deg); }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin: 14px 0 6px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], textarea, select {
  width: 100%; padding: 13px 14px; border-radius: var(--radius-s);
  border: 1px solid var(--border); background: var(--input-bg); color: var(--text);
  font-size: 15px; font-family: var(--font-body);
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
textarea { resize: vertical; min-height: 80px; }
.field-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.checkbox-row input { width: auto; }

.chip-group { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip {
  padding: 8px 14px; border-radius: var(--radius-pill); border: 1px solid var(--border);
  background: var(--surface-solid); color: var(--text-muted); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all var(--transition); user-select: none;
}
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 4px 10px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 700; }
.badge-accent { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.badge-success { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.badge-warning { background: color-mix(in srgb, var(--warning) 20%, transparent); color: var(--warning); }
.badge-danger { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.badge-muted { background: var(--border); color: var(--text-muted); }

/* ---------- Alerts / toast ---------- */
.alert { padding: 14px 16px; border-radius: var(--radius-m); margin-bottom: 16px; font-size: 14px; }
.alert-error { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.alert-success { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); }
.alert-info { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }

#toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 12px 22px; border-radius: var(--radius-pill);
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow-float); z-index: 200;
  opacity: 0; pointer-events: none; transition: all var(--transition);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 100;
  display: none; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; animation: fadeIn var(--transition); }
.modal-sheet {
  background: var(--bg-elevated); width: 100%; max-width: 560px;
  border-radius: 24px 24px 0 0; padding: 24px; max-height: 88vh; overflow-y: auto;
  animation: slideUp 280ms cubic-bezier(.32,.72,0,1);
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal-sheet { border-radius: var(--radius-l); }
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-handle { width: 40px; height: 4px; background: var(--border); border-radius: 4px; margin: 0 auto 16px; }

/* ---------- Login / register ---------- */
.auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-logo { text-align: center; font-family: var(--font-display); font-weight: 800; font-size: 34px; margin-bottom: 6px; }
.auth-logo span { color: var(--accent); }
.auth-sub { text-align: center; color: var(--text-muted); margin-bottom: 28px; font-size: 14px; }
.auth-switch { text-align: center; margin-top: 18px; font-size: 14px; color: var(--text-muted); }

/* ---------- Dashboard ---------- */
.stat-card { text-align: center; }
.stat-value { font-family: var(--font-display); font-size: 28px; font-weight: 800; color: var(--accent); }
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

.scheda-card { display: flex; justify-content: space-between; align-items: center; }
.scheda-card .info h3 { margin-bottom: 4px; font-size: 17px; }
.scheda-card .days { display: flex; gap: 4px; margin-top: 8px; }
.day-dot { width: 22px; height: 22px; border-radius: 50%; font-size: 10px; display: flex; align-items: center; justify-content: center; background: var(--border); color: var(--text-muted); font-weight: 700; }
.day-dot.on { background: var(--accent); color: #fff; }

/* ---------- Esercizio in scheda ---------- */
.exercise-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.exercise-row:last-child { border-bottom: none; }
.exercise-thumb { width: 48px; height: 48px; border-radius: var(--radius-s); background: var(--border); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; overflow: hidden; }
.exercise-thumb img { width: 100%; height: 100%; object-fit: cover; }
.exercise-info { flex: 1; min-width: 0; }
.exercise-info h4 { margin: 0; font-size: 15px; }
.exercise-info .meta { font-size: 13px; color: var(--text-muted); }

/* ---------- Modalità allenamento ---------- */
.workout-exercise { margin-bottom: 20px; }
.workout-exercise.done { opacity: 0.55; }
.set-row { display: grid; grid-template-columns: 40px 1fr 1fr 44px; gap: 10px; align-items: center; padding: 8px 0; }
.set-row .set-num { font-weight: 700; color: var(--text-muted); text-align: center; }
.set-row input { text-align: center; padding: 10px; }
.set-check { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--border); background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-weight: 700; transition: all var(--transition); }
.set-check.checked { background: var(--success); border-color: var(--success); color: #fff; }
.timer-pill { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-pill); background: var(--accent); color: #fff; font-weight: 700; font-family: var(--font-display); }

/* ---------- Theme picker ---------- */
.theme-option { border: 2px solid transparent; border-radius: var(--radius-m); padding: 4px; cursor: pointer; transition: all var(--transition); }
.theme-option.selected { border-color: var(--accent); }
.theme-swatch { height: 70px; border-radius: calc(var(--radius-m) - 4px); display: flex; overflow: hidden; margin-bottom: 8px; }
.theme-swatch div { flex: 1; }
.theme-option-label { text-align: center; font-size: 13px; font-weight: 600; }

/* ---------- Utility ---------- */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-col { display: flex; flex-direction: column; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.small { font-size: 13px; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.skeleton { background: linear-gradient(90deg, var(--border) 25%, var(--bg) 37%, var(--border) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--radius-s); }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* Fade/slide for page content */
.page-enter { animation: pageIn 320ms cubic-bezier(.22,1,.36,1); }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Offline banner */
#offline-banner {
  display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 300;
  background: var(--warning); color: #1D1D1F; text-align: center; padding: 8px; font-size: 13px; font-weight: 700;
}
#offline-banner.show { display: block; }

table.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.admin-table th, table.admin-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.admin-table th { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }

@media (min-width: 860px) {
  .tabbar { display: none; }
  body { padding-bottom: 0; }
  .desktop-nav { position: sticky; top: 0; z-index: 40; }
}
