/* ─── Reset & Base ───────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5f7fa;
  color: #1a1a2e;
  line-height: 1.5;
  min-height: 100vh;
}
a { color: #4caf50; text-decoration: none; }
a:hover { color: #388e3c; }

/* ─── Layout ────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: #fff; border-right: 1px solid #e5e7eb;
  display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar-logo {
  padding: 20px 16px; font-size: 18px; font-weight: 700;
  border-bottom: 1px solid #e5e7eb; display: flex; align-items: center; gap: 8px;
}
.sidebar-logo svg { width: 28px; height: 28px; }
.sidebar-nav { flex: 1; padding: 12px 8px; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 10px; color: #6b7280; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all .15s; border: none; background: none; width: 100%; text-align: left;
}
.sidebar-link:hover { background: #f0fdf4; color: #4caf50; }
.sidebar-link.active { background: #e8f5e9; color: #2e7d32; font-weight: 600; }
.sidebar-link svg { width: 20px; height: 20px; flex-shrink: 0; }
.sidebar-footer { padding: 12px 8px; border-top: 1px solid #e5e7eb; }
.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: #fff; padding: 12px 24px; border-bottom: 1px solid #e5e7eb;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar-title { font-size: 20px; font-weight: 700; }
.topbar-user { display: flex; align-items: center; gap: 12px; font-size: 14px; color: #6b7280; }
.content { flex: 1; padding: 24px; overflow-y: auto; }

/* ─── Cards ─────────────────────────────────── */
.card {
  background: #fff; border-radius: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  padding: 20px; margin-bottom: 16px;
}
.card-title { font-size: 14px; font-weight: 600; color: #6b7280; margin-bottom: 8px; }
.card-flex { display: flex; gap: 16px; flex-wrap: wrap; }
.stat-card {
  flex: 1; min-width: 160px; background: #fff; border-radius: 12px;
  padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,0.05); border: 1px solid #e5e7eb;
}
.stat-card-header { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #6b7280; margin-bottom: 6px; }
.stat-card-value { font-size: 24px; font-weight: 700; }
.stat-card-sub { font-size: 12px; color: #6b7280; }
.stat-card svg { width: 20px; height: 20px; flex-shrink: 0; }

/* ─── Progress Bar ──────────────────────────── */
.progress-bar { height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; margin: 8px 0; }
.progress-fill { height: 100%; background: #4caf50; border-radius: 4px; transition: width .3s ease; }

/* ─── Buttons ───────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: 10px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all .15s; border: none; font-family: inherit;
}
.btn-primary { background: #4caf50; color: #fff; }
.btn-primary:hover { background: #388e3c; }
.btn-outline { background: transparent; color: #6b7280; border: 1px solid #d1d5db; }
.btn-outline:hover { background: #f3f4f6; }
.btn-ghost { background: transparent; color: #6b7280; border: none; }
.btn-ghost:hover { background: #f3f4f6; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-icon {
  width: 36px; height: 36px; padding: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-micro { padding: 8px 16px; font-size: 13px; border-radius: 20px; }

/* ─── Forms ─────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.form-input {
  width: 100%; padding: 10px 14px; border: 1px solid #d1d5db; border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #fff; transition: border-color .15s;
}
.form-input:focus { outline: none; border-color: #4caf50; box-shadow: 0 0 0 3px rgba(76,175,80,0.1); }
.form-input.error { border-color: #ef4444; }
.form-select {
  width: 100%; padding: 10px 14px; border: 1px solid #d1d5db; border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #fff; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
}
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-hint { font-size: 12px; color: #9ca3af; margin-top: 4px; }
.form-error { font-size: 12px; color: #ef4444; margin-top: 4px; display: none; }
.form-error.show { display: block; }
.password-wrapper { position: relative; }
.password-wrapper .form-input { padding-right: 40px; }
.password-toggle {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  cursor: pointer; font-size: 18px; line-height: 1; user-select: none;
}

/* ─── Chips / Badges ────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 14px; border-radius: 20px; border: 1px solid #d1d5db;
  background: #fff; font-size: 13px; cursor: pointer; transition: all .15s; user-select: none;
}
.chip:hover { border-color: #4caf50; }
.chip.selected { background: #e8f5e9; border-color: #4caf50; color: #2e7d32; }

/* ─── Radio Group ───────────────────────────── */
.radio-group { display: flex; flex-direction: column; gap: 6px; }
.radio-btn {
  padding: 10px 16px; border-radius: 10px; border: 2px solid #d1d5db;
  background: #fff; font-size: 14px; cursor: pointer; transition: all .15s;
}
.radio-btn:hover { border-color: #4caf50; }
.radio-btn.selected { border-color: #4caf50; background: #e8f5e9; color: #2e7d32; font-weight: 600; }

/* ─── Meal Cards ────────────────────────────── */
.meal-card {
  background: #fff; border-radius: 12px; border: 1px solid #e5e7eb;
  margin-bottom: 12px; overflow: hidden;
}
.meal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; cursor: pointer; background: #fafafa;
}
.meal-header-title { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.meal-header-title svg { width: 18px; height: 18px; }
.meal-body { padding: 12px 16px; }
.meal-product {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0; font-size: 13px; border-bottom: 1px solid #f3f4f6;
}
.meal-product:last-child { border-bottom: none; }
.meal-product-name { color: #374151; }
.meal-product-kbju { color: #6b7280; font-size: 12px; }
.meal-total { display: flex; justify-content: space-between; padding: 8px 0 0; font-size: 13px; font-weight: 600; border-top: 1px solid #e5e7eb; margin-top: 8px; }

/* ─── Questionnaire ─────────────────────────── */
.questionnaire-step { display: none; }
.questionnaire-step.active { display: block; }
.step-indicator { display: flex; align-items: center; gap: 8px; margin-bottom: 24px; }
.step-dot {
  width: 28px; height: 28px; border-radius: 50%; background: #e5e7eb;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: #9ca3af;
}
.step-dot.active { background: #4caf50; color: #fff; }
.step-dot.done { background: #10b981; color: #fff; }
.step-line { flex: 1; height: 2px; background: #e5e7eb; }
.step-line.done { background: #10b981; }

/* ─── Modal ─────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal {
  background: #fff; border-radius: 16px; padding: 24px; width: 90%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-title { font-size: 18px; font-weight: 700; }

/* ─── Toast ─────────────────────────────────── */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 16px; border-radius: 10px; font-size: 14px; color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15); animation: slideIn .3s ease; max-width: 360px;
}
.toast-success { background: #10b981; }
.toast-error { background: #ef4444; }
.toast-info { background: #3b82f6; }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── Auth Pages ────────────────────────────── */
.auth-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(135deg, #e8f5e9 0%, #f5f7fa 100%);
}
.auth-card {
  background: #fff; border-radius: 20px; box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  padding: 40px; width: 100%; max-width: 420px;
}
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo svg { width: 48px; height: 48px; }
.auth-title { font-size: 24px; font-weight: 700; text-align: center; margin-bottom: 8px; }
.auth-subtitle { font-size: 14px; color: #6b7280; text-align: center; margin-bottom: 24px; }
.auth-footer { text-align: center; font-size: 13px; color: #6b7280; margin-top: 20px; }

/* ─── Calendar ──────────────────────────────── */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.calendar-day {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: 14px; border-radius: 8px; cursor: pointer; background: #fff;
}
.calendar-day:hover { background: #f0fdf4; }
.calendar-day.today { background: #4caf50; color: #fff; font-weight: 600; }
.calendar-day.other-month { color: #d1d5db; }
.calendar-day.has-data { border-bottom: 2px solid #4caf50; }
.calendar-weekday { text-align: center; font-size: 12px; color: #6b7280; padding: 8px 0; font-weight: 600; }

/* ─── Weight Trend ──────────────────────────── */
.trend-chart { width: 100%; height: 200px; }

/* ─── Voice Input ───────────────────────────── */
.voice-wave {
  display: flex; align-items: center; justify-content: center; gap: 3px; height: 60px;
}
.voice-wave span {
  width: 4px; background: #4caf50; border-radius: 2px; animation: wave 1s ease-in-out infinite;
}
.voice-wave span:nth-child(1) { height: 20px; animation-delay: 0s; }
.voice-wave span:nth-child(2) { height: 35px; animation-delay: .1s; }
.voice-wave span:nth-child(3) { height: 50px; animation-delay: .2s; }
.voice-wave span:nth-child(4) { height: 35px; animation-delay: .3s; }
.voice-wave span:nth-child(5) { height: 20px; animation-delay: .4s; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.5); }
  50% { transform: scaleY(1); }
}

/* ─── Tab Navigation ────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid #e5e7eb; margin-bottom: 16px; }
.tab {
  padding: 10px 20px; font-size: 14px; font-weight: 500; color: #6b7280;
  cursor: pointer; border-bottom: 2px solid transparent; transition: all .15s;
  background: none; border-top: none; border-left: none; border-right: none; font-family: inherit;
}
.tab:hover { color: #4caf50; }
.tab.active { color: #4caf50; border-bottom-color: #4caf50; font-weight: 600; }

/* ─── Spinner ──────────────────────────────── */
.spinner {
  width: 24px; height: 24px; border: 3px solid #e5e7eb; border-top-color: #4caf50;
  border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Empty State ──────────────────────────── */
.empty-state { text-align: center; padding: 40px 20px; color: #6b7280; }
.empty-state svg { width: 64px; height: 64px; opacity: .4; margin-bottom: 16px; }
.empty-state-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.empty-state-text { font-size: 14px; }

/* ─── Product Search ────────────────────────── */
.search-wrap { position: relative; }
.search-wrap .form-input { padding-left: 40px; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: #9ca3af; }
.search-results { margin-top: 8px; border: 1px solid #e5e7eb; border-radius: 10px; max-height: 240px; overflow-y: auto; }
.search-result {
  padding: 10px 14px; cursor: pointer; font-size: 14px; display: flex; justify-content: space-between; align-items: center;
}
.search-result:hover { background: #f0fdf4; }
.search-result:not(:last-child) { border-bottom: 1px solid #f3f4f6; }

/* ─── Symptoms Badges ───────────────────────── */
.symptom-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.symptom-badge {
  padding: 10px; border-radius: 10px; border: 1px solid #e5e7eb; text-align: center;
  cursor: pointer; font-size: 13px; transition: all .15s;
}
.symptom-badge:hover { border-color: #4caf50; }
.symptom-badge.selected { background: #fee2e2; border-color: #fca5a5; color: #dc2626; }

/* ─── Water Quick Buttons ───────────────────── */
.water-quick { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.water-quick button {
  padding: 12px 20px; border-radius: 10px; border: 2px solid #e5e7eb;
  background: #fff; font-size: 16px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.water-quick button:hover { border-color: #3b82f6; background: #eff6ff; }

/* ─── Responsive ────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .stat-card { min-width: calc(50% - 8px); }
  .form-row { flex-direction: column; gap: 0; }
  .auth-card { margin: 16px; padding: 24px; }
}

/* ─── Mobile Bottom Nav ─────────────────────── */
.mobile-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: #fff; border-top: 1px solid #e5e7eb; z-index: 100;
  padding: 8px 0; justify-content: space-around;
}
.mobile-nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 10px; color: #6b7280; cursor: pointer; background: none; border: none; padding: 4px 12px;
}
.mobile-nav-item svg { width: 22px; height: 22px; }
.mobile-nav-item.active { color: #4caf50; }

@media (max-width: 768px) {
  .mobile-nav { display: flex; }
  .content { padding-bottom: 72px; }
}

/* ─── Misc ──────────────────────────────────── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: #6b7280; font-size: 13px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
