/* ============================================================
   FITFORGE - Premium Dark Athletic Theme
   ============================================================ */

:root {
  --bg: #09090b;
  --bg-card: #18181b;
  --bg-card-hover: #1f1f23;
  --bg-input: #27272a;
  --border: #27272a;
  --border-light: rgba(255,255,255,0.06);
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;
  --emerald: #10b981;
  --emerald-dark: #059669;
  --cyan: #06b6d4;
  --orange: #f59e0b;
  --rose: #f43f5e;
  --purple: #a855f7;
  --blue: #3b82f6;
  --amber: #f59e0b;
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --nav-height: 64px;
  --header-height: 56px;
}

* { margin:0; padding:0; box-sizing:border-box; }
html { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
input[type="number"] { -moz-appearance: textfield; }
::selection { background: rgba(16,185,129,0.3); }
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #27272a; border-radius: 2px; }

/* ---- Layout ---- */
.app { display: flex; flex-direction: column; min-height: 100vh; }
.page { flex:1; padding: 16px 16px 80px; max-width: 480px; margin: 0 auto; width: 100%; }
.page.with-header { padding-top: 72px; }
.hidden { display: none !important; }

/* ---- Header ---- */
.header {
  position: fixed; top:0; left:0; right:0; z-index:40;
  background: rgba(9,9,11,0.92); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  height: var(--header-height);
}
.header-inner {
  max-width: 480px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; height: 100%;
}
.header-title { font-size: 18px; font-weight: 800; }
.header-subtitle { font-size: 11px; color: var(--text-dim); }
.header-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--emerald), var(--cyan));
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: #000; cursor: pointer;
}
.header-back {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 4px; margin-right: 8px; font-size: 20px;
}

/* ---- Bottom Nav ---- */
.bottom-nav {
  position: fixed; bottom:0; left:0; right:0; z-index:50;
  background: rgba(9,9,11,0.95); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-light);
  height: var(--nav-height);
}
.bottom-nav-inner {
  max-width: 480px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-around;
  height: 100%; padding: 0 8px;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 12px; border-radius: 12px;
  color: var(--text-dim); text-decoration: none;
  transition: color 0.2s; cursor: pointer; border: none; background: none;
  font-family: inherit;
}
.nav-item.active { color: var(--emerald); }
.nav-item svg { width: 20px; height: 20px; }
.nav-item span { font-size: 10px; font-weight: 500; }

/* ---- Cards ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.card-title {
  font-size: 11px; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600; margin-bottom: 8px;
}

/* ---- Stat Cards ---- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.stat-card {
  border-radius: var(--radius); padding: 12px;
  border: 1px solid var(--border-light);
  position: relative; overflow: hidden;
}
.stat-card.emerald { background: linear-gradient(135deg, rgba(16,185,129,0.15), rgba(16,185,129,0.03)); border-color: rgba(16,185,129,0.15); }
.stat-card.cyan { background: linear-gradient(135deg, rgba(6,182,212,0.15), rgba(6,182,212,0.03)); border-color: rgba(6,182,212,0.15); }
.stat-card.orange { background: linear-gradient(135deg, rgba(245,158,11,0.15), rgba(245,158,11,0.03)); border-color: rgba(245,158,11,0.15); }
.stat-card.purple { background: linear-gradient(135deg, rgba(168,85,247,0.15), rgba(168,85,247,0.03)); border-color: rgba(168,85,247,0.15); }
.stat-card.blue { background: linear-gradient(135deg, rgba(59,130,246,0.15), rgba(59,130,246,0.03)); border-color: rgba(59,130,246,0.15); }
.stat-card.amber { background: linear-gradient(135deg, rgba(245,158,11,0.15), rgba(245,158,11,0.03)); border-color: rgba(245,158,11,0.15); }
.stat-card.rose { background: linear-gradient(135deg, rgba(244,63,94,0.15), rgba(244,63,94,0.03)); border-color: rgba(244,63,94,0.15); }
.stat-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.stat-value { font-size: 24px; font-weight: 800; color: var(--text); margin-top: 2px; }
.stat-unit { font-size: 11px; color: var(--text-dim); font-weight: 400; margin-left: 2px; }

/* ---- XP Bar ---- */
.xp-bar-container { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.xp-level-badge {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--amber), #ea580c);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 900; color: #fff;
  box-shadow: 0 4px 12px rgba(245,158,11,0.3);
}
.xp-info { margin-left: 10px; flex: 1; }
.xp-title { font-size: 14px; font-weight: 700; }
.xp-sub { font-size: 10px; color: var(--text-dim); }
.xp-numbers { text-align: right; }
.xp-total { font-size: 14px; font-weight: 700; color: var(--amber); }
.xp-next { font-size: 10px; color: var(--text-dim); }
.xp-track {
  width: 100%; height: 10px; background: var(--bg-input);
  border-radius: 5px; overflow: hidden; margin-top: 8px;
}
.xp-fill {
  height: 100%; border-radius: 5px;
  background: linear-gradient(90deg, var(--amber), #ea580c);
  transition: width 1s ease;
}

/* ---- Streak ---- */
.streak-card { display: flex; align-items: center; gap: 12px; }
.streak-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; background: var(--bg-input);
}
.streak-icon.fire { background: linear-gradient(135deg, rgba(245,158,11,0.2), rgba(239,68,68,0.2)); border: 1px solid rgba(245,158,11,0.2); }
.streak-value { font-size: 28px; font-weight: 900; }
.streak-label { font-size: 11px; color: var(--text-dim); }
.streak-dots { display: flex; gap: 3px; margin-left: auto; }
.streak-dot { width: 6px; height: 20px; border-radius: 3px; background: var(--bg-input); }
.streak-dot.active { background: linear-gradient(to top, var(--emerald), #34d399); }

/* ---- Buttons ---- */
.btn {
  width: 100%; padding: 14px; border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 700; cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
  font-family: inherit;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--emerald-dark), var(--emerald));
  color: #fff; box-shadow: 0 4px 12px rgba(16,185,129,0.25);
}
.btn-gradient {
  background: linear-gradient(135deg, var(--emerald-dark), var(--cyan));
  color: #fff; box-shadow: 0 4px 16px rgba(16,185,129,0.2);
}
.btn-secondary { background: var(--bg-input); color: var(--text-muted); }
.btn-danger { background: rgba(244,63,94,0.1); border: 1px solid rgba(244,63,94,0.2); color: var(--rose); }
.btn-sm { padding: 8px 16px; font-size: 12px; width: auto; }
.btn-outline { background: none; border: 1px dashed var(--border); color: var(--text-dim); }

