/* ─── Root & Theme ─────────────────────────────────────────────────────────── */
:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #1e2430;
  --surface3: #252d3d;
  --border: #30363d;
  --accent: #3fb950;
  --accent-dim: #2ea043;
  --accent-glow: rgba(63, 185, 80, 0.15);
  --blue: #58a6ff;
  --purple: #bc8cff;
  --orange: #f0883e;
  --red: #f85149;
  --yellow: #d29922;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-dim: #6e7681;
  --sidebar-w: 240px;
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #5bde6e; }

/* ─── Layout ───────────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 28px 32px;
  max-width: 1200px;
}

/* ─── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

.brand-name { font-size: 16px; font-weight: 700; color: var(--text); line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--text-muted); }

.sidebar-user {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}

.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}

.avatar-admin { background: linear-gradient(135deg, #6e40c9, #bc8cff); color: #fff; }
.avatar-client { background: linear-gradient(135deg, var(--accent-dim), var(--accent)); color: #fff; }

.sidebar-user-info { overflow: hidden; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: var(--text-muted); }

.sidebar-nav { padding: 12px 0; flex: 1; }

.nav-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-dim);
  padding: 8px 20px 4px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px;
  color: var(--text-muted);
  font-size: 13px; font-weight: 500;
  border-radius: 0;
  transition: all .15s;
  cursor: pointer;
  border-left: 3px solid transparent;
}

.nav-item:hover { background: var(--surface2); color: var(--text); border-color: transparent; }
.nav-item.active { background: var(--accent-glow); color: var(--accent); border-left-color: var(--accent); }
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.logout-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  color: var(--text-muted);
  font-size: 13px;
  border-radius: var(--radius-sm);
  width: 100%;
  transition: all .15s;
}

.logout-btn:hover { background: rgba(248, 81, 73, .1); color: var(--red); }

/* ─── Page Header ──────────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}

.page-title { font-size: 24px; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

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

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}

.card-title { font-size: 15px; font-weight: 600; color: var(--text); }
.card-subtitle { font-size: 12px; color: var(--text-muted); }

/* ─── Stat Cards ───────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
}

.stat-card.green::before { background: var(--accent); }
.stat-card.blue::before { background: var(--blue); }
.stat-card.purple::before { background: var(--purple); }
.stat-card.orange::before { background: var(--orange); }
.stat-card.red::before { background: var(--red); }

.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-unit { font-size: 14px; font-weight: 500; color: var(--text-muted); margin-left: 2px; }
.stat-sub { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

/* ─── Progress Bar ─────────────────────────────────────────────────────────── */
.progress-bar-wrap {
  background: var(--surface3);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
  margin-top: 10px;
}

.progress-bar-fill {
  height: 100%; border-radius: 99px;
  transition: width .3s;
  background: var(--accent);
}

.progress-bar-fill.over { background: var(--red); }
.progress-bar-fill.blue { background: var(--blue); }
.progress-bar-fill.purple { background: var(--purple); }
.progress-bar-fill.orange { background: var(--orange); }

/* ─── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  border: none; cursor: pointer;
  transition: all .15s;
  text-decoration: none;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #5bde6e; color: #fff; }
.btn-secondary { background: var(--surface3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface2); border-color: var(--text-muted); }
.btn-danger { background: rgba(248, 81, 73, .1); color: var(--red); border: 1px solid rgba(248, 81, 73, .2); }
.btn-danger:hover { background: rgba(248, 81, 73, .2); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; width: 32px; height: 32px; justify-content: center; }

/* ─── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.form-control {
  width: 100%;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text);
  font-size: 14px;
  transition: border-color .15s;
  outline: none;
}

.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-control::placeholder { color: var(--text-dim); }

select.form-control option { background: var(--surface2); }

textarea.form-control { resize: vertical; min-height: 90px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ─── File Upload ──────────────────────────────────────────────────────────── */
.file-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  position: relative;
}

.file-upload-area:hover, .file-upload-area.drag-over {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.file-upload-area input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}

.file-upload-icon { font-size: 32px; margin-bottom: 8px; }
.file-upload-text { font-size: 13px; color: var(--text-muted); }
.file-upload-text strong { color: var(--accent); }

#photo-preview {
  max-width: 200px; max-height: 200px;
  border-radius: var(--radius);
  margin-top: 12px;
  display: none;
  border: 2px solid var(--accent);
}

/* ─── Mood Selector ────────────────────────────────────────────────────────── */
.mood-selector { display: flex; gap: 8px; }

.mood-btn {
  flex: 1;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface3);
  cursor: pointer;
  text-align: center;
  font-size: 20px;
  transition: all .15s;
}

.mood-btn:hover { border-color: var(--accent); transform: scale(1.05); }
.mood-btn.selected { border-color: var(--accent); background: var(--accent-glow); }

.mood-btn input[type="radio"] { display: none; }

