/* ════════════════════════════════════════
   CalTrack — Modern App Design
   Inspired by MyFitnessPal / iOS Health
   ════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800&display=swap');

:root {
  /* Brand */
  --primary:       #3B82F6;
  --primary-dark:  #2563EB;
  --primary-light: #EFF6FF;

  /* Macro colors */
  --cal-color:     #3B82F6;
  --carb-color:    #10B981;
  --fat-color:     #8B5CF6;
  --protein-color: #F59E0B;

  /* Semantic */
  --success:       #10B981;
  --success-light: #D1FAE5;
  --warning:       #F59E0B;
  --warning-light: #FEF3C7;
  --danger:        #EF4444;
  --danger-light:  #FEE2E2;
  --secondary:     #06B6D4;

  /* Layout */
  --bg:       #E8F0FB;
  --bg-card:  #FFFFFF;
  --bg-card2: #F8FAFD;
  --text:     #1E293B;
  --text-muted: #64748B;
  --border:   #E2E8F0;

  --radius:    16px;
  --radius-sm: 10px;
  --shadow:    0 2px 8px rgba(59,130,246,.08), 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 8px 24px rgba(59,130,246,.12);
  --transition: .15s ease;
}

/* ─── Reset ─── */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { font-size: 16px; }

body {
  font-family: 'Tajawal', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }

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

/* ════════════════════════════════════════
   NAVBAR
   ════════════════════════════════════════ */
.navbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(59,130,246,.08);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
}
.navbar-brand .brand-icon {
  width: 30px; height: 30px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .95rem;
}
.navbar-brand span { color: var(--text); }

.navbar-nav {
  display: flex; align-items: center; gap: 2px;
  list-style: none; flex: 1; justify-content: center;
}
.navbar-nav a {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 13px; border-radius: 99px;
  font-size: .85rem; font-weight: 500;
  color: var(--text-muted); transition: var(--transition);
}
.navbar-nav a:hover  { background: var(--bg-card2); color: var(--text); }
.navbar-nav a.active { background: var(--primary-light); color: var(--primary); font-weight: 700; }

.navbar-user {
  display: flex; align-items: center; gap: 8px;
  font-size: .85rem; color: var(--text-muted);
}
.navbar-user .user-name { font-weight: 500; white-space: nowrap; }

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #818CF8);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem; color: #fff; flex-shrink: 0;
}

/* ════════════════════════════════════════
   LAYOUT
   ════════════════════════════════════════ */
.container { max-width: 1200px; margin: 0 auto; padding: 1.25rem; }

.page-header { margin-bottom: 1.25rem; }
.page-title  { font-size: 1.5rem; font-weight: 800; color: var(--text); }
.page-subtitle { color: var(--text-muted); margin-top: 3px; font-size: .875rem; font-weight: 400; }

/* ════════════════════════════════════════
   CARDS
   ════════════════════════════════════════ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 1rem;
  display: flex; align-items: center; gap: 6px;
  text-transform: uppercase; letter-spacing: .06em;
}

/* ════════════════════════════════════════
   STAT CARDS
   ════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .75rem; margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  position: relative; overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-card::after {
  content: '';
  position: absolute; top: 0; right: 0;
  width: 3px; height: 100%;
  background: var(--accent, var(--primary));
  border-radius: 0 var(--radius) var(--radius) 0;
}

.stat-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; margin-bottom: .6rem; color: var(--primary);
}
.stat-value { font-size: 1.75rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: .78rem; color: var(--text-muted); margin-top: 3px; font-weight: 500; }

/* ════════════════════════════════════════
   MACRO PROGRESS BARS
   ════════════════════════════════════════ */
.macro-bar-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

.macro-bar-row {
  display: flex;
  gap: 1.5rem;
}

.macro-bar-item {
  flex: 1;
  display: flex; flex-direction: column; gap: 5px;
}
.macro-bar-label {
  display: flex; justify-content: space-between;
  font-size: .8rem; font-weight: 600; color: var(--text-muted);
}
.macro-bar-label span:last-child { color: var(--text); font-weight: 700; }

