/* ═══════════════════════════════════════════
   FITPULSE — style.css
   ═══════════════════════════════════════════ */

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

:root {
  --bg: #0a0a0f;
  --surface: #13131c;
  --surface2: #1c1c2a;
  --surface3: #252535;
  --accent: #00e5a0;
  --accent2: #7c6bff;
  --accent3: #ff5f7e;
  --accent4: #ffb347;
  --text: #f0f0f8;
  --text2: #9898b8;
  --text3: #5a5a7a;
  --radius: 18px;
  --radius-sm: 10px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── TOAST ─── */
#toast {
  position: fixed;
  top: calc(var(--safe-top) + 70px);
  left: 50%;
  transform: translateX(-50%) translateY(-16px);
  background: var(--surface2);
  border: 1px solid var(--surface3);
  border-radius: 20px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 2000;
  opacity: 0;
  transition: all 0.25s ease;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── MODAL ─── */
#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 500;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
#modal-overlay.show { display: block; }

.modal {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface2);
  border-radius: 24px 24px 0 0;
  padding: 24px 20px calc(var(--safe-bottom) + 24px);
  z-index: 600;
  border-top: 1px solid var(--surface3);
}
.modal.show { display: block; }

.modal-title {
  font-family: 'Syne', sans-serif;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  text-align: center;
}
.modal-field { margin-bottom: 14px; }
.modal-label {
  display: block;
  font-size: 12px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.modal-input {
  width: 100%;
  background: var(--surface3);
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 16px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  outline: none;
  -webkit-appearance: none;
}
.modal-input:focus { background: #2e2e42; }
select.modal-input { cursor: pointer; }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.modal-btn-cancel {
  flex: 1;
  background: var(--surface3);
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
}
.modal-btn-save {
  flex: 2;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  color: #000;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: opacity 0.15s;
}
.modal-btn-save:active { opacity: 0.85; }

/* ─── IOS HSP PROMPT ─── */
#hsp {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 999;
  background: linear-gradient(180deg, transparent 0%, rgba(10,10,15,0.98) 25%);
  padding: 28px 24px calc(var(--safe-bottom) + 32px);
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
#hsp.show { display: flex; }
.hsp-arrow {
  width: 48px; height: 48px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #000; font-weight: 700;
  animation: bounce 1.4s ease-in-out infinite;
}
@keyframes bounce {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-7px); }
}
.hsp-title { font-family: 'Syne', sans-serif; font-size: 18px; font-weight: 700; text-align: center; }
.hsp-sub   { font-size: 13px; color: var(--text2); text-align: center; line-height: 1.6; max-width: 300px; }
.hsp-steps {
  display: flex; gap: 8px; align-items: center;
  background: var(--surface2); border-radius: var(--radius-sm);
  padding: 10px 16px; font-size: 12px; color: var(--text2);
  text-align: center; flex-wrap: wrap; justify-content: center;
}
.hsp-steps span { color: var(--accent); font-weight: 700; }
.hsp-dismiss {
  font-size: 12px; color: var(--text3);
  background: none; border: none; cursor: pointer;
  text-decoration: underline; font-family: 'DM Sans', sans-serif; padding: 4px;
}

