/* === NutritionHub — Dark Purple Theme === */
:root {
  --bg: #0f0b1a;
  --surface: #1a1528;
  --surface2: #231d35;
  --border: #2d2545;
  --text: #e8e4f0;
  --text-muted: #9b92b0;
  --primary: #a855f7;
  --primary-glow: rgba(168, 85, 247, 0.15);
  --green: #34d399;
  --red: #f87171;
  --blue: #60a5fa;
  --orange: #fb923c;
  --yellow: #fbbf24;
  --protein-color: #60a5fa;
  --carb-color: #fbbf24;
  --fat-color: #f87171;
  --fiber-color: #34d399;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html { scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100vh; }

/* Nav */
.nav { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; backdrop-filter: blur(12px); }
.nav-inner { max-width: 1100px; margin: 0 auto; padding: 0 1.25rem; display: flex; align-items: center; justify-content: space-between; height: 60px; }
.logo { font-weight: 700; font-size: 1.2rem; color: var(--primary); text-decoration: none; }
.nav-links { display: flex; gap: 1.5rem; }
.nav-links a { color: var(--text-muted); text-decoration: none; font-size: 0.9rem; font-weight: 500; transition: color 0.2s; }
.nav-links a:hover { color: var(--primary); }
.nav-toggle { display: none; background: none; border: none; color: var(--text); cursor: pointer; width: 28px; height: 28px; }
.nav-toggle svg { width: 100%; height: 100%; }

/* Container */
.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.25rem; }
.card h2 { font-size: 1.15rem; margin-bottom: 1rem; color: var(--text); }

/* Hero Section */
.hero { text-align: center; padding: 2.5rem 0 1.5rem; }
.hero h1 { font-size: 2rem; font-weight: 700; margin-bottom: 0.5rem; }
.hero-sub { color: var(--text-muted); font-size: 1.05rem; margin-bottom: 1.5rem; }

/* Search */
.search-box { max-width: 600px; margin: 0 auto; }
.search-input-wrap { position: relative; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--text-muted); pointer-events: none; }
.search-input { width: 100%; padding: 0.9rem 1rem 0.9rem 2.8rem; background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: 1rem; font-family: var(--font); transition: border-color 0.2s; }
.search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.search-results { position: absolute; top: 100%; left: 0; right: 0; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 4px; max-height: 350px; overflow-y: auto; display: none; z-index: 50; }
.search-results.active { display: block; }
.search-result-item { padding: 0.75rem 1rem; display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: background 0.15s; text-decoration: none; color: var(--text); }
.search-result-item:hover { background: var(--primary-glow); }
.search-result-name { font-weight: 500; }
.search-result-cal { color: var(--text-muted); font-size: 0.85rem; }

/* Tool Grid */
.quick-tools { margin-bottom: 1.5rem; }
.quick-tools h2 { font-size: 1.2rem; margin-bottom: 1rem; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.75rem; }
.tool-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1rem; text-align: center; text-decoration: none; color: var(--text); transition: border-color 0.2s, transform 0.2s; }
.tool-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.tool-icon { font-size: 1.8rem; display: block; margin-bottom: 0.4rem; }
.tool-name { font-weight: 600; font-size: 0.9rem; display: block; }
.tool-desc { color: var(--text-muted); font-size: 0.78rem; display: block; margin-top: 0.2rem; }