.macro-bar-track {
  height: 6px; border-radius: 99px;
  background: var(--border); overflow: hidden;
}
.macro-bar-fill {
  height: 100%; border-radius: 99px;
  transition: width .8s cubic-bezier(.4,0,.2,1);
}
.macro-bar-fill.carbs   { background: var(--carb-color); }
.macro-bar-fill.fat     { background: var(--fat-color); }
.macro-bar-fill.protein { background: var(--protein-color); }

/* Calories bar big */
.cal-bar-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: .75rem;
}
.cal-bar-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: .6rem;
}
.cal-bar-title { font-size: .78rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.cal-bar-main  { font-size: 1.6rem; font-weight: 800; color: var(--text); }
.cal-bar-main span { font-size: .9rem; font-weight: 500; color: var(--text-muted); }
.cal-bar-remaining { font-size: .85rem; color: var(--text-muted); font-weight: 500; }

.cal-bar-track { height: 8px; border-radius: 99px; background: var(--border); overflow: hidden; }
.cal-bar-fill  { height: 100%; border-radius: 99px; background: var(--cal-color); transition: width .8s cubic-bezier(.4,0,.2,1); }

/* ════════════════════════════════════════
   PROGRESS RING
   ════════════════════════════════════════ */
.progress-ring-wrap {
  display: flex; flex-direction: column; align-items: center; gap: .75rem;
}
.progress-ring-svg { transform: rotate(-90deg); }
.progress-ring-bg   { fill: none; stroke: var(--border);   stroke-width: 10; }
.progress-ring-fill {
  fill: none; stroke: var(--primary);
  stroke-width: 10; stroke-linecap: round;
  transition: stroke-dashoffset 1s cubic-bezier(.4,0,.2,1);
}
.ring-center {
  position: absolute;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.ring-value { font-size: 1.5rem; font-weight: 800; }
.ring-label { font-size: .72rem; color: var(--text-muted); font-weight: 500; }

/* ════════════════════════════════════════
   FOOD ITEMS
   ════════════════════════════════════════ */
.food-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: background var(--transition), border-color var(--transition);
}
.food-item + .food-item { margin-top: 6px; }
.food-item:hover { background: var(--primary-light); border-color: rgba(59,130,246,.25); }

.food-item-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0; color: var(--primary);
}
.food-item-info { flex: 1; min-width: 0; }
.food-item-name { font-weight: 700; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.food-item-meta { font-size: .75rem; color: var(--text-muted); margin-top: 1px; }
.food-item-cal  { font-weight: 800; color: var(--primary); font-size: .9rem; white-space: nowrap; }
.food-item-del  {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: .95rem; padding: 5px;
  border-radius: var(--radius-sm); transition: var(--transition); flex-shrink: 0;
}
.food-item-del:hover { color: var(--danger); background: var(--danger-light); }

/* ════════════════════════════════════════
   MEAL GROUP CARD  (diary style)
   ════════════════════════════════════════ */
.meal-group {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: .75rem;
}
.meal-group-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1.1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}
.meal-group-header .meal-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary); font-size: .95rem; margin-left: 8px;
}
.meal-group-body { padding: .5rem .75rem; }