/* ─── ANDROID INSTALL BANNER ─── */
#install-banner {
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  padding: 10px 16px; display: none;
  justify-content: space-between; align-items: center;
}
#install-banner.show { display: flex; }
.ib-text { font-size: 12px; font-weight: 600; color: #fff; }
.ib-btn {
  background: rgba(255,255,255,0.2); color: #fff; border: none;
  border-radius: 20px; padding: 6px 14px; font-size: 11px;
  font-weight: 700; cursor: pointer; font-family: 'DM Sans', sans-serif;
}

/* ─── TOPBAR ─── */
.topbar {
  padding: calc(var(--safe-top) + 16px) 20px 0;
  background: var(--bg);
  position: sticky; top: 0; z-index: 100;
}
.topbar-inner {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 4px;
}
.app-name { font-family: 'Syne', sans-serif; font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.app-name span { color: var(--accent); }
.pwa-badge {
  background: var(--surface2); border: 1px solid rgba(0,229,160,0.35);
  border-radius: 20px; padding: 4px 12px; font-size: 11px;
  color: var(--accent); font-weight: 600; display: none;
}
.pwa-badge.show { display: block; }
.greeting { font-size: 13px; color: var(--text2); margin-bottom: 14px; }

/* ─── TOP NAV ─── */
.nav {
  display: flex; gap: 6px;
  padding: 0 20px 14px;
  overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
  background: var(--bg); position: sticky; top: 72px; z-index: 90;
}
.nav::-webkit-scrollbar { display: none; }
.nav-btn {
  flex-shrink: 0;
  background: var(--surface); border: 1px solid var(--surface3);
  border-radius: 30px; padding: 8px 18px; font-size: 13px;
  font-weight: 500; color: var(--text2); cursor: pointer;
  transition: all 0.18s; white-space: nowrap; font-family: 'DM Sans', sans-serif;
}
.nav-btn.active { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 700; }

/* ─── SECTIONS ─── */
.section {
  display: none; padding: 0 20px;
  padding-bottom: calc(var(--safe-bottom) + 100px);
}
.section.active { display: block; }

/* ─── STAT CARDS ─── */
.hero-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.stat-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 16px; position: relative; overflow: hidden;
  cursor: pointer; transition: background 0.15s;
}
.stat-card:active { background: var(--surface2); }
.stat-card::before {
  content: ''; position: absolute; top: 0; right: 0;
  width: 64px; height: 64px; border-radius: 50%;
  opacity: 0.12; transform: translate(20px,-20px);
}
.stat-card.green::before  { background: var(--accent); }
.stat-card.purple::before { background: var(--accent2); }
.stat-card.red::before    { background: var(--accent3); }
.stat-card.amber::before  { background: var(--accent4); }

.stat-label {
  font-size: 11px; color: var(--text2); margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: 0.5px;
  display: flex; align-items: center; gap: 5px;
}
.edit-hint { font-size: 11px; color: var(--text3); opacity: 0.6; }
.stat-val { font-family: 'Syne', sans-serif; font-size: 28px; font-weight: 800; line-height: 1; }
.stat-val.green  { color: var(--accent); }
.stat-val.purple { color: var(--accent2); }
.stat-val.red    { color: var(--accent3); }
.stat-val.amber  { color: var(--accent4); }
.stat-unit { font-size: 11px; color: var(--text3); margin-top: 3px; }

/* ─── SECTION TITLE ─── */
.sec-title {
  font-family: 'Syne', sans-serif; font-size: 16px; font-weight: 700;
  margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center;
}
.sec-title-link {
  font-family: 'DM Sans', sans-serif; font-size: 12px;
  color: var(--accent2); font-weight: 400; cursor: pointer;
}

/* ─── MINI CHART ─── */
.mini-chart {
  display: flex; align-items: flex-end; gap: 6px;
  height: 52px; margin-bottom: 6px;
}
.bar { flex: 1; background: var(--surface3); border-radius: 5px; cursor: pointer; transition: background 0.2s; min-height: 4px; }
.bar:hover, .bar.active { background: var(--accent); }

/* ─── QUICK ACTIONS ─── */
.quick-row { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 8px; margin-bottom: 20px; }
.quick-btn {
  background: var(--surface); border: 1px solid var(--surface3);
  border-radius: var(--radius-sm); padding: 12px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 20px; cursor: pointer; transition: background 0.15s;
}
.quick-btn span { font-family: 'DM Sans', sans-serif; font-size: 10px; color: var(--text2); font-weight: 500; text-align: center; line-height: 1.2; }
.quick-btn:active { background: var(--surface2); }

/* ─── PREMIUM LOCKED ─── */
.premium-section-wrap { position: relative; margin-bottom: 14px; }
.premium-section {
  background: linear-gradient(135deg,rgba(124,107,255,0.08),rgba(0,229,160,0.04));
  border: 1px solid rgba(124,107,255,0.18); border-radius: var(--radius); padding: 16px;
}
.premium-label { font-size: 10px; color: var(--accent2); font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 6px; }
.premium-title { font-family: 'Syne', sans-serif; font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.premium-desc  { font-size: 13px; color: var(--text2); line-height: 1.55; }
.locked-overlay {
  position: absolute; inset: 0; background: rgba(10,10,15,0.82);
  border-radius: var(--radius); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.lock-icon { font-size: 28px; }
.lock-text { font-family: 'Syne', sans-serif; font-size: 13px; font-weight: 700; text-align: center; color: var(--text2); max-width: 160px; line-height: 1.4; }
.lock-cta { font-size: 12px; color: var(--accent); font-weight: 600; cursor: pointer; background: none; border: none; font-family: 'DM Sans', sans-serif; padding: 4px 8px; }

/* ─── CALENDAR STRIP ─── */
.cal-strip { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-bottom: 20px; padding-bottom: 4px; }
.cal-strip::-webkit-scrollbar { display: none; }
.cal-day { flex-shrink: 0; width: 44px; background: var(--surface); border-radius: var(--radius-sm); padding: 8px 4px; text-align: center; cursor: pointer; border: 1px solid transparent; transition: all 0.15s; }
.cal-day.today  { border-color: var(--accent); color: var(--accent); }
.cal-day.active { background: var(--accent); color: #000; border-color: var(--accent); }
.cal-day-name   { font-size: 9px; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.7; margin-bottom: 3px; }
.cal-day-num    { font-family: 'Syne', sans-serif; font-size: 15px; font-weight: 700; }

/* ─── WORKOUT LIST ─── */
.workout-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; list-style: none; }
.workout-item { background: var(--surface); border-radius: var(--radius-sm); padding: 14px 16px; display: flex; align-items: center; gap: 14px; }
.workout-icon { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.wi-green  { background: rgba(0,229,160,0.1); }
.wi-purple { background: rgba(124,107,255,0.1); }
.wi-red    { background: rgba(255,95,126,0.1); }
.workout-info { flex: 1; min-width: 0; }
.workout-name { font-size: 14px; font-weight: 500; margin-bottom: 2px; }
.workout-meta { font-size: 12px; color: var(--text2); }
.workout-check {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--surface3); background: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 14px; color: #000;
  transition: all 0.18s; flex-shrink: 0; font-family: 'DM Sans', sans-serif;
}
.workout-check.done { background: var(--accent); border-color: var(--accent); }

/* ─── PROGRESS BAR ─── */
.progress-bar-wrap { margin-bottom: 16px; }
.progress-bar-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text2); margin-bottom: 8px; }
.progress-bar-track { height: 6px; background: var(--surface3); border-radius: 3px; overflow: hidden; }
.progress-bar-fill  { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s ease; }

/* ─── NUTRITION ─── */
.macro-ring-wrap { display: flex; justify-content: center; margin-bottom: 20px; }
.macro-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 20px; }
.macro-pill { background: var(--surface); border-radius: var(--radius-sm); padding: 12px 8px; text-align: center; }
.macro-pill-label { font-size: 10px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.macro-pill-val   { font-family: 'Syne', sans-serif; font-size: 18px; font-weight: 700; }
.macro-pill-sub   { font-size: 10px; color: var(--text3); margin-top: 2px; }

.food-log { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; list-style: none; }
.food-item {
  background: var(--surface); border-radius: var(--radius-sm);
  padding: 12px 14px; display: flex; justify-content: space-between;
  align-items: center; gap: 10px;
}
.food-name { font-size: 13px; font-weight: 500; margin-bottom: 2px; }
.food-time { font-size: 11px; color: var(--text2); }
.food-cal  { font-size: 12px; color: var(--accent4); font-weight: 700; flex-shrink: 0; }
.food-log-empty { font-size: 13px; color: var(--text3); text-align: center; padding: 20px 0 10px; }
.meal-delete {
  background: none; border: none; color: var(--text3); font-size: 18px;
  cursor: pointer; padding: 0 4px; line-height: 1; flex-shrink: 0;
  font-family: 'DM Sans', sans-serif;
}
.meal-delete:hover { color: var(--accent3); }
.add-food-btn {
  width: 100%; background: none; border: 1px dashed var(--surface3);
  border-radius: var(--radius-sm); padding: 14px; text-align: center;
  font-size: 13px; color: var(--text3); cursor: pointer;
  font-family: 'DM Sans', sans-serif; transition: border-color 0.2s, color 0.2s; margin-top: 4px;
}
.add-food-btn:hover { border-color: var(--accent2); color: var(--accent2); }

/* ─── HABITS ─── */
.habit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.habit-card { background: var(--surface); border-radius: var(--radius); padding: 16px; position: relative; }
.habit-name { font-size: 13px; font-weight: 500; margin-bottom: 8px; line-height: 1.3; }
.habit-streak { font-family: 'Syne', sans-serif; font-size: 28px; font-weight: 800; line-height: 1; margin-bottom: 2px; }
.habit-streak-label { font-size: 10px; color: var(--text3); }
.habit-dots { display: flex; gap: 4px; margin-top: 10px; flex-wrap: wrap; }
.habit-dot  { width: 8px; height: 8px; border-radius: 50%; background: var(--surface3); flex-shrink: 0; }
.habit-dot.done  { background: var(--accent); }
.habit-dot.today { background: var(--accent3); }
.habit-toggle {
  position: absolute; top: 12px; right: 12px;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface3); border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; cursor: pointer; color: #000;
  transition: all 0.18s; font-family: 'DM Sans', sans-serif;
}
.habit-toggle.active { background: var(--accent); }

