/* ─────────────────────────────────────────────────────
   The META Design System
   Dark aesthetic · Bebas Neue + Inter · Lime accent
   ───────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg:         #0a0a0a;
  --bg-card:    #151515;
  --bg-input:   #1e1e1e;
  --bg-elevated:#1a1a1a;
  --border:     #2a2a2a;
  --text:       #f0f0f0;
  --text-secondary: #b0b0b0;
  --text-muted: #888;
  --text-dim:   #666;
  --accent:     #C4FF3C;
  --accent-bg:  rgba(196,255,60,.08);
  --accent-text:#000;
  --danger:     #FF5A1F;
  --warning:    #FFD93D;
  --success:    #00E5C4;
  --shadow:     none;
  --radius:     12px;
  --radius-sm:  8px;
  --font-display: 'Bebas Neue', sans-serif;
  --font-body:    'Inter', sans-serif;
  --safe-bottom:  env(safe-area-inset-bottom, 20px);
  --transition:   .2s ease;
}

[data-theme="light"] {
  --bg:         #f2f2f7;
  --bg-card:    #ffffff;
  --bg-input:   #f0f0f0;
  --bg-elevated:#ffffff;
  --border:     #d6d6d6;
  --text:       #1a1a1a;
  --text-secondary: #555;
  --text-muted: #777;
  --text-dim:   #999;
  --accent:     #3d8500;
  --accent-bg:  rgba(61,133,0,.08);
  --accent-text:#fff;
  --danger:     #d63000;
  --warning:    #b89500;
  --success:    #008a6e;
  --shadow:     0 1px 3px rgba(0,0,0,.08);
}

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

html {
  overflow-x: hidden;
  width: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  height: 100%;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

#app {
  max-width: 480px;
  overflow-x: hidden;
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── Views ─────────────────────────────────────── */
.view { display: none; flex-direction: column; min-height: 100dvh; width: 100%; max-width: 100%; }
.view.active { display: flex; animation: fadeIn .15s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Splash / Loading ───────────────────────────── */
.splash {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100dvh; gap: 16px;
}
.splash-logo {
  width: 80px; height: 80px; border-radius: 20px;
  background: var(--accent); color: var(--accent-text);
  font-family: var(--font-display); font-size: 48px;
  display: flex; align-items: center; justify-content: center;
}
.splash-name {
  font-family: var(--font-display); font-size: 36px;
  letter-spacing: 2px; color: var(--text);
}
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Typography ─────────────────────────────────── */
h1 { font-family: var(--font-display); font-size: 32px; letter-spacing: 1px; color: var(--text); }
h2 { font-family: var(--font-display); font-size: 24px; letter-spacing: .5px; color: var(--text); }
h3 { font-size: 15px; font-weight: 600; color: var(--text); }
p  { color: var(--text-secondary); font-size: 14px; line-height: 1.6; }

/* ── Cards ──────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

/* ── Buttons ────────────────────────────────────── */
.btn {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; padding: 14px 20px;
  border-radius: var(--radius-sm); border: none; cursor: pointer;
  font-family: var(--font-body); font-size: 15px; font-weight: 600;
  transition: opacity var(--transition), transform .1s, background var(--transition);
  text-decoration: none; width: 100%;
}
.btn:active { transform: scale(.97); opacity: .85; }

.btn-primary   { background: var(--accent); color: var(--accent-text); }
.btn-secondary { background: var(--bg-input); color: var(--text); border: 1px solid var(--border); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-ghost     { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-sm        { padding: 10px 16px; font-size: 14px; }
.btn:disabled  { opacity: .4; cursor: not-allowed; }

/* ── Forms ──────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .6px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  padding: 12px 14px;
  width: 100%;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
input:disabled { opacity: .5; cursor: not-allowed; }
textarea { resize: vertical; min-height: 80px; }

.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* Radio group */
.radio-group { display: flex; gap: 10px; }
.radio-label { flex: 1; }
.radio-label input { display: none; }
.radio-custom {
  display: flex; align-items: center; justify-content: center;
  padding: 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-input);
  cursor: pointer; font-size: 14px; font-weight: 500;
  transition: all var(--transition);
}
.radio-label input:checked + .radio-custom {
  border-color: var(--accent); background: var(--accent-bg); color: var(--accent);
}

/* ── Navigation bar ─────────────────────────────── */
.nav-bar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: min(480px, 100vw);
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: max(var(--safe-bottom), 8px);
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,.15);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 10px 4px 6px;
  cursor: pointer; border: none; background: none;
  color: var(--text-dim); font-size: 10px; font-weight: 500; gap: 3px;
  transition: color var(--transition);
  min-height: 48px;
}
.nav-item.active { color: var(--accent); }
.nav-icon { font-size: 20px; line-height: 1; }