/* ════════════════════════════════════════
   FORMS
   ════════════════════════════════════════ */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block; font-size: .875rem; font-weight: 700;
  margin-bottom: 5px; color: var(--text);
}
.form-control {
  width: 100%;
  background: var(--bg-card2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  color: var(--text); font-size: .875rem; font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
  background: var(--bg-card);
}
.form-control::placeholder { color: var(--text-muted); }
.form-row   { display: grid; grid-template-columns: 1fr 1fr;     gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
select.form-control { cursor: pointer; }

/* ════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 18px;
  border: 1.5px solid transparent; border-radius: 99px;
  font-size: .875rem; font-weight: 700; font-family: inherit;
  cursor: pointer; transition: all var(--transition);
  outline: none; white-space: nowrap; user-select: none;
}
.btn:focus-visible { box-shadow: 0 0 0 3px rgba(59,130,246,.3); }

.btn-primary  { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover  { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-secondary { background: var(--bg-card2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }

.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #059669; }

.btn-full { width: 100%; }
.btn-lg   { padding: 11px 24px; font-size: .95rem; }
.btn-sm   { padding: 5px 13px;  font-size: .8rem; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-sm); }

/* ════════════════════════════════════════
   MODALS
   ════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
  padding: 1rem;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1.5rem;
  width: 100%; max-width: 480px;
  max-height: 92vh; overflow-y: auto;
  transform: translateY(20px) scale(.97);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1);
  box-shadow: 0 20px 60px rgba(15,23,42,.2);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem; padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1.1rem; font-weight: 800; }
.modal-close {
  background: var(--bg-card2); border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1rem;
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.modal-close:hover { background: var(--danger-light); color: var(--danger); }

/* ════════════════════════════════════════
   ALERTS
   ════════════════════════════════════════ */
.alert {
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: .875rem; margin-bottom: 1rem;
  display: flex; align-items: flex-start; gap: 8px;
  border-width: 1px; border-style: solid; font-weight: 500;
}
.alert-success { background: var(--success-light); color: #065F46; border-color: #6EE7B7; }
.alert-error   { background: var(--danger-light);  color: #991B1B; border-color: #FCA5A5; }
.alert-info    { background: var(--primary-light); color: #1E40AF; border-color: #93C5FD; }

/* ════════════════════════════════════════
   BADGES
   ════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 9px; border-radius: 99px;
  font-size: .72rem; font-weight: 700;
}
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-success { background: var(--success-light); color: #065F46; }
.badge-danger  { background: var(--danger-light);  color: #991B1B; }
.badge-warning { background: var(--warning-light); color: #92400E; }

/* ════════════════════════════════════════
   TABLE
   ════════════════════════════════════════ */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: right; border-bottom: 1px solid var(--border); font-size: .875rem; }
th {
  color: var(--text-muted); font-weight: 700;
  background: var(--bg-card2);
  font-size: .75rem; text-transform: uppercase; letter-spacing: .05em;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--primary-light); }

/* ════════════════════════════════════════
   TABS
   ════════════════════════════════════════ */
.tabs {
  display: flex; gap: 4px;
  background: var(--bg-card2); border: 1px solid var(--border);
  border-radius: 99px; padding: 4px; margin-bottom: 1.25rem;
}
.tab-btn {
  flex: 1; padding: 7px 12px; border: none; border-radius: 99px;
  background: none; cursor: pointer;
  color: var(--text-muted); font-size: .875rem; font-weight: 700; font-family: inherit;
  transition: all var(--transition);
}
.tab-btn.active { background: var(--bg-card); color: var(--primary); box-shadow: var(--shadow); }
.tab-btn:hover:not(.active) { color: var(--text); }

/* ════════════════════════════════════════
   CAMERA UI
   ════════════════════════════════════════ */
.camera-container {
  position: relative; width: 100%;
  border-radius: var(--radius); overflow: hidden;
  background: #0F172A; aspect-ratio: 4/3;
  border: 1px solid var(--border);
}
#camera-video, #camera-canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding-bottom: 1.5rem;
  background: linear-gradient(to top, rgba(0,0,0,.55) 0%, transparent 50%);
}
.capture-btn {
  width: 64px; height: 64px; border-radius: 50%;
  border: 4px solid #fff; background: rgba(255,255,255,.25);
  cursor: pointer; transition: var(--transition); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
}
.capture-btn:hover { background: rgba(255,255,255,.4); transform: scale(1.05); }

.scan-line {
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  animation: scanDown 2s ease-in-out infinite;
}
@keyframes scanDown { 0%{top:0;opacity:1} 80%{opacity:1} 100%{top:100%;opacity:0} }

/* ════════════════════════════════════════
   CHARTS
   ════════════════════════════════════════ */
.chart-bar-wrap { display:flex; align-items:flex-end; gap:5px; height:120px; }
.chart-bar-col  { flex:1; display:flex; flex-direction:column; align-items:center; gap:3px; height:100%; justify-content:flex-end; }
.chart-bar {
  width: 100%; background: linear-gradient(to top, var(--primary), #818CF8);
  border-radius: 6px 6px 0 0; min-height: 4px;
  transition: height .8s cubic-bezier(.4,0,.2,1);
}
.chart-bar-label { font-size:.68rem; color:var(--text-muted); text-align:center; font-weight:600; }

/* ════════════════════════════════════════
   MACRO PILLS
   ════════════════════════════════════════ */
.macro-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:.75rem; }
.macro-pill {
  background: var(--bg-card2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 8px; text-align: center;
}
.macro-value { font-size:1.15rem; font-weight:800; }
.macro-label { font-size:.72rem; color:var(--text-muted); margin-top:2px; font-weight:600; }

/* ════════════════════════════════════════
   MISC COMPONENTS
   ════════════════════════════════════════ */
.trend-up     { color: var(--danger); }
.trend-down   { color: var(--success); }
.trend-stable { color: var(--text-muted); }

.spinner {
  width: 30px; height: 30px;
  border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite; margin: auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.glow-primary { box-shadow: 0 0 20px rgba(59,130,246,.3); }
.glow-success { box-shadow: 0 0 20px rgba(16,185,129,.3); }

.img-preview {
  width: 100%; max-height: 220px;
  object-fit: contain; border-radius: var(--radius);
  border: 2px dashed var(--border);
}
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 2rem; text-align: center; cursor: pointer;
  transition: var(--transition); color: var(--text-muted);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary); background: var(--primary-light); color: var(--primary);
}
.analyzing-overlay {
  position: absolute; inset: 0;
  background: rgba(255,255,255,.9); backdrop-filter: blur(6px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 1rem; border-radius: var(--radius);
}
.analyzing-text { font-size: 1rem; font-weight: 700; color: var(--primary); }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.45} }
.pulse { animation: pulse 1.5s ease-in-out infinite; }

.progress-bar-wrap {
  background: var(--border); border-radius: 99px; height: 6px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; background: var(--primary);
  border-radius: 99px; transition: width .8s cubic-bezier(.4,0,.2,1);
}

/* ════════════════════════════════════════
   AUTH PAGE
   ════════════════════════════════════════ */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  background:
    radial-gradient(ellipse 700px 600px at 15% 85%, rgba(59,130,246,.12) 0%, transparent 100%),
    radial-gradient(ellipse 500px 700px at 90%  5%, rgba(99,102,241,.10) 0%, transparent 100%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2.25rem 2rem;
  box-shadow: 0 8px 40px rgba(59,130,246,.14);
}
.auth-logo { text-align: center; margin-bottom: 1.75rem; }
.auth-logo .ms-logo {
  display: inline-grid; grid-template-columns: 1fr 1fr; gap: 3px; margin-bottom: 12px;
}
.auth-logo .ms-logo span { width: 18px; height: 18px; border-radius: 2px; }
.auth-logo .ms-logo .sq1 { background: #F25022; }
.auth-logo .ms-logo .sq2 { background: #7FBA00; }
.auth-logo .ms-logo .sq3 { background: #00A4EF; }
.auth-logo .ms-logo .sq4 { background: #FFB900; }
.auth-logo h1 { font-size: 1.5rem; font-weight: 800; color: var(--text); }
.auth-logo p  { color: var(--text-muted); font-size: .875rem; margin-top: 3px; }

/* ════════════════════════════════════════
   GRIDS
   ════════════════════════════════════════ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr;     gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* ════════════════════════════════════════
   ADMIN SIDEBAR
   ════════════════════════════════════════ */
.admin-layout { display: flex; min-height: calc(100vh - 56px); }
.admin-sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--bg-card); border-left: 1px solid var(--border);
  padding: 1rem .75rem;
}
.admin-content { flex: 1; padding: 1.5rem; overflow: auto; }

.sidebar-nav { list-style: none; display: flex; flex-direction: column; gap: 3px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 13px; border-radius: 99px;
  color: var(--text-muted); font-size: .875rem; font-weight: 500;
  transition: var(--transition);
}
.sidebar-nav a:hover  { background: var(--bg-card2); color: var(--text); }
.sidebar-nav a.active { background: var(--primary-light); color: var(--primary); font-weight: 700; }

/* ════════════════════════════════════════
   FITNESS EXTRAS
   ════════════════════════════════════════ */
.bmi-arc-track { fill:none; stroke:var(--border); stroke-width:18; stroke-linecap:round; }
.bmi-arc-fill  { fill:none; stroke-width:18; stroke-linecap:round; transition:stroke-dashoffset 1.3s ease; }

.workout-done-badge {
  display:inline-flex; align-items:center; gap:4px;
  background:var(--success-light); color:#065F46;
  border:1px solid #6EE7B7; border-radius:99px;
  padding:3px 10px; font-size:.75rem; font-weight:700;
}
.step-progress-dot {
  width:8px; height:8px; border-radius:50%;
  background:var(--border); transition:background .2s;
}
.step-progress-dot.active { background:var(--primary); }
.step-progress-dot.done   { background:var(--success); }

.wt-trend-up   { color:var(--success); }
.wt-trend-down { color:var(--danger); }

.comparison-strip { display:flex; gap:8px; overflow-x:auto; padding-bottom:6px; }
.comparison-item  {
  flex-shrink:0; width:120px;
  background:var(--bg-card2); border:1px solid var(--border);
  border-radius:var(--radius-sm); overflow:hidden;
}
.comparison-item img { width:100%; height:150px; object-fit:cover; display:block; }
.comparison-item-lbl { padding:5px 8px; font-size:.72rem; color:var(--text-muted); text-align:center; }

@keyframes slideIn   { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:none} }
@keyframes fadeSlide { from{opacity:0;transform:translateX(12px)} to{opacity:1;transform:none} }
@keyframes completeFlash {
  0%{opacity:0;transform:scale(.7)} 50%{opacity:1;transform:scale(1.05)} 100%{opacity:0;transform:scale(1.2)}
}
.complete-flash { animation:completeFlash .7s ease forwards; }

/* ════════════════════════════════════════
   MOBILE BOTTOM NAV  (5 tabs + center +)
   ════════════════════════════════════════ */
.mobile-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  z-index: 150;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -4px 20px rgba(59,130,246,.10);
}
.mobile-nav-inner {
  display: flex; align-items: center; height: 64px;
}
.mobile-nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  text-decoration: none;
  color: var(--text-muted); font-size: .64rem; font-weight: 700;
  transition: color var(--transition);
  position: relative; height: 100%;
}
.mobile-nav-item i { font-size: 1.3rem; transition: transform .15s ease; }
.mobile-nav-item.active { color: var(--primary); }
.mobile-nav-item.active i { transform: translateY(-2px); }
.mobile-nav-item.active::before {
  content: '';
  position: absolute; top: 0; left: 20%; right: 20%;
  height: 3px; background: var(--primary);
  border-radius: 0 0 4px 4px;
}
.mobile-nav-item:hover { color: var(--primary); }

