/* ==========================================
   FitTracker - Dark Gym Theme
   ========================================== */
:root {
  --bg: #0d0d1a;
  --bg2: #16162b;
  --bg3: #1e1e3a;
  --surface: #252548;
  --border: #333366;
  --text: #e0e0f0;
  --text-muted: #8888aa;
  --accent: #00ff88;
  --accent-dim: #00cc6a;
  --red: #ff4466;
  --orange: #ff8844;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ========== LOGIN ========== */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: radial-gradient(ellipse at center, var(--bg2) 0%, var(--bg) 100%);
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: var(--shadow);
}
.login-logo {
  width: 64px;
  height: 64px;
  background: var(--accent);
  color: var(--bg);
  font-size: 2rem;
  font-weight: 900;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}
.login-box h1 { font-size: 1.6rem; margin-bottom: 0.3rem; }
.login-sub { color: var(--text-muted); margin-bottom: 1.5rem; font-size: 0.9rem; }
.login-footer { margin-top: 1.5rem; font-size: 0.75rem; color: var(--text-muted); }

/* ========== FORMS ========== */
.form-group { margin-bottom: 1rem; text-align: left; }
.form-group label { display: block; margin-bottom: 0.3rem; font-size: 0.85rem; color: var(--text-muted); }
input, .input-full, .input-sm {
  width: 100%;
  padding: 0.7rem 0.9rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border 0.2s;
}
input:focus { border-color: var(--accent); }
.input-sm { padding: 0.5rem 0.7rem; }

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn:hover { background: var(--bg3); }
.btn-primary { background: var(--accent); color: var(--bg); font-weight: 600; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dim); }
.btn-full { width: 100%; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.btn-logout {
  background: none;
  border: 1px solid var(--red);
  color: var(--red);
  padding: 0.4rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  transition: 0.2s;
}
.btn-logout:hover { background: var(--red); color: white; }

.error-msg { color: var(--red); font-size: 0.85rem; margin-top: 0.5rem; min-height: 1.2rem; }
.text-muted { color: var(--text-muted); }
.loading { color: var(--text-muted); font-style: italic; }

/* ========== NAV ========== */
#topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.2rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand { display: flex; align-items: center; gap: 0.5rem; }
.brand-icon {
  width: 32px; height: 32px;
  background: var(--accent); color: var(--bg);
  font-weight: 900; font-size: 1.1rem;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.brand-text { font-weight: 700; font-size: 1rem; }
.nav-links { display: flex; align-items: center; gap: 0.3rem; }
.nav-links a { text-decoration: none; padding: 0.4rem 0.6rem; border-radius: var(--radius-sm); font-size: 1.1rem; transition: 0.2s; }
.nav-links a.active { background: var(--surface); }
.nav-links a:hover { background: var(--surface); }
.mobile-toggle { display: none; background: none; border: none; color: var(--text); font-size: 1.5rem; cursor: pointer; padding: 0.2rem; }

/* ========== PAGES ========== */
#page-content { max-width: 960px; margin: 0 auto; padding: 1.2rem; }
.page-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.2rem; }
.page-header h2 { font-size: 1.3rem; }

/* ========== CARDS ========== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-bottom: 1rem;
}
.card-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.8rem; }
.card-icon { font-size: 1.2rem; }
.card-title { font-weight: 600; font-size: 0.95rem; }

.dash-cards { display: grid; gap: 1rem; grid-template-columns: 1fr; }

/* ========== WORKOUT ========== */
.workout-grid { display: grid; gap: 0.8rem; }
.day-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.day-card h3 { font-size: 0.9rem; color: var(--accent); margin-bottom: 0.5rem; }
.exercise-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.85rem;
}
.exercise-row:last-child { border-bottom: none; }
.exercise-check { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.exercise-name { flex: 1; }
.exercise-detail { color: var(--text-muted); font-size: 0.8rem; white-space: nowrap; }
.exercise-done { text-decoration: line-through; opacity: 0.5; }

/* ========== ATTENDANCE ========== */
.attendance-buttons { display: flex; gap: 0.5rem; margin: 0.5rem 0; }
.attendance-buttons .btn { flex: 1; }
.attendance-buttons .btn.attended { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.attendance-buttons .btn.missed { background: var(--red); color: white; border-color: var(--red); }

/* ========== NUTRITION ========== */
.date-nav { display: flex; justify-content: center; align-items: center; gap: 0.8rem; margin-bottom: 1rem; }
.date-nav span { min-width: 120px; text-align: center; font-weight: 600; font-size: 0.9rem; }
.nutrition-grid { display: grid; gap: 0.8rem; }
.meal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.8rem; }
.meal-card h4 { font-size: 0.8rem; color: var(--accent); margin-bottom: 0.3rem; text-transform: uppercase; letter-spacing: 0.5px; }
.meal-name { font-weight: 600; font-size: 0.95rem; }
.meal-macros { display: flex; gap: 0.8rem; margin-top: 0.3rem; font-size: 0.8rem; color: var(--text-muted); }
.meal-macros span { }
.macro-cal { color: var(--orange); }
.macro-pro { color: var(--accent); }
.macro-carbs { color: #66bbff; }
.macro-fat { color: #ffaa44; }

.macro-bar { display: flex; gap: 1rem; justify-content: center; padding: 0.8rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-top: 0.8rem; font-size: 0.85rem; }

/* Calendar month */
.cal-month { display: grid; grid-template-columns: repeat(7,1fr); gap: 2px; }
.cal-day { background: var(--bg2); border-radius: 4px; min-height: 60px; padding: 3px; font-size: 0.7rem; cursor: pointer; position: relative; }
.cal-day-num { font-weight: 600; margin-bottom: 2px; }
.cal-day.has-food { border-left: 2px solid var(--accent); }
.cal-day.today { border: 1px solid var(--accent); }
.cal-day-labels { display: grid; grid-template-columns: repeat(7,1fr); gap: 2px; margin-bottom: 4px; }
.cal-day-labels span { text-align: center; font-size: 0.7rem; color: var(--text-muted); padding: 4px 0; }

/* ========== PROGRESS ========== */
.progress-grid { display: grid; gap: 1rem; }
.weight-input-row { display: flex; gap: 0.5rem; margin-top: 0.8rem; }
.weight-input-row input { flex: 1; }
.stats-container { text-align: center; padding: 1rem 0; }
.stats-container .big-num { font-size: 2.5rem; font-weight: 800; color: var(--accent); }
.streak-container { text-align: center; padding: 1rem; }
.streak-num { font-size: 3rem; font-weight: 900; color: var(--orange); }
.streak-label { display: block; font-size: 0.8rem; color: var(--text-muted); }

.weekday-dots { display: flex; gap: 0.5rem; justify-content: center; margin-top: 0.5rem; }
.weekday-dot { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 600; }
.weekday-dot.done { background: var(--accent); color: var(--bg); }
.weekday-dot.missed { background: var(--red); color: white; }
.weekday-dot.future { background: var(--bg3); color: var(--text-muted); }

/* Profile */
.profile-form { max-width: 400px; }

/* ========== RESPONSIVE ========== */
@media(min-width: 640px) {
  .dash-cards { grid-template-columns: 1fr 1fr; }
  .workout-grid { grid-template-columns: 1fr 1fr; }
  .nutrition-grid { grid-template-columns: 1fr 1fr; }
  .progress-grid { grid-template-columns: 1fr 1fr; }
  .dash-cards > *:first-child { grid-column: 1 / -1; }
}
@media(min-width: 860px) {
  .dash-cards { grid-template-columns: 1fr 1fr 1fr; }
  .dash-cards > *:first-child { grid-column: auto; }
  .workout-grid { grid-template-columns: 1fr 1fr 1fr; }
}
@media(max-width: 639px) {
  .mobile-toggle { display: block; }
  .nav-links { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--bg2); flex-direction: column; padding: 1rem; border-bottom: 1px solid var(--border); }
  .nav-links.open { display: flex; }
  #topnav { position: relative; }
  .login-box { padding: 1.5rem; }
}

/* ========== WEEKLY SUMMARY ========== */
#dash-weekly-summary { margin-bottom: 1rem; }
.weekly-summary {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(135deg, var(--surface) 0%, #1a2a3a 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
}
.ws-emoji { font-size: 2.5rem; flex-shrink: 0; }
.ws-content { flex: 1; }
.ws-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.2rem; }
.ws-msg { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.5rem; line-height: 1.4; }
.ws-days { display: flex; gap: 6px; margin-bottom: 0.3rem; }
.ws-day {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700;
}
.ws-day.done { background: var(--accent); color: var(--bg); }
.ws-day.missed { background: var(--red); color: white; }
.ws-day.empty { background: var(--bg3); color: var(--text-muted); }
.ws-record { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }