/* ============================================
   TodayFit · Nutrition Web App Styles
   ============================================ */
:root {
  --green: #22c55e;
  --green-bg: #f0fdf4;
  --green-dark: #166534;
  --orange: #f97316;
  --orange-bg: #fff7ed;
  --blue: #3b82f6;
  --blue-bg: #eff6ff;
  --purple: #8b5cf6;
  --purple-bg: #f5f3ff;
  --red: #ef4444;
  --red-bg: #fef2f2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.1);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
#app { min-height: 100vh; display: flex; flex-direction: column; }

/* === Login === */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #f0fdf4 0%, #eff6ff 100%);
}
.login-card {
  background: white; border-radius: var(--radius); padding: 48px 40px;
  width: 420px; max-width: 96vw; box-shadow: var(--shadow-lg);
}
.login-card h1 { font-size: 28px; font-weight: 700; margin-bottom: 4px; }
.login-card p { color: var(--gray-500); font-size: 14px; margin-bottom: 28px; }
.login-card .error { background: var(--red-bg); color: var(--red); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; display: none; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--gray-700); }
.form-group input, .form-group select {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm);
  font-size: 14px; transition: border-color .2s; outline: none; font-family: inherit;
}
.form-group input:focus, .form-group select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(34,197,94,.15); }
.btn {
  padding: 10px 20px; border-radius: var(--radius-sm); border: none; font-weight: 600;
  font-size: 14px; cursor: pointer; transition: all .2s; font-family: inherit;
}
.btn-primary { background: var(--green); color: white; width: 100%; padding: 12px; font-size: 15px; }
.btn-primary:hover { background: #16a34a; transform: translateY(-1px); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-outline { background: transparent; border: 1.5px solid var(--gray-200); color: var(--gray-700); }
.btn-outline:hover { border-color: var(--green); color: var(--green); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #dc2626; }
.link { color: var(--green); text-decoration: none; font-weight: 600; font-size: 13px; cursor: pointer; }
.link:hover { text-decoration: underline; }
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }

/* === App Layout === */
.app-layout { display: flex; flex: 1; }
.sidebar {
  width: 240px; background: white; border-right: 1px solid var(--gray-200);
  padding: 20px 0; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100;
}
.sidebar-logo { padding: 0 20px 20px; font-size: 18px; font-weight: 700; color: var(--green-dark); border-bottom: 1px solid var(--gray-100); margin-bottom: 12px; }
.sidebar nav { flex: 1; padding: 0 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius-sm);
  color: var(--gray-500); font-size: 13px; font-weight: 500; cursor: pointer; transition: all .15s;
}
.nav-item:hover { background: var(--gray-50); color: var(--gray-700); }
.nav-item.active { background: var(--green-bg); color: var(--green-dark); font-weight: 600; }
.nav-item .icon { width: 20px; text-align: center; font-size: 16px; }
.sidebar-footer { padding: 12px 20px; border-top: 1px solid var(--gray-100); font-size: 12px; color: var(--gray-500); }
.main-content { margin-left: 240px; flex: 1; padding: 28px 32px; }
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 22px; font-weight: 700; }
.page-header p { color: var(--gray-500); font-size: 14px; margin-top: 4px; }

/* === Cards === */
.card {
  background: white; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
}
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { text-align: center; padding: 24px; }
.stat-card .value { font-size: 32px; font-weight: 700; color: var(--green-dark); }
.stat-card .label { font-size: 13px; color: var(--gray-500); margin-top: 4px; }
.stat-card .sub { font-size: 11px; color: var(--gray-300); }

/* === Meal Plan === */
.meal-day { margin-bottom: 20px; }
.meal-day-header {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--gray-50); padding: 12px 16px; border-radius: var(--radius-sm);
  font-weight: 600; cursor: pointer; transition: background .2s;
}
.meal-day-header:hover { background: var(--gray-100); }
.meal-card {
  padding: 14px 16px; border-left: 3px solid var(--green); margin: 8px 0;
  background: white; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.meal-card h4 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.meal-card .items { font-size: 13px; color: var(--gray-700); line-height: 1.6; }
.meal-card .macros { display: flex; gap: 12px; margin-top: 6px; font-size: 12px; color: var(--gray-500); }
.meal-card .macros span { background: var(--gray-50); padding: 2px 8px; border-radius: 6px; }
.meal-type { display: inline-block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--gray-500); margin-bottom: 4px; }
.food-item { display: flex; flex-direction: column; padding: 6px 0; border-bottom: 1px solid var(--gray-100); }
.food-item:last-child { border: none; }
.food-item-info { display: flex; justify-content: space-between; align-items: center; }
.food-item-edit { display: flex; align-items: center; gap: 4px; margin-top: 4px; padding: 4px 0; }
.food-portion { color: var(--gray-500); font-size: 12px; }
.food-cals { font-size: 13px; font-weight: 500; }
.btn-icon { width: 30px; height: 26px; border: 1px solid var(--gray-200); background: white; border-radius: 6px; cursor: pointer; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; }
.btn-icon:hover { background: var(--gray-100); }
.btn-icon-danger { border-color: var(--red); color: var(--red); }
.portion-input { width: 50px; text-align: center; padding: 3px 4px; border: 1.5px solid var(--gray-200); border-radius: 6px; font-size: 13px; font-family: inherit; }

/* === Tabs === */
.tabs { display: flex; gap: 4px; background: var(--gray-100); padding: 4px; border-radius: var(--radius-sm); margin-bottom: 20px; }
.tab { padding: 8px 18px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; transition: all .2s; color: var(--gray-500); border: none; background: none; font-family: inherit; }
.tab.active { background: white; color: var(--gray-900); box-shadow: var(--shadow); }

/* === Food Log === */
.food-entry { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--gray-100); }
.food-entry:last-child { border: none; }
.food-entry .info { flex: 1; }
.food-entry .info .name { font-weight: 500; font-size: 14px; }
.food-entry .info .detail { font-size: 12px; color: var(--gray-500); }
.food-entry .cals { font-weight: 600; font-size: 14px; color: var(--orange); }
.food-entry .actions { display: flex; gap: 4px; }

/* === Progress Bar === */
.progress-bar { height: 6px; background: var(--gray-100); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.progress-bar .fill { height: 100%; border-radius: 3px; transition: width .5s ease; }
.fill-green { background: var(--green); }
.fill-orange { background: var(--orange); }
.fill-blue { background: var(--blue); }
.fill-red { background: var(--red); }

/* === Food Search === */
.search-box { display: flex; gap: 8px; margin-bottom: 16px; }
.search-box input { flex: 1; padding: 10px 14px; border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm); font-size: 14px; outline: none; font-family: inherit; }
.search-box input:focus { border-color: var(--green); }
.search-results { max-height: 280px; overflow-y: auto; }
.search-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer; transition: background .15s; }
.search-item:hover { background: var(--gray-50); }
.search-item .name { font-weight: 500; font-size: 14px; }
.search-item .cals { font-size: 13px; color: var(--gray-500); }

/* === Nutritionist Clients === */
.client-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--gray-100); }
.client-row:last-child { border: none; }
.client-row .name { font-weight: 600; font-size: 14px; }
.client-row .email { font-size: 12px; color: var(--gray-500); }

/* === Modal === */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal {
  background: white;
  border-radius: 16px;
  padding: 24px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px rgba(0,0,0,0.2);
}
.modal h3 { margin-bottom: 8px; }
.modal .form-group { margin-bottom: 12px; }
.modal .actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* === Spinner === */
.loading { display: flex; align-items: center; gap: 8px; padding: 12px 0; font-size: 14px; color: var(--gray-500); }
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Badge === */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-green { background: var(--green-bg); color: var(--green-dark); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }

/* === Responsive === */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar nav .nav-item span:not(.icon) { display: none; }
  .sidebar-logo span { display: none; }
  .main-content { margin-left: 60px; padding: 20px 16px; }
  .card-grid { grid-template-columns: 1fr; }
}

/* === Loading === */
.loading { text-align: center; padding: 40px; color: var(--gray-500); font-size: 14px; }
.spinner { display: inline-block; width: 20px; height: 20px; border: 2.5px solid var(--gray-200); border-top-color: var(--green); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-300); }

/* === Supplements Table === */
.supplement-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--gray-100); }
.supplement-row:last-child { border: none; }
.supplement-row .name { flex: 1; font-weight: 500; font-size: 14px; }
.supplement-row .dose { font-size: 13px; color: var(--gray-500); }
.supplement-row .time { font-size: 12px; padding: 3px 10px; background: var(--green-bg); color: var(--green-dark); border-radius: 12px; }

/* === Skeleton Loading === */
.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-50) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 8px;
}
.skeleton-text { height: 14px; width: 80%; margin-bottom: 8px; }
.skeleton-title { height: 22px; width: 60%; margin-bottom: 12px; }
.skeleton-card { height: 110px; border-radius: 12px; margin-bottom: 12px; }
.skeleton-row { height: 46px; margin-bottom: 8px; }
.skeleton-stat { height: 100px; border-radius: 16px; padding: 16px; }
.skeleton-avatar { width: 36px; height: 36px; border-radius: 50%; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.lazy-load { min-height: 100px; opacity: 0; transition: opacity 0.3s; }
.lazy-load.loaded { opacity: 1; }