/* ---- Inputs ---- */
.input-group { margin-bottom: 12px; }
.input-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; margin-bottom: 4px; display: block; }
.input {
  width: 100%; padding: 12px 16px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px; outline: none;
  transition: border-color 0.2s; font-family: inherit;
}
.input:focus { border-color: var(--emerald); }
.input-center { text-align: center; }
select.input { appearance: none; cursor: pointer; }

/* ---- Progress Bars ---- */
.progress-track { height: 6px; background: var(--bg-input); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.progress-fill.emerald { background: linear-gradient(90deg, var(--emerald-dark), var(--emerald)); }
.progress-fill.cyan { background: linear-gradient(90deg, #0891b2, var(--cyan)); }
.progress-fill.orange { background: linear-gradient(90deg, #d97706, var(--orange)); }
.progress-fill.rose { background: linear-gradient(90deg, #e11d48, var(--rose)); }

/* ---- Workout Card ---- */
.exercise-card { cursor: pointer; transition: background 0.15s; }
.exercise-card:active { background: var(--bg-card-hover); }
.exercise-header { display: flex; align-items: center; justify-content: space-between; }
.exercise-count {
  width: 36px; height: 36px; border-radius: 8px; background: var(--bg-input);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--emerald);
}
.exercise-info { flex: 1; margin-left: 12px; }
.exercise-name { font-size: 14px; font-weight: 600; }
.exercise-meta { font-size: 10px; color: var(--text-dim); }
.exercise-arrow { color: var(--text-dim); transition: transform 0.2s; font-size: 14px; }
.exercise-arrow.open { transform: rotate(180deg); }
.exercise-body { padding-top: 12px; border-top: 1px solid var(--border-light); margin-top: 12px; }
.set-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px; font-size: 12px; color: var(--text-muted);
  background: rgba(255,255,255,0.02); border-radius: 8px; margin-bottom: 4px;
}
.set-inputs { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 8px 0; }

/* ---- Meal Card ---- */
.meal-header { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.meal-icon { font-size: 20px; margin-right: 10px; }
.meal-name { font-size: 14px; font-weight: 600; flex:1; }
.meal-cals { font-size: 13px; font-weight: 600; text-align: right; }
.meal-protein { font-size: 10px; color: var(--cyan); text-align: right; }

.food-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: var(--radius-xs);
  margin-bottom: 6px; transition: background 0.15s;
}
.food-item.done { background: rgba(16,185,129,0.08); border: 1px solid rgba(16,185,129,0.15); }
.food-item:not(.done) { background: rgba(255,255,255,0.02); }
.food-check {
  width: 20px; height: 20px; border-radius: 6px;
  border: 2px solid var(--border); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; flex-shrink: 0; background: none;
  color: transparent; font-size: 12px;
}
.food-check.checked { background: var(--emerald); border-color: var(--emerald); color: #fff; }
.food-name { font-size: 12px; font-weight: 500; flex:1; }
.food-name.checked-text { color: #6ee7b7; }
.food-macros { font-size: 10px; color: var(--text-dim); }
.food-grams {
  font-size: 11px; color: var(--text-muted); padding: 4px 8px;
  background: var(--bg-input); border-radius: 6px; cursor: pointer;
  border: none; font-family: inherit;
}

/* ---- Hydration ---- */
.water-glasses { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.water-glass { width: 16px; height: 20px; border-radius: 3px; background: var(--bg-input); transition: background 0.2s; }
.water-glass.filled { background: rgba(6,182,212,0.6); }
.water-buttons { display: flex; gap: 8px; }
.water-btn {
  flex:1; padding: 10px; background: var(--bg-input); border: none;
  border-radius: var(--radius-xs); color: var(--text-muted);
  font-size: 12px; font-weight: 500; cursor: pointer;
  transition: background 0.15s; font-family: inherit;
}
.water-btn:active { background: rgba(6,182,212,0.15); }

/* ---- Macro Rings ---- */
.macro-rings { display: flex; justify-content: space-around; padding: 12px 0; }
.macro-ring { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.macro-ring svg { width: 60px; height: 60px; }
.macro-ring-value { font-size: 12px; font-weight: 700; }
.macro-ring-label { font-size: 10px; color: var(--text-dim); }
.macro-ring-goal { font-size: 9px; color: #52525b; }

/* ---- Metric Grid ---- */
.metric-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.metric-btn {
  padding: 10px; border-radius: var(--radius-xs); text-align: left;
  border: 1px solid var(--border-light); background: var(--bg-card);
  cursor: pointer; transition: all 0.15s; font-family: inherit; color: var(--text);
}
.metric-btn.active { background: rgba(16,185,129,0.1); border-color: rgba(16,185,129,0.25); }
.metric-label { font-size: 9px; color: var(--text-dim); }
.metric-value { font-size: 13px; font-weight: 700; }
.metric-diff { font-size: 9px; }
.metric-diff.up { color: var(--emerald); }
.metric-diff.down { color: var(--rose); }

/* ---- Run Card ---- */
.run-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px; border-radius: var(--radius-xs);
  background: var(--bg-card); border: 1px solid var(--border-light);
  margin-bottom: 8px;
}

/* ---- PR Cards ---- */
.pr-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.pr-card {
  text-align: center; padding: 10px; border-radius: var(--radius-xs);
  background: rgba(255,255,255,0.02);
}
.pr-label { font-size: 12px; font-weight: 700; color: var(--amber); }
.pr-value { font-size: 20px; font-weight: 800; margin-top: 4px; }
.pr-unit { font-size: 9px; color: var(--text-dim); }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--bg-card); border-radius: var(--radius-sm); margin-bottom: 16px; }
.tab-btn {
  flex:1; padding: 10px; border: none; border-radius: var(--radius-xs);
  font-size: 12px; font-weight: 500; cursor: pointer;
  background: none; color: var(--text-dim); transition: all 0.15s;
  font-family: inherit;
}
.tab-btn.active { background: var(--emerald-dark); color: #fff; }

/* ---- Login ---- */
.login-page {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px;
}
.login-logo {
  width: 80px; height: 80px; border-radius: 20px;
  background: linear-gradient(135deg, var(--emerald), var(--cyan));
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; margin-bottom: 16px;
  box-shadow: 0 8px 32px rgba(16,185,129,0.25);
}
.login-title { font-size: 28px; font-weight: 900; margin-bottom: 4px; }
.login-sub { font-size: 13px; color: var(--text-dim); margin-bottom: 32px; }
.login-form { width: 100%; max-width: 320px; }
.login-error { font-size: 12px; color: var(--rose); text-align: center; margin-top: 8px; }

/* ---- Loading ---- */
.loading {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 40px; gap: 12px;
}
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--bg-input);
  border-top-color: var(--emerald); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-content {
  width: 100%; max-width: 480px;
  background: var(--bg-card); border-radius: 24px 24px 0 0;
  padding: 24px; border-top: 1px solid var(--border);
  max-height: 80vh; overflow-y: auto;
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; }

/* ---- Toast ---- */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 100; padding: 12px 24px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: toast-in 0.3s ease;
  max-width: 90%;
}
.toast.success { border-color: rgba(16,185,129,0.3); }
.toast.error { border-color: rgba(244,63,94,0.3); }
@keyframes toast-in { from { opacity:0; transform: translateX(-50%) translateY(-20px); } }

/* ---- Charts area ---- */
.chart-container { width: 100%; height: 200px; position: relative; }

/* ---- Badges Grid ---- */
.badges-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.badge-item { display: flex; flex-direction: column; align-items: center; gap: 4px; opacity: 0.35; }
.badge-icon {
  width: 40px; height: 40px; border-radius: 12px; background: var(--bg-input);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.badge-name { font-size: 9px; color: var(--text-dim); text-align: center; }
.badge-item.earned { opacity: 1; }

/* ---- Flex Helpers ---- */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-col { display: flex; flex-direction: column; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-xs { font-size: 10px; }
.text-sm { font-size: 12px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 24px; }
.text-2xl { font-size: 28px; }
.font-bold { font-weight: 700; }
.font-black { font-weight: 900; }
.text-emerald { color: var(--emerald); }
.text-cyan { color: var(--cyan); }
.text-orange { color: var(--orange); }
.text-rose { color: var(--rose); }
.text-purple { color: var(--purple); }
.text-amber { color: var(--amber); }
.text-dim { color: var(--text-dim); }
.text-muted { color: var(--text-muted); }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
