/* ============================================================
   LEANPROTOCOL CLIENT APP — STYLES
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0f172a;
  --bg2:      #1e293b;
  --bg3:      #263045;
  --accent:   #22d3ee;
  --accent2:  #0891b2;
  --green:    #10b981;
  --red:      #ef4444;
  --gold:     #f59e0b;
  --white:    #f8fafc;
  --muted:    #94a3b8;
  --border:   #334155;
  --radius:   12px;
  --tab-h:    68px;
  --nav-h:    56px;
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--white);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ── SCREENS ─────────────────────────────────────────────── */
.screen { display: none; flex-direction: column; height: 100%; }
.screen.active { display: flex; }

/* ── TOP NAV ─────────────────────────────────────────────── */
.top-nav {
  height: var(--nav-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
}
.nav-back {
  background: none; border: none; color: var(--accent);
  font-size: 22px; cursor: pointer; padding: 4px 8px 4px 0;
  line-height: 1;
}
.nav-title { font-weight: 700; font-size: 16px; flex: 1; }
.nav-action {
  background: none; border: none; color: var(--accent);
  font-size: 22px; cursor: pointer; padding: 4px;
}

/* ── SCROLLABLE CONTENT ──────────────────────────────────── */
.scroll-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(var(--tab-h) + 16px);
}
.scroll-content.no-tabs { padding-bottom: 24px; }

/* ── TAB BAR ─────────────────────────────────────────────── */
.tab-bar {
  height: var(--tab-h);
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-item {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px;
  background: none; border: none;
  color: var(--muted);
  font-size: 10px; font-weight: 600;
  cursor: pointer;
  transition: color .2s;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.tab-item.active { color: var(--accent); }
.tab-icon { font-size: 20px; line-height: 1; }

/* ── ONBOARDING ──────────────────────────────────────────── */
#screen-onboard {
  background: var(--bg);
  justify-content: center;
  align-items: center;
}
.onboard-wrap {
  width: 100%; max-width: 420px;
  padding: 32px 24px;
  display: flex; flex-direction: column;
  gap: 0;
}
.onboard-logo { font-size: 28px; font-weight: 900; margin-bottom: 8px; }
.onboard-logo span { color: var(--accent); }
.onboard-step { display: none; }
.onboard-step.active { display: flex; flex-direction: column; gap: 20px; }
.onboard-title { font-size: 22px; font-weight: 800; line-height: 1.3; }
.onboard-sub { font-size: 14px; color: var(--muted); line-height: 1.6; }
.step-dots {
  display: flex; gap: 6px; margin-bottom: 8px;
}
.step-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border); transition: background .2s;
}
.step-dot.active { background: var(--accent); }

/* ── FORM ELEMENTS ───────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--white);
  font-size: 15px;
  padding: 12px 14px;
  border-radius: var(--radius);
  outline: none;
  width: 100%;
  transition: border-color .2s;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); }
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--muted); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.form-hint { font-size: 11px; color: var(--muted); }

.toggle-group { display: flex; background: var(--bg3); border-radius: var(--radius); padding: 3px; gap: 3px; }
.toggle-btn {
  flex: 1; padding: 8px; border: none; border-radius: 9px;
  background: transparent; color: var(--muted);
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all .2s;
}
.toggle-btn.active { background: var(--accent); color: var(--bg); }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 13px 20px; border-radius: var(--radius);
  font-weight: 700; font-size: 15px; cursor: pointer; border: none;
  transition: all .2s; width: 100%;
}
.btn-primary { background: var(--accent); color: var(--bg); }
.btn-primary:hover { background: var(--accent2); }
.btn-ghost { background: var(--bg2); color: var(--white); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-green { background: var(--green); color: #fff; }
.btn-danger { background: rgba(239,68,68,.12); color: var(--red); border: 1px solid rgba(239,68,68,.2); }
.btn-sm { padding: 8px 14px; font-size: 13px; width: auto; }
.btn-whatsapp { background: #25D366; color: #fff; width: 100%; }
.btn-whatsapp:hover { background: #1ebe5d; }

/* ── COACH CONTACT CARD ──────────────────────────────────── */
.coach-contact-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.coach-contact-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
  font-weight: 500;
}

/* ── CHECKIN LOCKED STATE ────────────────────────────────── */
.checkin-lock-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 20px 32px;
}
.checkin-lock-icon {
  font-size: 52px;
  margin-bottom: 20px;
  opacity: .8;
}
.checkin-lock-title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 10px;
}
.checkin-lock-sub {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 28px;
  max-width: 280px;
}