/* ─── RUNNING ─── */
.run-hero {
  background: var(--surface); border-radius: var(--radius);
  padding: 24px 20px; text-align: center; margin-bottom: 14px;
  position: relative; overflow: hidden;
}
.run-map-bg {
  position: absolute; inset: 0; opacity: 0.04;
  background-image:
    repeating-linear-gradient(0deg, var(--accent) 0, var(--accent) 1px, transparent 1px, transparent 40px),
    repeating-linear-gradient(90deg, var(--accent) 0, var(--accent) 1px, transparent 1px, transparent 40px);
}
.run-dist      { font-family: 'Syne', sans-serif; font-size: 56px; font-weight: 800; color: var(--accent); line-height: 1; position: relative; }
.run-dist-unit { font-size: 20px; color: var(--text2); font-weight: 400; }
.run-sub       { font-size: 13px; color: var(--text2); margin-top: 6px; position: relative; }
.run-day-label { font-size: 12px; color: var(--text2); }
.run-empty     { font-size: 13px; color: var(--text3); padding: 16px 0; text-align: center; list-style: none; }

.run-stats-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.run-stat { background: var(--surface); border-radius: var(--radius-sm); padding: 12px 8px; text-align: center; }
.run-stat-val   { font-family: 'Syne', sans-serif; font-size: 20px; font-weight: 700; margin-bottom: 2px; }
.run-stat-label { font-size: 10px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.4px; }

