:root {
  --primary: #00D4AA;
  --primary-glow: rgba(0, 212, 170, 0.3);
  --secondary: #667EEA;
  --bg-dark: #0A0E1A;
  --bg-card: rgba(20, 27, 45, 0.7);
  --bg-glass: rgba(255, 255, 255, 0.05);
  --border-glass: rgba(255, 255, 255, 0.1);
  --text-primary: #FFFFFF;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.4);
  
  --success: #00E676;
  --warning: #FFB300;
  --danger: #FF5252;
  
  --meal-breakfast: #FF9800;
  --meal-lunch: #4CAF50;
  --meal-dinner: #2196F3;
  --meal-snack: #E91E63;
  
  --font-ar: 'Cairo', sans-serif;
  --font-en: 'Inter', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-ar);
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(circle at 15% 50%, rgba(0, 212, 170, 0.05), transparent 25%),
    radial-gradient(circle at 85% 30%, rgba(102, 126, 234, 0.05), transparent 25%);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

.app-container {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  background-color: var(--bg-dark);
  box-shadow: 0 0 50px rgba(0,0,0,0.5);
  overflow-x: hidden;
  padding-bottom: 80px; /* Space for bottom nav */
}

/* Utilities */
.text-center { text-align: center; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.p-3 { padding: 1rem; }
.w-100 { width: 100%; }
.d-none { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.flex-center { display: flex; align-items: center; }
.space-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.flex-1 { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; }

/* Typography */
h1, h2, h3, h4 { font-weight: 700; margin-bottom: 0.5rem; }
.en-font { font-family: var(--font-en); }

/* Pages */
.page {
  display: none;
  padding: 1.5rem;
  animation: fadeIn 0.3s ease;
}
.page.active {
  display: block;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

/* Glassmorphism Components */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s, box-shadow 0.2s;
}

/* Inputs & Forms */
.input-field {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: 12px;
  font-family: var(--font-ar);
  font-size: 1rem;
  transition: all 0.3s ease;
}
.input-field:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
  background: rgba(255, 255, 255, 0.1);
}

.input-group {
  position: relative;
  margin-bottom: 1rem;
}
.input-group i {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.input-group input {
  width: 100%;
  padding-right: 48px;
}

/* Buttons */
button {
  font-family: var(--font-ar);
  cursor: pointer;
  border: none;
  outline: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #00A383);
  color: #fff;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  box-shadow: 0 4px 15px var(--primary-glow);
  transition: all 0.2s;
}
.btn-primary:active { transform: scale(0.98); }
.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-glass);
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 600;
  transition: all 0.2s;
}
.btn-sm { padding: 8px 16px; font-size: 0.9rem; }
.icon-btn {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  height: 70px;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.75rem;
  transition: color 0.3s;
}
.nav-item i { margin-bottom: 4px; transition: transform 0.3s; }
.nav-item.active { color: var(--primary); }
.nav-item.active i { transform: translateY(-3px); }

/* Circular Progress */
.progress-ring-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 1rem 0 2rem;
}
.progress-ring circle {
  transition: stroke-dashoffset 1s ease-in-out;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}
.progress-text {
  position: absolute;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.progress-text .consumed { font-size: 2.5rem; font-weight: 700; font-family: var(--font-en); line-height: 1; }
.progress-text .target { font-size: 1rem; color: var(--text-muted); font-family: var(--font-en); }
.progress-text .label { font-size: 0.8rem; color: var(--text-secondary); }

/* Macro Bars */
.macros-summary {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.macro-item { flex: 1; text-align: center; font-size: 0.85rem; color: var(--text-secondary); }
.macro-bar {
  height: 6px;
  background: var(--bg-glass);
  border-radius: 3px;
  margin: 6px 0;
  overflow: hidden;
}
.macro-fill { height: 100%; border-radius: 3px; transition: width 1s ease; }
.macro-item.protein .macro-fill { background: var(--secondary); }
.macro-item.carbs .macro-fill { background: var(--warning); }
.macro-item.fat .macro-fill { background: var(--danger); }
.macro-val { font-family: var(--font-en); font-size: 0.8rem; }

/* Meals List */
.meal-card {
  margin-bottom: 1rem;
  padding: 1rem;
  border-radius: 16px;
}
.meal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.meal-title { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }
.meal-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.meal-card.breakfast .meal-icon { background: rgba(255, 152, 0, 0.2); color: var(--meal-breakfast); }
.meal-card.lunch .meal-icon { background: rgba(76, 175, 80, 0.2); color: var(--meal-lunch); }
.meal-card.dinner .meal-icon { background: rgba(33, 150, 243, 0.2); color: var(--meal-dinner); }
.meal-card.snack .meal-icon { background: rgba(233, 30, 99, 0.2); color: var(--meal-snack); }

.food-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-top: 1px solid var(--border-glass);
  font-size: 0.9rem;
}
.food-item-details { display: flex; flex-direction: column; }
.food-macros { font-size: 0.75rem; color: var(--text-muted); font-family: var(--font-en); }

/* FAB */
.fab {
  position: fixed;
  bottom: 85px;
  right: max(20px, calc(50% - 220px));
  width: 56px;
  height: 56px;
  border-radius: 28px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0, 212, 170, 0.4);
  z-index: 90;
  transition: transform 0.2s;
}
.fab:active { transform: scale(0.9); }

/* Auth */
.auth-container { display: flex; flex-direction: column; justify-content: center; min-height: 80vh; }
.logo-container { text-align: center; margin-bottom: 2rem; }
.main-logo-icon { width: 64px; height: 64px; color: var(--primary); margin-bottom: 1rem; }
.auth-tabs { display: flex; background: var(--bg-glass); border-radius: 12px; margin-bottom: 1.5rem; padding: 4px; }
.auth-tab { flex: 1; padding: 10px; border-radius: 8px; color: var(--text-secondary); background: transparent; transition: 0.3s; }
.auth-tab.active { background: var(--primary); color: white; }
.auth-form { display: none; }
.auth-form.active { display: block; animation: fadeIn 0.3s; }

/* Tabs inside pages */
.logger-tabs, .reports-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 1.5rem;
}
.log-tab {
  flex: 1;
  padding: 10px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  color: var(--text-secondary);
}
.log-tab.active {
  background: var(--primary-glow);
  border-color: var(--primary);
  color: var(--primary);
}
.log-panel { display: none; }
.log-panel.active { display: block; animation: fadeIn 0.3s; }

/* Camera / Barcode */
.camera-container, .barcode-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: #000;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
video { width: 100%; height: 100%; object-fit: cover; }
.camera-controls {
  position: absolute;
  bottom: 20px;
  left: 0; right: 0;
  display: flex;
  justify-content: center;
}
.btn-capture {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: 4px solid white;
  display: flex; align-items: center; justify-content: center;
  color: white;
  backdrop-filter: blur(4px);
}

/* Toast & Loading */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 26, 0.9);
  backdrop-filter: blur(5px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.loading-overlay.active { opacity: 1; pointer-events: all; }
.spinner {
  width: 40px; height: 40px;
  border: 4px solid var(--border-glass);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1001;
  width: 90%;
  max-width: 400px;
}
.toast {
  background: rgba(20, 27, 45, 0.95);
  backdrop-filter: blur(10px);
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  animation: slideDown 0.3s, fadeOut 0.3s 2.7s forwards;
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideDown { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeOut { to { opacity: 0; visibility: hidden; } }