/* ─── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}

th {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); padding: 10px 14px;
  text-align: left; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td { padding: 12px 14px; border-bottom: 1px solid rgba(48, 54, 61, .5); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

/* ─── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px;
  border-radius: 99px; font-size: 11px; font-weight: 600;
}

.badge-green { background: rgba(63, 185, 80, .15); color: var(--accent); }
.badge-blue { background: rgba(88, 166, 255, .15); color: var(--blue); }
.badge-orange { background: rgba(240, 136, 62, .15); color: var(--orange); }
.badge-red { background: rgba(248, 81, 73, .15); color: var(--red); }
.badge-purple { background: rgba(188, 140, 255, .15); color: var(--purple); }
.badge-gray { background: var(--surface3); color: var(--text-muted); }

/* ─── Meal Tags ────────────────────────────────────────────────────────────── */
.meal-tag { font-size: 11px; font-weight: 700; }
.meal-breakfast { color: var(--orange); }
.meal-lunch { color: var(--blue); }
.meal-dinner { color: var(--purple); }
.meal-snack { color: var(--accent); }

/* ─── Client Grid ──────────────────────────────────────────────────────────── */
.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.client-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all .2s;
}

.client-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
}

.client-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.client-avatar { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; flex-shrink: 0; }

.client-name { font-size: 15px; font-weight: 600; color: var(--text); }
.client-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.client-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }

.client-stat {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.client-stat-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.client-stat-value { font-size: 16px; font-weight: 700; color: var(--text); margin-top: 2px; }

/* ─── Weight Photo Grid ────────────────────────────────────────────────────── */
.weight-entries { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }

.weight-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all .2s;
}

.weight-card:hover { border-color: var(--accent); box-shadow: 0 6px 20px rgba(0,0,0,.3); }

.weight-photo {
  width: 100%; aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.weight-photo-placeholder {
  width: 100%; aspect-ratio: 1;
  background: var(--surface3);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: var(--text-dim);
}

.weight-card-body { padding: 12px; }
.weight-value { font-size: 20px; font-weight: 800; color: var(--text); }
.weight-unit { font-size: 12px; color: var(--text-muted); }
.weight-date { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.weight-note { font-size: 12px; color: var(--text-muted); margin-top: 6px; font-style: italic; }

/* ─── Wellbeing Cards ──────────────────────────────────────────────────────── */
.wellbeing-list { display: flex; flex-direction: column; gap: 12px; }

.wellbeing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  position: relative;
}

.wellbeing-meta { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.wellbeing-date { font-size: 12px; color: var(--text-muted); }

.wellbeing-icons { display: flex; gap: 8px; }

.wellbeing-metric {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text-muted);
}

.wellbeing-text { font-size: 14px; color: var(--text); line-height: 1.6; }

.wellbeing-delete {
  position: absolute; top: 12px; right: 12px;
}

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

/* ─── Alerts / Flash ───────────────────────────────────────────────────────── */
.alerts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }

.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
}

.alert-success { background: rgba(63, 185, 80, .1); color: #5bde6e; border: 1px solid rgba(63, 185, 80, .2); }
.alert-danger { background: rgba(248, 81, 73, .1); color: var(--red); border: 1px solid rgba(248, 81, 73, .2); }
.alert-warning { background: rgba(210, 153, 34, .1); color: var(--yellow); border: 1px solid rgba(210, 153, 34, .2); }
.alert-info { background: rgba(88, 166, 255, .1); color: var(--blue); border: 1px solid rgba(88, 166, 255, .2); }

/* ─── Meal Sections ────────────────────────────────────────────────────────── */
.meal-section { margin-bottom: 24px; }

.meal-section-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.meal-section-icon { font-size: 20px; }
.meal-section-name { font-size: 15px; font-weight: 700; }
.meal-section-cal { font-size: 12px; color: var(--text-muted); margin-left: auto; }

/* ─── Empty States ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 24px;
  color: var(--text-muted);
}

.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty-text { font-size: 13px; }

/* ─── Login Page ───────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%; max-width: 400px;
  box-shadow: 0 24px 64px rgba(0,0,0,.5);
}

.login-logo {
  text-align: center; margin-bottom: 32px;
}

.login-icon {
  width: 56px; height: 56px;
  background: var(--accent);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; margin: 0 auto 12px;
}

.login-title { font-size: 22px; font-weight: 800; text-align: center; }
.login-subtitle { font-size: 13px; color: var(--text-muted); text-align: center; margin-top: 4px; }

/* ─── Date Picker Row ──────────────────────────────────────────────────────── */
.date-nav {
  display: flex; align-items: center; gap: 8px;
}

.date-label { font-size: 15px; font-weight: 600; color: var(--text); }

/* ─── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-brand .brand-name,
  .sidebar-brand .brand-sub,
  .sidebar-user-info,
  .nav-item span,
  .nav-section-label { display: none; }
  .main-content { margin-left: 60px; padding: 16px; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ─── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ─── Utilities ────────────────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.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-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.font-bold { font-weight: 700; }
.text-right { text-align: right; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