/* Food Grid */
.food-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.75rem; }
.food-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; text-decoration: none; color: var(--text); transition: border-color 0.2s; }
.food-card:hover { border-color: var(--primary); }
.food-card-top { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.food-emoji { font-size: 1.3rem; }
.food-card-macros { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.macro-pill { font-size: 0.72rem; padding: 0.2rem 0.5rem; border-radius: 20px; font-weight: 500; }
.macro-pill.cal { background: rgba(168, 85, 247, 0.15); color: var(--primary); }
.macro-pill.prot { background: rgba(96, 165, 250, 0.15); color: var(--protein-color); }
.macro-pill.carb { background: rgba(251, 191, 36, 0.15); color: var(--carb-color); }
.macro-pill.fat { background: rgba(248, 113, 113, 0.15); color: var(--fat-color); }

/* Food Page */
.food-hero { margin-bottom: 1rem; }
.food-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.food-brand { color: var(--text-muted); font-size: 0.9rem; }
.food-category { color: var(--primary); font-size: 0.85rem; font-weight: 500; }
.serving-toggle { display: flex; align-items: center; gap: 0.5rem; margin-top: 1rem; }
.serving-btn { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.4rem 1rem; color: var(--text-muted); cursor: pointer; font-size: 0.85rem; transition: all 0.2s; }
.serving-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Nutrition Grid */
.nutrition-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.macro-card { text-align: center; }
.calorie-display { margin-bottom: 1.5rem; }
.cal-number { font-size: 3rem; font-weight: 700; color: var(--primary); }
.cal-label { display: block; color: var(--text-muted); font-size: 0.9rem; }
.macro-bars { text-align: left; }
.macro-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.6rem; }
.macro-label { width: 60px; font-size: 0.85rem; color: var(--text-muted); flex-shrink: 0; }
.macro-bar-track { flex: 1; height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.macro-bar { height: 100%; border-radius: 4px; transition: width 0.3s; }
.protein-bar { background: var(--protein-color); }
.carb-bar { background: var(--carb-color); }
.fat-bar { background: var(--fat-color); }
.fiber-bar { background: var(--fiber-color); }
.sugar-bar { background: var(--orange); }
.sodium-bar { background: var(--red); }
.macro-value { font-size: 0.85rem; font-weight: 600; width: 55px; text-align: right; flex-shrink: 0; }
#macroChart { max-width: 200px; margin: 1.5rem auto 0; }

/* Nutrient Table */
.nutrient-table { width: 100%; border-collapse: collapse; }
.nutrient-table th, .nutrient-table td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.nutrient-table th { color: var(--text-muted); font-weight: 500; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; }
.dv-pct { color: var(--text-muted); font-size: 0.8rem; margin-left: 0.3rem; }
.muted { color: var(--text-muted); font-style: italic; }

/* Compare */
.compare-subtitle { color: var(--text-muted); }
.compare-table-wrap { overflow-x: auto; margin-bottom: 1.25rem; }
.compare-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.compare-table th, .compare-table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); text-align: center; }
.compare-table th { background: var(--surface2); color: var(--text-muted); font-size: 0.85rem; }
.compare-table td:first-child { text-align: left; font-weight: 500; }
.food-col { min-width: 120px; }
.winner { color: var(--green); font-weight: 600; }
.loser { color: var(--text-muted); }
.compare-links { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.compare-link { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.5rem 1rem; color: var(--primary); text-decoration: none; font-size: 0.85rem; transition: background 0.2s; }
.compare-link:hover { background: var(--primary-glow); }

/* Recipe */
.recipe-analyzer { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.recipe-input-section { grid-column: 1; }
.recipe-results { grid-column: 2; }
.recipe-textarea { width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; color: var(--text); font-family: var(--font); font-size: 0.95rem; resize: vertical; }
.recipe-textarea:focus { outline: none; border-color: var(--primary); }
.recipe-controls { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; }
.recipe-totals { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.5rem; margin-bottom: 1rem; }
.recipe-total-item { text-align: center; padding: 0.75rem 0.5rem; background: var(--surface2); border-radius: var(--radius-sm); }
.recipe-total-item.cal { background: var(--primary-glow); }
.total-value { display: block; font-size: 1.3rem; font-weight: 700; }
.total-label { font-size: 0.75rem; color: var(--text-muted); }
.serving-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 400; }
.error-msg { color: var(--red); padding: 0.5rem 0; font-size: 0.9rem; }

/* Calculators */
.calc-nav { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.calc-nav-link { padding: 0.4rem 0.9rem; border-radius: 20px; font-size: 0.82rem; color: var(--text-muted); text-decoration: none; background: var(--surface2); border: 1px solid var(--border); transition: all 0.2s; }
.calc-nav-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.calc-nav-link:hover:not(.active) { border-color: var(--primary); color: var(--text); }
.calculator-form p { color: var(--text-muted); margin-bottom: 1rem; }
.calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.25rem; }
.calc-field label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.3rem; font-weight: 500; }
.calc-input { width: 100%; padding: 0.65rem 0.85rem; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: 0.95rem; font-family: var(--font); }
.calc-input:focus { outline: none; border-color: var(--primary); }
.calc-result { margin-top: 1.25rem; padding: 1.5rem; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); }
.calc-result h3 { font-size: 1.1rem; margin-bottom: 0.75rem; }
.result-big { font-size: 2.5rem; font-weight: 700; color: var(--primary); display: block; }
.result-label { color: var(--text-muted); font-size: 0.9rem; }
.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.75rem; margin-top: 1rem; }
.result-item { text-align: center; padding: 0.75rem; background: var(--surface); border-radius: var(--radius-sm); }
.result-item-value { display: block; font-size: 1.2rem; font-weight: 700; }
.result-item-label { font-size: 0.78rem; color: var(--text-muted); }
.bmi-scale { display: flex; margin-top: 1rem; border-radius: 6px; overflow: hidden; height: 28px; position: relative; }
.bmi-segment { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 600; color: #000; }
.bmi-underweight { background: var(--blue); }
.bmi-normal { background: var(--green); }
.bmi-overweight { background: var(--orange); }
.bmi-obese { background: var(--red); }
.bmi-marker { position: absolute; top: -6px; width: 3px; height: 40px; background: #fff; border-radius: 2px; transition: left 0.3s; }

/* FAQ */
.faq-section { margin-top: 0.5rem; }
.faq-item { border-bottom: 1px solid var(--border); }
.faq-item:last-child { border-bottom: none; }
.faq-item summary { padding: 0.85rem 0; cursor: pointer; font-weight: 500; color: var(--text); list-style: none; display: flex; justify-content: space-between; align-items: center; }
.faq-item summary::after { content: '+'; color: var(--primary); font-size: 1.2rem; font-weight: 300; }
.faq-item[open] summary::after { content: '−'; }
.faq-item p { padding: 0 0 0.85rem; color: var(--text-muted); font-size: 0.9rem; line-height: 1.7; }

/* Info */
.info-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin-top: 1rem; }
.info-section h2 { margin-bottom: 0.75rem; }
.info-section p { color: var(--text-muted); font-size: 0.92rem; line-height: 1.7; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 0.65rem 1.5rem; border-radius: var(--radius-sm); font-size: 0.95rem; font-weight: 600; font-family: var(--font); cursor: pointer; border: none; transition: all 0.2s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #9333ea; transform: translateY(-1px); }

/* Footer */
.footer { background: var(--surface); border-top: 1px solid var(--border); padding: 1.5rem 1.25rem; margin-top: 2rem; }
.footer-inner { max-width: 1100px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; }
.footer p { color: var(--text-muted); font-size: 0.82rem; }
.footer a { color: var(--primary); text-decoration: none; }
.footer-links { display: flex; gap: 1.25rem; }
.footer-links a { color: var(--text-muted); text-decoration: none; font-size: 0.82rem; }
.footer-links a:hover { color: var(--primary); }

/* Mobile */
@media (max-width: 768px) {
  .nav-toggle { display: block; }
  .nav-links { display: none; position: absolute; top: 60px; left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--border); flex-direction: column; padding: 1rem 1.25rem; gap: 0.75rem; }
  .nav-links.active { display: flex; }

  .hero h1 { font-size: 1.5rem; }
  .hero-sub { font-size: 0.92rem; }

  .nutrition-grid { grid-template-columns: 1fr; }
  .recipe-analyzer { grid-template-columns: 1fr; }
  .recipe-results { grid-column: 1; }
  .recipe-totals { grid-template-columns: repeat(3, 1fr); }

  .calc-grid { grid-template-columns: 1fr; }
  .calc-nav { gap: 0.35rem; }
  .calc-nav-link { font-size: 0.75rem; padding: 0.35rem 0.7rem; }

  .compare-table { font-size: 0.85rem; }
  .food-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .tool-grid { grid-template-columns: repeat(2, 1fr); }

  .footer-inner { flex-direction: column; text-align: center; }
  .result-big { font-size: 2rem; }
}

@media (max-width: 480px) {
  .tool-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .tool-card { padding: 1rem 0.5rem; }
  .recipe-totals { grid-template-columns: repeat(2, 1fr); }
}