.run-btn {
  background: var(--accent3); border: none; border-radius: var(--radius);
  padding: 17px; width: 100%; font-family: 'Syne', sans-serif;
  font-size: 16px; font-weight: 700; color: #fff; cursor: pointer;
  letter-spacing: 0.3px; transition: transform 0.1s, opacity 0.15s;
}
.run-btn:active  { transform: scale(0.97); }
.run-btn.running { background: var(--surface3); color: var(--text2); }

/* ─── BOTTOM NAV ─── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(10,10,15,0.96);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 10px 8px; padding-bottom: calc(var(--safe-bottom) + 10px);
  display: flex; justify-content: space-around; z-index: 100;
}
.bn-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; color: var(--text3); cursor: pointer;
  padding: 6px 12px; border-radius: var(--radius-sm);
  transition: color 0.15s; font-family: 'DM Sans', sans-serif;
}
.bn-btn.active { color: var(--accent); }
.bn-icon  { font-size: 20px; line-height: 1; }
.bn-label { font-size: 10px; font-weight: 500; letter-spacing: 0.3px; }

/* ─── RESPONSIVE ─── */
@media (min-width: 430px) {
  .topbar, .nav, main { max-width: 430px; margin-left: auto; margin-right: auto; }
  .bottom-nav { justify-content: center; }
  .bn-btn { min-width: 72px; }
  .modal { max-width: 430px; left: 50%; right: auto; transform: translateX(-50%); border-radius: 24px 24px 0 0; }
}