/* ── Page header ────────────────────────────────── */
.page-header {
  padding: 16px 20px 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.page-title { font-family: var(--font-display); font-size: 28px; }

/* ── Scrollable content (above nav) ─────────────── */
.page-content {
  flex: 1; overflow-y: auto;
  padding: 0 16px calc(90px + var(--safe-bottom)) 16px;
  display: flex; flex-direction: column; gap: 14px;
}
.page-content.no-nav { padding-bottom: 20px; }

/* ── Macro rings / summary ──────────────────────── */
.macro-summary {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.macro-cell {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--shadow);
}
.macro-cell .value { font-family: var(--font-display); font-size: 22px; color: var(--accent); }
.macro-cell .label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── Reliability badge ──────────────────────────── */
.reliability-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 20px; font-size: 13px; font-weight: 600;
}
.reliability-high   { background: rgba(0,229,196,.12); color: var(--success); }
.reliability-medium { background: rgba(255,217,61,.12); color: var(--warning); }
.reliability-low    { background: rgba(255,90,31,.12);  color: var(--danger); }

/* ── Meal card ──────────────────────────────────── */
.meal-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: var(--shadow);
}
.meal-icon { font-size: 28px; }
.meal-info { flex: 1; }
.meal-name { font-weight: 600; font-size: 15px; color: var(--text); }
.meal-macros { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.meal-kcal { font-family: var(--font-display); font-size: 20px; color: var(--accent); }

/* ── Adjustment buttons (plate analysis) ────────── */
.adjustment-group { display: flex; gap: 8px; }
.adjustment-group .btn { flex: 1; }

/* ── Upload zone ────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 32px 20px; text-align: center; cursor: pointer;
  transition: border-color var(--transition); position: relative;
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--accent); }
.upload-zone input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.upload-icon { font-size: 40px; margin-bottom: 8px; }

/* ── Toast ──────────────────────────────────────── */
.toast {
  position: fixed; bottom: calc(80px + var(--safe-bottom) + 12px);
  left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 20px;
  font-size: 14px; font-weight: 500; opacity: 0;
  transition: opacity .2s, transform .2s;
  max-width: 340px; text-align: center; z-index: 200;
  pointer-events: none; box-shadow: 0 4px 20px rgba(0,0,0,.2);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger);  color: var(--danger); }

/* ── Auth screens ───────────────────────────────── */
.auth-screen {
  display: flex; flex-direction: column;
  justify-content: center; min-height: 100dvh;
  padding: 40px 24px 24px;
}
.auth-logo { text-align: center; margin-bottom: 40px; }
.auth-logo .logo-mark {
  width: 64px; height: 64px; border-radius: 16px;
  background: var(--accent); color: var(--accent-text);
  font-family: var(--font-display); font-size: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.auth-logo h1 { font-size: 28px; }

/* ── Progress dots (onboarding) ─────────────────── */
.progress-dots { display: flex; gap: 8px; justify-content: center; margin-bottom: 32px; }
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border); transition: background .2s;
}
.dot.active { background: var(--accent); }

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

