/* GymFlow - Design System */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg:       #141625;
  --surface1: #1E2243;
  --surface2: #252B50;
  --surface3: #2E3560;
  --accent:   #F0FF4B;
  --energy:   #FF6B35;
  --success:  #22C55E;
  --danger:   #EF4444;
  --warn:     #FB923C;
  --text:     #E8EAFF;
  --muted:    #7A8299;
  --border:   rgba(240,255,75,.12);
  --radius:   1rem;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* ── Scrollbar ────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 2px; }

/* ── Typography ───────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 800; }
h2 { font-size: 1.375rem; font-weight: 700; }
h3 { font-size: 1.125rem; font-weight: 600; }
.text-muted  { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-energy { color: var(--energy); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }

/* ── Layout ───────────────────────────────────── */
#app { max-width: 480px; margin: 0 auto; position: relative; }
.page { min-height: 100dvh; padding: 0 0 6rem; }
.page-inner { padding: 1.25rem 1rem; }

/* ── Safe area bottom ─────────────────────────── */
.pb-safe { padding-bottom: calc(6rem + env(safe-area-inset-bottom, 0)); }

/* ── Cards ────────────────────────────────────── */
.card {
  background: var(--surface1);
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid var(--border);
}
.card-sm { padding: .875rem 1rem; border-radius: .875rem; }
.card-accent {
  background: var(--accent);
  color: #141625;
  border-color: transparent;
}
.card-energy {
  background: linear-gradient(135deg, var(--energy) 0%, #ff4500 100%);
  color: #fff;
  border-color: transparent;
}

/* ── Hero Banner ──────────────────────────────── */
.hero-banner {
  background: linear-gradient(135deg, var(--surface2) 0%, var(--surface1) 100%);
  border-radius: 1.5rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.hero-banner::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: rgba(240,255,75,.06);
}

/* ── Buttons ──────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .75rem 1.5rem; border-radius: .875rem;
  font-weight: 600; font-size: .9375rem;
  border: none; cursor: pointer;
  transition: transform .15s, opacity .15s, box-shadow .15s;
  text-decoration: none;
}
.btn:active { transform: scale(.96); }
.btn-accent  { background: var(--accent);  color: #141625; }
.btn-accent:hover { box-shadow: 0 0 20px rgba(240,255,75,.35); }
.btn-energy  { background: var(--energy);  color: #fff; }
.btn-energy:hover { box-shadow: 0 0 20px rgba(255,107,53,.4); }
.btn-surface { background: var(--surface2); color: var(--text); }
.btn-danger  { background: var(--danger);   color: #fff; }
.btn-ghost   { background: transparent; color: var(--muted); border: 1px solid var(--surface3); }
.btn-full    { width: 100%; }
.btn-sm      { padding: .5rem 1rem; font-size: .875rem; border-radius: .75rem; }
.btn-icon    { padding: .625rem; border-radius: .75rem; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* ── FAB ─────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(5.5rem + env(safe-area-inset-bottom,0));
  right: 1.25rem;
  width: 3.25rem; height: 3.25rem;
  border-radius: 50%;
  background: var(--accent);
  color: #141625;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 700;
  box-shadow: 0 4px 20px rgba(240,255,75,.4);
  transition: transform .2s, box-shadow .2s;
  z-index: 40;
}
.fab:active { transform: scale(.92); }
.fab.energy {
  background: var(--energy);
  box-shadow: 0 4px 20px rgba(255,107,53,.45);
}

/* ── Bottom Nav ───────────────────────────────── */
/* ── Floating bottom nav (pill style) ─────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  z-index: 50;
  background: transparent;
  padding: 0 1.25rem calc(env(safe-area-inset-bottom, 0px) + .75rem);
}
.bottom-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: .5rem .75rem;
  gap: .25rem;
  background: #1a1d35;
  border-radius: 9999px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5), 0 0 0 1px rgba(255,107,53,.18);
}
.nav-item {
  width: 3rem; height: 3rem;
  border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .15rem;
  cursor: pointer; border: none; background: transparent;
  color: var(--muted); font-size: .58rem; font-weight: 600;
  transition: all .2s;
}
.nav-item:active { transform: scale(.88); }
.nav-item svg { width: 20px; height: 20px; transition: transform .2s; }
.nav-item.active { background: rgba(255,255,255,.1); color: var(--accent); }
.nav-item.active svg { transform: scale(1.1); }
.nav-item.active.energy-nav { color: var(--energy); background: rgba(255,107,53,.12); }

/* ── Page Header ──────────────────────────────── */
.page-header {
  padding: 3.5rem 1rem 1rem;
  display: flex; align-items: center; justify-content: space-between;
}
.page-title { font-size: 1.5rem; font-weight: 800; }

/* ── Inputs ────────────────────────────────────── */
.input-wrap { display: flex; flex-direction: column; gap: .375rem; }
label { font-size: .8125rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.input {
  background: var(--surface2); border: 1px solid var(--surface3); border-radius: .75rem;
  padding: .8125rem 1rem; color: var(--text); font-size: .9375rem; font-family: inherit;
  outline: none; transition: border-color .2s;
  -webkit-appearance: none;
}
.input:focus { border-color: var(--accent); }
.input.error  { border-color: var(--danger); }
.input-number {
  background: var(--surface2); border: 1px solid var(--surface3); border-radius: .75rem;
  padding: .5rem .75rem; color: var(--text); font-size: 1.125rem; font-weight: 700;
  font-family: inherit; outline: none; text-align: center; width: 80px;
  transition: border-color .2s;
}
.input-number:focus { border-color: var(--accent); }
select.input { appearance: none; cursor: pointer; }

/* ── Set row ──────────────────────────────────── */
.set-row {
  display: flex; align-items: center; gap: .5rem;
  padding: .625rem .75rem;
  border-radius: .75rem;
  background: var(--surface2);
  border: 1px solid transparent;
  transition: border-color .2s, background .2s;
  position: relative; z-index: 1;
}
.set-row.completed          { border-color: rgba(34,197,94,.3); background: rgba(34,197,94,.06); }
.set-row.completed.pr-row   { border-color: rgba(34,197,94,.4); background: rgba(34,197,94,.09); }
.set-num {
  width: 1.75rem; height: 1.75rem; border-radius: 50%;
  background: var(--surface3); display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; color: var(--muted);
  flex-shrink: 0;
}
.set-row.completed .set-num          { background: var(--success); color: #fff; }
.set-row.completed.pr-row .set-num   { background: var(--accent); color: #141625; }

/* ── Exercise card in workout ─────────────────── */
.exercise-block {
  background: var(--surface1); border-radius: 1.125rem;
  border: 1px solid var(--border);
  overflow: hidden;
}
.exercise-block-header {
  padding: 1rem 1rem .75rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--surface3);
}

/* ── Progress bar ─────────────────────────────── */
.progress-bar { background: var(--surface3); border-radius: 999px; height: 6px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; transition: width .4s; }

/* ── Week grid ────────────────────────────────── */
.week-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: .375rem; }
.week-day {
  display: flex; flex-direction: column; align-items: center;
  gap: .25rem; padding: .625rem .25rem; border-radius: .75rem;
  background: var(--surface2); border: 1px solid transparent;
  cursor: default; transition: background .2s, border-color .2s;
}
.week-day.has-workout { border-color: rgba(240,255,75,.3); }
.week-day.today { background: var(--surface3); border-color: var(--accent); }
.week-day.done  { background: rgba(34,197,94,.1); border-color: rgba(34,197,94,.4); }
.week-day span.day-label { font-size: .625rem; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.week-day span.day-num   { font-size: .9375rem; font-weight: 700; }
.week-day .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }

/* ── Pill / Tag ────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .3125rem .75rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600;
  background: var(--surface3); color: var(--muted);
}
.pill-accent  { background: rgba(240,255,75,.15); color: var(--accent); }
.pill-energy  { background: rgba(255,107,53,.15);  color: var(--energy); }
.pill-success { background: rgba(34,197,94,.15);   color: var(--success); }
.pill-danger  { background: rgba(239,68,68,.15);   color: var(--danger); }

/* ── Streak badge ─────────────────────────────── */
.streak-badge {
  display: inline-flex; align-items: center; gap: .375rem;
  padding: .4375rem .875rem; border-radius: 999px;
  background: linear-gradient(135deg, #ff6b35, #ff4500);
  color: #fff; font-weight: 700; font-size: .875rem;
  box-shadow: 0 2px 12px rgba(255,107,53,.4);
}

/* ── Modal / Sheet ────────────────────────────── */
.overlay {
  position: fixed; inset: 0; background: rgba(10,12,25,.75);
  z-index: 100; backdrop-filter: blur(4px);
  display: flex; align-items: flex-end;
}
.sheet {
  background: var(--surface1); border-radius: 1.5rem 1.5rem 0 0;
  width: 100%; max-width: 480px; margin: 0 auto;
  padding: 1.5rem 1rem calc(1.5rem + env(safe-area-inset-bottom,0));
  max-height: 92dvh; overflow-y: auto;
}
.sheet-handle {
  width: 3rem; height: 4px; border-radius: 2px;
  background: var(--surface3); margin: 0 auto 1.25rem;
}
.modal-center {
  position: fixed; inset: 0; background: rgba(10,12,25,.8);
  z-index: 100; backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal-box {
  background: var(--surface1); border-radius: 1.5rem;
  width: 100%; max-width: 400px;
  padding: 1.75rem 1.5rem; border: 1px solid var(--surface3);
}

/* ── Rest Timer ───────────────────────────────── */
.timer-circle {
  width: 8rem; height: 8rem; border-radius: 50%;
  border: 4px solid var(--surface3); position: relative;
  display: flex; align-items: center; justify-content: center;
}
.timer-time { font-size: 2rem; font-weight: 800; color: var(--accent); }

/* ── Toast ────────────────────────────────────── */
.toast-container {
  position: fixed; top: 1rem; right: 1rem; left: 1rem;
  max-width: 440px; margin: 0 auto;
  display: flex; flex-direction: column; gap: .5rem;
  z-index: 200; pointer-events: none;
}
.toast {
  background: var(--surface2); border-radius: .875rem;
  padding: .875rem 1rem; border-left: 3px solid var(--accent);
  font-size: .9rem; font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  animation: slideIn .25s ease;
  pointer-events: all;
}
.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--danger); }
.toast.pr      { border-color: var(--accent); background: rgba(240,255,75,.1); }
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ── Skeleton loader ─────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: .75rem;
}
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ── Transition ───────────────────────────────── */
.page-enter  { animation: fadeUp .25s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ── Auth screen ──────────────────────────────── */
.auth-screen {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 2rem 1.25rem; gap: 2rem;
}
.auth-logo { font-size: 3rem; }
.auth-title { font-size: 2rem; font-weight: 800; text-align: center; line-height: 1.2; }
.auth-sub { color: var(--muted); text-align: center; font-size: .9375rem; }
.auth-card { background: var(--surface1); border-radius: 1.5rem; padding: 1.75rem 1.5rem; width: 100%; border: 1px solid var(--border); }

/* ── Stat boxes ───────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.stat-box {
  background: var(--surface2); border-radius: 1rem;
  padding: 1rem; border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: .25rem;
}
.stat-value { font-size: 1.5rem; font-weight: 800; }
.stat-label { font-size: .75rem; color: var(--muted); font-weight: 500; }

/* ── Day selector (routine builder) ─────────── */
.day-selector { display: flex; gap: .5rem; flex-wrap: wrap; }
.day-btn {
  width: 2.25rem; height: 2.25rem; border-radius: 50%;
  background: var(--surface3); color: var(--muted);
  border: 2px solid transparent; cursor: pointer;
  font-size: .8rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s, color .15s;
  flex-shrink: 0;
}
.day-btn.selected { background: rgba(240,255,75,.15); border-color: var(--accent); color: var(--accent); }

/* ── Chart container ─────────────────────────── */
.chart-wrap { position: relative; height: 200px; }

/* ── Empty state ─────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  gap: 1rem; padding: 3rem 1.5rem; text-align: center;
}
.empty-icon { font-size: 3.5rem; }
.empty-title { font-weight: 700; font-size: 1.125rem; }
.empty-sub { color: var(--muted); font-size: .9rem; }

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

/* ── Flex helpers ─────────────────────────────── */
.flex     { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .25rem; } .gap-2 { gap: .5rem; } .gap-3 { gap: .75rem; }
.gap-4 { gap: 1rem; } .gap-6 { gap: 1.5rem; }
.mt-1 { margin-top: .25rem; } .mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: .75rem; } .mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: .5rem; } .mb-4 { margin-bottom: 1rem; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.font-bold { font-weight: 700; } .font-semibold { font-weight: 600; }
.text-sm { font-size: .875rem; } .text-xs { font-size: .75rem; }
.text-lg { font-size: 1.125rem; } .text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.rounded-full { border-radius: 999px; }
.overflow-hidden { overflow: hidden; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Horizontal scroll ───────────────────────── */
.scroll-x { overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; }
.scroll-x::-webkit-scrollbar { display: none; }

/* ── Mood selector ───────────────────────────── */
.mood-row { display: flex; gap: .75rem; justify-content: center; }
.mood-btn {
  font-size: 1.75rem; padding: .5rem; border-radius: .75rem;
  background: var(--surface3); border: 2px solid transparent;
  cursor: pointer; transition: border-color .15s, transform .15s;
}
.mood-btn.active { border-color: var(--accent); transform: scale(1.15); }

/* ── Exercise chips (workout carousel selector) ─ */
.ex-chip {
  position: relative;
  display: inline-flex; flex-direction: column; justify-content: flex-end;
  width: 88px; height: 110px; flex-shrink: 0;
  border-radius: 1rem; overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
  background: var(--surface2);
}
.ex-chip:active { transform: scale(.97); }
.ex-chip-icon {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
.ex-chip-icon img  { width: 100%; height: 100%; object-fit: cover; }
.ex-chip-icon span { font-size: 3rem; line-height: 1; }
/* dark gradient so label is readable */
.ex-chip::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,.05) 30%, rgba(0,0,0,.62) 100%);
  pointer-events: none;
}
.ex-chip-label {
  position: relative; z-index: 1;
  margin: .4rem;
  background: rgba(255,255,255,.15);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: .5rem;
  padding: .2rem .4rem;
  font-size: .65rem; font-weight: 700; color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-align: center;
}
.ex-chip-check {
  position: absolute; top: .4rem; right: .4rem; z-index: 2;
  background: var(--success); color: #000;
  border-radius: 999px; padding: .1rem .35rem;
  font-size: .6rem; font-weight: 700;
}

/* States */
.ex-chip-active {
  border-color: var(--accent);
  box-shadow: 0 0 14px rgba(240,255,75,.3);
}
.ex-chip-done {
  border-color: rgba(34,197,94,.5);
}
.ex-chip-pending { border-color: transparent; }

.ex-chip-add {
  background: transparent;
  border: 2px dashed var(--surface3);
  color: var(--muted);
  align-items: center; justify-content: center; gap: .25rem;
  font-size: .8rem; font-weight: 700;
}
.ex-chip-add::after { display: none; }
.ex-chip-add:hover { border-color: var(--accent); color: var(--accent); }

/* ── Pulsing dot (active session indicator) ── */
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.5;transform:scale(1.5)} }
.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--energy); display: inline-block;
  animation: pulse 1.5s infinite;
}
