/* FitLife - Design System */
/* Aesthetic: Organic + Modern Athletic — dark backgrounds, warm greens, clean typography */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,300&family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,600;1,9..144,300&display=swap');

:root {
  --bg:          #0f1117;
  --bg-2:        #161920;
  --bg-3:        #1e2028;
  --bg-card:     #1a1d27;
  --border:      #2a2e3d;
  --border-2:    #353a4e;

  --green:       #5ddb8e;
  --green-dim:   #3aad67;
  --green-glow:  rgba(93,219,142,0.15);
  --amber:       #f5a623;
  --amber-dim:   rgba(245,166,35,0.15);
  --red:         #f05252;
  --red-dim:     rgba(240,82,82,0.12);
  --blue:        #6eb5ff;
  --blue-dim:    rgba(110,181,255,0.12);
  --purple:      #a78bfa;

  --text:        #e8eaf0;
  --text-2:      #9ca3b3;
  --text-3:      #5c6476;

  --font-body:   'DM Sans', sans-serif;
  --font-display:'Fraunces', serif;

  --radius:      12px;
  --radius-sm:   8px;
  --radius-lg:   20px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.3);

  --nav-h:       64px;
  --bottom-nav-h:68px;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Typography ── */
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; line-height: 1.2; }
h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.8rem); }
h3 { font-size: 1.1rem; }
p  { line-height: 1.6; color: var(--text-2); }
a  { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */
.container { max-width: 520px; margin: 0 auto; padding: 0 16px; }
.page-content { padding-top: calc(var(--nav-h) + 16px); padding-bottom: calc(var(--bottom-nav-h) + 20px); }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s;
}
.card:hover { border-color: var(--border-2); }
.card-sm { padding: 14px 16px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-body); font-size: 0.9rem; font-weight: 600;
  border: none; border-radius: var(--radius-sm); cursor: pointer;
  padding: 11px 20px; transition: all 0.2s; letter-spacing: 0.01em;
  text-decoration: none;
}
.btn-primary {
  background: var(--green); color: #0a1a10;
}
.btn-primary:hover { background: #6feaa0; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(93,219,142,0.35); text-decoration: none; color: #0a1a10; }
.btn-secondary {
  background: var(--bg-3); color: var(--text); border: 1px solid var(--border-2);
}
.btn-secondary:hover { background: var(--border); text-decoration: none; color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { color: var(--text); background: var(--bg-3); text-decoration: none; }
.btn-danger { background: var(--red-dim); color: var(--red); border: 1px solid rgba(240,82,82,0.3); }
.btn-danger:hover { background: rgba(240,82,82,0.2); text-decoration: none; color: var(--red); }
.btn-full { width: 100%; }
.btn-lg { padding: 14px 28px; font-size: 1rem; border-radius: var(--radius); }
.btn-sm { padding: 7px 14px; font-size: 0.82rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

/* ── Form elements ── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group label { font-size: 0.85rem; font-weight: 500; color: var(--text-2); }
.form-control {
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-family: var(--font-body);
  font-size: 0.95rem; padding: 11px 14px; transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}
.form-control:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-glow); }
.form-control::placeholder { color: var(--text-3); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Top nav ── */
.top-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h); background: rgba(15,17,23,0.92);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
}
.top-nav .logo {
  font-family: var(--font-display); font-size: 1.3rem; color: var(--green);
  display: flex; align-items: center; gap: 8px; text-decoration: none;
}
.top-nav .logo:hover { text-decoration: none; }
.top-nav .logo svg { width: 28px; height: 28px; }
.nav-user { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem; letter-spacing: 0.03em;
  flex-shrink: 0;
}

/* ── Bottom nav ── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--bottom-nav-h); background: rgba(22,25,32,0.95);
  backdrop-filter: blur(16px); border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--text-3); font-size: 0.68rem; font-weight: 500;
  text-decoration: none; padding: 8px 12px; border-radius: 10px;
  transition: color 0.2s; min-width: 56px; text-align: center;
}
.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav a:hover, .bottom-nav a.active { color: var(--green); text-decoration: none; }
.bottom-nav a.active svg { filter: drop-shadow(0 0 6px var(--green)); }

/* ── Badges & Pills ── */
.badge {
  display: inline-flex; align-items: center;
  font-size: 0.72rem; font-weight: 600; padding: 3px 9px;
  border-radius: 99px; letter-spacing: 0.03em;
}
.badge-green  { background: var(--green-glow); color: var(--green); border: 1px solid rgba(93,219,142,0.25); }
.badge-amber  { background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(245,166,35,0.25); }
.badge-red    { background: var(--red-dim); color: var(--red); border: 1px solid rgba(240,82,82,0.2); }
.badge-blue   { background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(110,181,255,0.2); }
.badge-purple { background: rgba(167,139,250,0.12); color: var(--purple); border: 1px solid rgba(167,139,250,0.2); }

/* ── Progress bar ── */
.progress-wrap { background: var(--bg-3); border-radius: 99px; height: 8px; overflow: hidden; }
.progress-bar  { height: 100%; border-radius: 99px; transition: width 0.6s cubic-bezier(.4,0,.2,1); }
.progress-green  { background: linear-gradient(90deg, var(--green-dim), var(--green)); }
.progress-amber  { background: linear-gradient(90deg, #e08000, var(--amber)); }
.progress-red    { background: linear-gradient(90deg, #c0392b, var(--red)); }

/* ── Stat tiles ── */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat-tile {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; text-align: center;
}
.stat-tile .val { font-family: var(--font-display); font-size: 1.9rem; line-height: 1; color: var(--text); }
.stat-tile .lbl { font-size: 0.75rem; color: var(--text-3); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.06em; }

/* ── Macro pills row ── */
.macro-row { display: flex; gap: 8px; }
.macro-pill {
  flex: 1; background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 8px; text-align: center;
}
.macro-pill .macro-val { font-size: 1rem; font-weight: 700; }
.macro-pill .macro-lbl { font-size: 0.68rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }
.macro-p { color: var(--blue); }
.macro-c { color: var(--amber); }
.macro-f { color: var(--purple); }

/* ── Section headers ── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); font-weight: 600; font-family: var(--font-body); }

/* ── Meal slots ── */
.meal-slot {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; background: var(--bg-3); border-radius: var(--radius-sm);
  border: 1px solid var(--border); margin-bottom: 8px;
  cursor: pointer; transition: border-color 0.2s;
}
.meal-slot:hover { border-color: var(--border-2); }
.meal-slot .meal-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
  flex-shrink: 0;
}
.meal-slot .meal-info { flex: 1; min-width: 0; }
.meal-slot .meal-name { font-size: 0.9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meal-slot .meal-cal  { font-size: 0.75rem; color: var(--text-3); }
.meal-icon-breakfast { background: rgba(245,166,35,0.12); }
.meal-icon-lunch     { background: rgba(110,181,255,0.12); }
.meal-icon-dinner    { background: rgba(93,219,142,0.12); }
.meal-icon-snack     { background: rgba(167,139,250,0.12); }

/* ── Workout card ── */
.workout-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 10px;
}
.workout-type-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.72rem; font-weight: 600; padding: 3px 10px;
  border-radius: 99px; letter-spacing: 0.03em;
}

/* ── Alerts ── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 0.9rem; margin-bottom: 16px; }
.alert-success { background: var(--green-glow); border: 1px solid rgba(93,219,142,0.3); color: var(--green); }
.alert-error   { background: var(--red-dim); border: 1px solid rgba(240,82,82,0.3); color: var(--red); }
.alert-info    { background: var(--blue-dim); border: 1px solid rgba(110,181,255,0.3); color: var(--blue); }
.alert-warn    { background: var(--amber-dim); border: 1px solid rgba(245,166,35,0.3); color: var(--amber); }

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Loading spinner ── */
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--green);
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast notifications ── */
#toast-container {
  position: fixed; top: 80px; right: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px;
  font-size: 0.9rem; box-shadow: var(--shadow);
  transform: translateX(120%); transition: transform 0.3s cubic-bezier(.4,0,.2,1);
  pointer-events: auto; max-width: 280px;
}
.toast.show { transform: translateX(0); }
.toast-success { border-left: 3px solid var(--green); }
.toast-error   { border-left: 3px solid var(--red); }
.toast-info    { border-left: 3px solid var(--blue); }

/* ── Modals ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border-2);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px 20px 32px; width: 100%; max-width: 520px;
  max-height: 90dvh; overflow-y: auto;
  transform: translateY(40px); transition: transform 0.3s cubic-bezier(.4,0,.2,1);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-handle {
  width: 36px; height: 4px; background: var(--border-2);
  border-radius: 99px; margin: 0 auto 20px;
}
.modal-title { font-family: var(--font-display); font-size: 1.4rem; margin-bottom: 16px; }

/* ── Tabs ── */
.tabs { display: flex; background: var(--bg-3); border-radius: var(--radius-sm); padding: 3px; margin-bottom: 20px; }
.tab-btn {
  flex: 1; padding: 9px 8px; border: none; background: transparent;
  color: var(--text-3); font-family: var(--font-body); font-size: 0.85rem; font-weight: 500;
  border-radius: calc(var(--radius-sm) - 2px); cursor: pointer; transition: all 0.2s;
}
.tab-btn.active { background: var(--bg-card); color: var(--text); box-shadow: var(--shadow-sm); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Weight chart ── */
.chart-container { position: relative; width: 100%; height: 180px; }

/* ── Ring / Donut ── */
.ring-wrap { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.ring-center { position: absolute; text-align: center; }

/* ── Day strip ── */
.day-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.day-strip::-webkit-scrollbar { display: none; }
.day-chip {
  flex-shrink: 0; width: 48px; height: 64px;
  background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius-sm);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  cursor: pointer; transition: all 0.2s; text-decoration: none; color: var(--text-2);
}
.day-chip:hover { border-color: var(--border-2); color: var(--text); text-decoration: none; }
.day-chip.active { background: var(--green-glow); border-color: var(--green); color: var(--green); }
.day-chip.has-workout::after {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: var(--green); display: block;
}
.day-chip .day-num { font-size: 1rem; font-weight: 700; }
.day-chip .day-name { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Check items (shopping list) ── */
.check-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.check-item:last-child { border-bottom: none; }
.check-item input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--green); flex-shrink: 0; cursor: pointer; }
.check-item.done .item-name { text-decoration: line-through; color: var(--text-3); }
.item-name { flex: 1; font-size: 0.9rem; }
.item-qty  { font-size: 0.8rem; color: var(--text-3); flex-shrink: 0; }

/* ── Empty states ── */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.9rem; }