/* ── Theme switch ─────────────────────────────── */
.theme-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.theme-switch-track {
  width: 44px; height: 24px;
  background: var(--border);
  border-radius: 12px;
  position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
}
.theme-switch-thumb {
  width: 20px; height: 20px;
  background: var(--text-muted);
  border-radius: 50%;
  position: absolute;
  top: 2px; left: 2px;
  transition: transform var(--transition), background var(--transition);
}
.theme-switch.active .theme-switch-track { background: var(--accent); }
.theme-switch.active .theme-switch-thumb {
  transform: translateX(20px);
  background: var(--accent-text);
}
.theme-switch-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ── Utilities ──────────────────────────────────── */
.text-accent  { color: var(--accent); }
.text-muted   { color: var(--text-muted); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.text-center  { text-align: center; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.hidden { display: none !important; }
.flex   { display: flex; }
.flex-col { flex-direction: column; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

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

/* ── Date strip ────────────────────────────────── */
.date-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.date-strip::-webkit-scrollbar { display: none; }
.date-strip .ds-arrow {
  color: var(--text-dim);
  font-size: 20px;
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
  padding: 4px;
}
.date-strip .ds-days {
  display: flex;
  gap: 6px;
  flex: 1;
  overflow-x: auto;
}
.date-strip .ds-day {
  text-align: center;
  flex-shrink: 0;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  background: var(--bg);
  transition: background var(--transition);
}
.date-strip .ds-day .ds-label { font-size: 9px; color: var(--text-dim); text-transform: uppercase; }
.date-strip .ds-day .ds-num   { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.date-strip .ds-day.active    { background: var(--accent); }
.date-strip .ds-day.active .ds-label,
.date-strip .ds-day.active .ds-num   { color: var(--accent-text); font-weight: 700; }
.date-strip .ds-day.has-data .ds-num { color: var(--text-secondary); }

/* ── Steps banner ──────────────────────────────── */
.steps-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 12px 16px 0;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
  overflow: hidden;
}
.steps-banner input {
  width: 80px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  padding: 6px 8px;
  text-align: center;
}
.steps-banner .steps-label { flex: 1; font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.steps-banner .btn-sm {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 14px;
  cursor: pointer;
  transition: opacity var(--transition);
  min-height: 36px;
}
.steps-banner .btn-sm:active { opacity: .8; }

/* ── Dashboard macro grid ──────────────────────── */
.dash-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin: 12px 16px 0;
  box-shadow: var(--shadow);
}
.dash-kcal-remaining { font-size: 36px; font-weight: 800; color: var(--accent); line-height: 1.1; }
.dash-kcal-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.dash-bar {
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  margin: 10px 0 4px;
}
.dash-bar-fill {
  height: 6px; border-radius: 3px;
  background: var(--accent); max-width: 100%;
  transition: width .4s ease;
}
.dash-stats {
  display: flex;
  gap: 8px;
  margin: 10px 16px 0;
}
.dash-stat {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  box-shadow: var(--shadow);
}
.dash-stat-val { font-size: 15px; font-weight: 700; color: var(--accent); }
.dash-stat-lbl { font-size: 10px; color: var(--text-muted); margin-top: 2px; font-weight: 500; }
.macro-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 16px 0;
}
.macro-cell .mc-label { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; font-weight: 600; }
.macro-cell .mc-val   { font-size: 16px; font-weight: 700; color: var(--text); }
.macro-cell .mc-goal  { font-size: 10px; color: var(--text-dim); font-weight: 500; }
.macro-cell .mc-bar   { height: 4px; background: var(--bg-input); border-radius: 2px; margin-top: 8px; }
.macro-cell .mc-fill  { height: 4px; border-radius: 2px; max-width: 100%; transition: width .4s ease; }

/* ── Meal type tabs ────────────────────────────── */
.input-tabs {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 14px;
}
.input-tab {
  flex: 1;
  text-align: center;
  padding: 10px 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  background: var(--bg);
  border-right: 1px solid var(--border);
  transition: background var(--transition), color var(--transition);
}
.input-tab:last-child { border-right: none; }
.input-tab.active { background: var(--accent); color: var(--accent-text); font-weight: 700; }

/* ── Ingredient rows (advanced mode) ──────────── */
.ingredient-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
.ingredient-row input[type=text]   { flex: 3; padding: 10px; }
.ingredient-row input[type=number] { flex: 1; text-align: center; padding: 10px; }
.state-toggle-wrap {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}
.st-opt {
  font-size: 11px;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text-dim);
  background: var(--bg);
  transition: background var(--transition), color var(--transition);
  user-select: none;
  font-weight: 500;
}
.st-opt.st-active {
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
}
.remove-ing { color: var(--text-dim); font-size: 18px; cursor: pointer; padding: 6px; flex-shrink: 0; }
.remove-ing:active { color: var(--danger); }

/* ── Admin cards ───────────────────────────────── */
.admin-client-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}
.admin-client-card .client-name { font-size: 15px; font-weight: 600; color: var(--text); }
.admin-client-card .client-meta { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.activity-dot-green  { color: #4caf50; font-size: 11px; font-weight: 500; }
.activity-dot-yellow { color: #ff9800; font-size: 11px; font-weight: 500; }
.activity-dot-red    { color: #e91e63; font-size: 11px; font-weight: 500; }