/* Center "+" button */
.mobile-nav-center {
  flex: 0 0 64px; display: flex;
  align-items: center; justify-content: center;
  margin-bottom: 8px; position: relative; top: -10px;
}
.mobile-nav-center a {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.6rem;
  box-shadow: 0 4px 16px rgba(59,130,246,.45);
  transition: all var(--transition);
  text-decoration: none;
}
.mobile-nav-center a:hover { background: var(--primary-dark); transform: scale(1.08); box-shadow: 0 6px 20px rgba(59,130,246,.55); }
.mobile-nav-center a:active { transform: scale(.95); }

/* ════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════ */
@media (max-width: 768px) {
  .mobile-nav { display: block; }
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }

  .navbar-nav { display: none; }
  .navbar-user .user-name,
  .navbar-user .btn-sm  { display: none; }

  .container { padding: .875rem; }

  .form-row, .form-row-3, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-grid  { grid-template-columns: 1fr 1fr; gap: .625rem; }
  .macro-bar-row { gap: .75rem; }
  .admin-sidebar { display: none; }
  .admin-content { padding: 1rem; }
  .page-title    { font-size: 1.25rem; }
  .auth-card     { padding: 1.75rem 1.25rem; }
  .modal         { padding: 1.25rem; border-radius: 20px 20px 0 0; align-self: flex-end; width: 100%; max-width: 100%; }
  .modal-overlay { align-items: flex-end; padding: 0; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: .5rem; }
  .stat-value { font-size: 1.45rem; }
  .navbar     { padding: 0 .875rem; height: 52px; }
  .macro-grid { grid-template-columns: repeat(3,1fr); }
  .comparison-strip { -webkit-overflow-scrolling: touch; }
}