/* ── Auth pages ── */
.auth-page {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(93,219,142,0.08), transparent);
}
.auth-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 32px 28px; width: 100%; max-width: 400px;
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo .logo-text { font-family: var(--font-display); font-size: 2rem; color: var(--green); }
.auth-logo .logo-sub  { font-size: 0.85rem; color: var(--text-3); margin-top: 4px; }

/* ── Responsive utilities ── */
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.mt-1   { margin-top: 4px; }
.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; }
.flex   { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-3); }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ── AI chat bubble ── */
.ai-fab {
  position: fixed; bottom: calc(var(--bottom-nav-h) + 16px); right: 16px; z-index: 50;
  width: 52px; height: 52px; border-radius: 50%; background: var(--green);
  border: none; cursor: pointer; box-shadow: 0 4px 20px rgba(93,219,142,0.4);
  display: flex; align-items: center; justify-content: center; font-size: 1.3rem;
  transition: transform 0.2s, box-shadow 0.2s;
}
.ai-fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(93,219,142,0.55); }

.chat-window {
  position: fixed; bottom: calc(var(--bottom-nav-h) + 80px); right: 16px; z-index: 150;
  width: min(340px, calc(100vw - 32px)); background: var(--bg-card);
  border: 1px solid var(--border-2); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); display: none; flex-direction: column; max-height: 420px;
}
.chat-window.open { display: flex; }
.chat-header { padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 0.9rem; display: flex; align-items: center; justify-content: space-between; }
.chat-messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 85%; padding: 9px 12px; border-radius: 12px; font-size: 0.87rem; line-height: 1.5; }
.chat-msg.user { background: var(--green-glow); border: 1px solid rgba(93,219,142,0.2); align-self: flex-end; color: var(--text); }
.chat-msg.ai   { background: var(--bg-3); align-self: flex-start; color: var(--text); }
.chat-input-row { padding: 10px 12px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.chat-input { flex: 1; background: var(--bg-3); border: 1px solid var(--border); border-radius: 8px; color: var(--text); padding: 8px 12px; font-size: 0.87rem; font-family: var(--font-body); outline: none; }
.chat-input:focus { border-color: var(--green); }
.chat-send { background: var(--green); border: none; border-radius: 8px; color: #0a1a10; padding: 8px 12px; cursor: pointer; font-weight: 700; }

/* ── Animations ── */
@keyframes fadeIn  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.fade-in  { animation: fadeIn  0.3s ease forwards; }
.slide-up { animation: slideUp 0.35s ease forwards; }

/* Stagger children */
.stagger > * { opacity: 0; animation: fadeIn 0.3s ease forwards; }
.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.1s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.2s; }
.stagger > *:nth-child(5) { animation-delay: 0.25s; }
.stagger > *:nth-child(6) { animation-delay: 0.3s; }

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