/* ── DASHBOARD ───────────────────────────────────────────── */
.dash-header {
  background: linear-gradient(135deg, rgba(34,211,238,.1), rgba(34,211,238,.02));
  border: 1px solid rgba(34,211,238,.15);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.dash-greeting { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.dash-name { font-size: 22px; font-weight: 800; }
.dash-date { font-size: 12px; color: var(--muted); margin-top: 2px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.stat-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.stat-val { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.stat-unit { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stat-delta { font-size: 12px; font-weight: 600; margin-top: 4px; }
.stat-delta.up { color: var(--green); }
.stat-delta.down { color: var(--red); }
.stat-delta.neutral { color: var(--muted); }

.chart-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.chart-card h3 { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px; }

.week-avg-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.week-avg-card h3 { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px; }
.week-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.week-row:last-child { border-bottom: none; }
.week-label { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.week-avg { font-size: 16px; font-weight: 700; color: var(--text); }
.week-days { font-size: 11px; color: var(--muted); margin-left: 4px; }
.week-delta { font-size: 14px; font-weight: 600; text-align: right; }
.week-delta.loss { color: var(--green); }
.week-delta.gain { color: #f87171; }
.week-delta.neutral { color: var(--muted); }

.macro-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.macro-card h3 { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 14px; }
.macro-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.macro-label { font-size: 13px; font-weight: 600; width: 60px; flex-shrink: 0; }
.macro-bar-wrap { flex: 1; height: 8px; background: var(--bg3); border-radius: 4px; overflow: hidden; }
.macro-bar { height: 100%; border-radius: 4px; transition: width .5s; }
.macro-bar.protein { background: var(--accent); }
.macro-bar.carbs { background: var(--gold); }
.macro-bar.fat { background: #a78bfa; }
.macro-nums { font-size: 12px; color: var(--muted); width: 80px; text-align: right; flex-shrink: 0; }

.quick-log-btn {
  position: fixed;
  bottom: calc(var(--tab-h) + 16px);
  right: 16px;
  width: 52px; height: 52px;
  background: var(--accent);
  color: var(--bg);
  border: none; border-radius: 50%;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(34,211,238,.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
  transition: transform .15s;
}
.quick-log-btn:active { transform: scale(.93); }

.no-data-msg {
  text-align: center; padding: 40px 20px;
  color: var(--muted); font-size: 14px; line-height: 1.6;
}
.no-data-msg .icon { font-size: 40px; margin-bottom: 12px; }

/* ── LOG ENTRY ───────────────────────────────────────────── */
.rating-row { display: flex; gap: 6px; }
.rating-dot {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--bg3); border: 1px solid var(--border);
  font-size: 13px; font-weight: 700; color: var(--muted);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.rating-dot.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* ── HISTORY ─────────────────────────────────────────────── */
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
  cursor: pointer; transition: border-color .2s;
}
.history-item:hover { border-color: var(--accent); }
.history-date-block { text-align: center; flex-shrink: 0; width: 42px; }
.history-month { font-size: 10px; color: var(--muted); text-transform: uppercase; font-weight: 700; }
.history-day { font-size: 22px; font-weight: 800; line-height: 1; }
.history-info { flex: 1; }
.history-weight { font-size: 18px; font-weight: 800; }
.history-macros { font-size: 12px; color: var(--muted); margin-top: 2px; }
.history-tags { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.htag {
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 100px;
  text-transform: uppercase; letter-spacing: .04em;
}
.htag-training { background: rgba(34,211,238,.1); color: var(--accent); }
.htag-rest { background: rgba(148,163,184,.1); color: var(--muted); }

/* ── WEEKLY CHECK-IN ─────────────────────────────────────── */
.checkin-summary {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.checkin-summary h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.checkin-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.checkin-row:last-child { border-bottom: none; }
.checkin-key { font-size: 13px; color: var(--muted); }
.checkin-val { font-size: 14px; font-weight: 700; }

/* ── SETTINGS ────────────────────────────────────────────── */
.settings-section { margin-bottom: 24px; }
.settings-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; padding-left: 4px; }
.settings-row {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 8px;
}
.settings-row-info { flex: 1; }
.settings-row-info strong { font-size: 14px; display: block; }
.settings-row-info span { font-size: 12px; color: var(--muted); }

/* ── MODALS ──────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.75); z-index: 200;
  align-items: flex-end; justify-content: center;
  padding: 0;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg2); border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
}
.modal-handle { width: 40px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 20px; }
.modal h2 { font-size: 18px; font-weight: 800; margin-bottom: 16px; }
.modal-close { float: right; background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; margin-top: -4px; }

/* ── TOAST ───────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: calc(var(--tab-h) + 16px); left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg2); border: 1px solid var(--border);
  color: var(--white); padding: 10px 20px; border-radius: 100px;
  font-size: 13px; font-weight: 600; z-index: 300;
  transition: all .3s; opacity: 0; pointer-events: none; white-space: nowrap;
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ── PROGRESS RING ───────────────────────────────────────── */
.goal-ring-wrap { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.goal-ring-info h3 { font-size: 16px; font-weight: 800; }
.goal-ring-info p { font-size: 13px; color: var(--muted); margin-top: 4px; }
svg.ring { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--bg3); stroke-width: 8; }
.ring-fill { fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset .8s ease; }

/* ── EMPTY STATE ─────────────────────────────────────────── */
.tag { display: inline-block; background: rgba(34,211,238,.12); color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 3px 12px; border-radius: 100px; border: 1px solid rgba(34,211,238,.2); }

/* ── SECTION DIVIDER ─────────────────────────────────────── */
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-head h3 { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.section-head a { font-size: 12px; color: var(--accent); cursor: pointer; }
