/* ===== DESIGN TOKENS (ocean green theme) ===== */
:root {
  /* Dark ocean green palette */
  --bg-body: #04100e;
  --bg-primary: #081a16;
  --bg-secondary: #0c241e;
  --bg-card: rgba(12, 40, 34, 0.82);
  --bg-card-solid: #102e26;
  --bg-elevated: rgba(16, 46, 38, 0.9);
  --bg-hover: rgba(255, 255, 255, 0.05);

  /* Glass */
  --glass-bg: rgba(4, 16, 14, 0.7);
  --glass-border: rgba(255, 255, 255, 0.09);
  --glass-border-hover: rgba(255, 255, 255, 0.15);

  /* Text */
  --text-primary: #e8f5f0;
  --text-secondary: #88b4a6;
  --text-muted: #5a8a7c;
  --text-bright: #ffffff;

  /* Accent (avocat) */
  --accent: #8db600;
  --accent-bright: #a8cc2a;
  --accent-hover: #749800;
  --accent-glow: rgba(141, 182, 0, 0.35);
  --accent-gradient: linear-gradient(135deg, #6b8e23 0%, #a8cc2a 100%);
  --accent-glow-color: #c5e17a;

  /* Semantic */
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;

  /* Keto verdicts */
  --keto-green: #22c55e;
  --keto-orange: #f59e0b;
  --keto-red: #ef4444;

  /* Borders & shadows */
  --border: #1a3018;
  --border-subtle: #122210;
  --border-hover: #4a7a20;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
  --shadow-card: 0 4px 30px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --shadow-glow: 0 0 20px rgba(141, 182, 0, 0.3);

  /* Spacing */
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 32px;
  --sp-2xl: 48px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Consolas', monospace;

  /* Transitions */
  --transition-fast: 0.15s ease;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
input, button, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
::selection { background: rgba(141, 182, 0, 0.3); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.15); }

/* ===== BODY & LAYOUT ===== */
html, body {
  background: var(--bg-body);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
}

body::before {
  content: '';
  position: fixed;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 500px;
  background: radial-gradient(ellipse, rgba(141, 182, 0, 0.05) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  padding: var(--sp-lg);
  padding-bottom: calc(var(--sp-lg) + env(safe-area-inset-bottom, 0px));
}

/* ===== HEADER ===== */
.header {
  text-align: center;
  margin-bottom: var(--sp-2xl);
}

.brand {
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(135deg, var(--accent-bright) 0%, var(--accent-glow-color) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 16px rgba(141, 182, 0, 0.35));
}

.brand-dk {
  font-weight: 900;
  -webkit-text-fill-color: transparent;
  background: linear-gradient(135deg, #ffffff 0%, var(--accent-bright) 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-top: var(--sp-xs);
  font-weight: 300;
}

/* ===== SEARCH ===== */
.search-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.search-form {
  width: 100%;
  max-width: 520px;
  position: relative;
}

.search-input-wrap {
  display: flex;
  gap: var(--sp-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 6px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(141, 182, 0, 0.1);
}

.search-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  padding: 12px 16px;
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  color: #fff;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.search-btn:hover {
  box-shadow: 0 0 24px rgba(141, 182, 0, 0.3);
  transform: translateY(-1px);
}

.search-btn:active {
  transform: scale(0.95);
}

.search-btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* ===== AUTOCOMPLETE ===== */
.suggestions {
  list-style: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 10;
  display: none;
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-top: var(--sp-xs);
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
}

.suggestions.visible {
  display: block;
}

.suggestion-item {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 10px var(--sp-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.suggestion-item:hover,
.suggestion-item.active {
  background: var(--bg-hover);
}

.suggestion-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
}

.suggestion-dot.keto { background: var(--keto-green); }
.suggestion-dot.moderate { background: var(--keto-orange); }
.suggestion-dot.not_keto { background: var(--keto-red); }

.suggestion-text {
  font-size: 0.9rem;
  color: var(--text-primary);
}

/* ===== RAINBOW GLOW LOADING ===== */
.search-input-wrap.loading {
  animation: rainbow-glow 2s linear infinite;
  border-color: transparent;
}

@keyframes rainbow-glow {
  0%   { box-shadow: 0 0 8px 2px #a8cc2a, 0 0 24px 6px rgba(168, 204, 42, 0.25); border-color: #a8cc2a; }
  25%  { box-shadow: 0 0 8px 2px #22c55e, 0 0 24px 6px rgba(34, 197, 94, 0.25); border-color: #22c55e; }
  50%  { box-shadow: 0 0 8px 2px #c5e17a, 0 0 24px 6px rgba(197, 225, 122, 0.25); border-color: #c5e17a; }
  75%  { box-shadow: 0 0 8px 2px #6b8e23, 0 0 24px 6px rgba(107, 142, 35, 0.25); border-color: #6b8e23; }
  100% { box-shadow: 0 0 8px 2px #a8cc2a, 0 0 24px 6px rgba(168, 204, 42, 0.25); border-color: #a8cc2a; }
}

/* ===== RESULT AREA ===== */
.result-area {
  width: 100%;
  max-width: 520px;
  margin-top: var(--sp-xl);
  display: none;
}

.result-area.visible {
  display: block;
  animation: fadeSlideUp 0.4s ease;
}

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== RESULT CARD ===== */
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.result-card::before {
  content: '';
  display: block;
  height: 3px;
}

.result-card.verdict-keto::before { background: var(--keto-green); }
.result-card.verdict-moderate::before { background: var(--keto-orange); }
.result-card.verdict-not_keto::before { background: var(--keto-red); }

.result-body {
  padding: var(--sp-lg);
  text-align: center;
}

/* Verdict badge */
.verdict-badge {
  display: inline-block;
  padding: 8px 24px;
  border-radius: 100px;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: var(--sp-md);
}

.verdict-keto .verdict-badge {
  background: rgba(34, 197, 94, 0.1);
  color: var(--keto-green);
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.verdict-moderate .verdict-badge {
  background: rgba(245, 158, 11, 0.1);
  color: var(--keto-orange);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.verdict-not_keto .verdict-badge {
  background: rgba(239, 68, 68, 0.1);
  color: var(--keto-red);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

/* Food name */
.result-food-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: var(--sp-sm);
}

/* ===== NUTRITION GRID ===== */
.nutrition-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-sm);
  margin: var(--sp-lg) 0;
  padding: var(--sp-md);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.nutrition-item {
  text-align: center;
  padding: var(--sp-sm) 0;
}

.nutrition-value {
  font-size: 1.2rem;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1;
}

.nutrition-value.carbs { color: var(--keto-orange); }
.nutrition-value.fat { color: #fbbf24; }
.nutrition-value.protein { color: #60a5fa; }
.nutrition-value.kcal { color: var(--accent-bright); }

.nutrition-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
}

/* ===== EXPLANATION & RECOMMENDATION ===== */
.result-explanation {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  text-align: left;
  margin-top: var(--sp-md);
  padding-top: var(--sp-md);
  border-top: 1px solid var(--border-subtle);
}

.result-recommendation {
  font-size: 0.85rem;
  color: var(--text-primary);
  margin-top: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  background: rgba(141, 182, 0, 0.06);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  text-align: left;
  line-height: 1.5;
}

.result-warning {
  font-size: 0.8rem;
  color: var(--keto-orange);
  margin-top: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  background: rgba(245, 158, 11, 0.06);
  border-left: 3px solid var(--keto-orange);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  text-align: left;
  line-height: 1.5;
}

.result-footer {
  margin-top: var(--sp-sm);
  padding-top: var(--sp-sm);
  border-top: 1px solid var(--border-subtle);
  text-align: center;
}

.result-source {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  opacity: 0.6;
}

/* ===== ERROR ===== */
.error-message {
  max-width: 520px;
  width: 100%;
  margin-top: var(--sp-md);
  padding: var(--sp-sm) var(--sp-md);
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-md);
  color: var(--danger);
  font-size: 0.85rem;
  text-align: center;
  display: none;
}

.error-message.visible {
  display: block;
  animation: fadeSlideUp 0.3s ease;
}

/* ===== RESPONSIVE: TABLET+ ===== */
@media (min-width: 768px) {
  .brand {
    font-size: 3.8rem;
  }

  .subtitle {
    font-size: 0.95rem;
  }

  .nutrition-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .nutrition-value {
    font-size: 1.3rem;
  }

  .result-food-name {
    font-size: 1.4rem;
  }
}

/* ===== RESPONSIVE: SMALL MOBILE ===== */
@media (max-width: 380px) {
  #app {
    padding: var(--sp-md) var(--sp-sm);
  }

  .brand {
    font-size: 1.8rem;
    letter-spacing: 2px;
  }

  .header {
    margin-bottom: var(--sp-xl);
  }

  .search-input {
    padding: 10px 12px;
    font-size: 16px;
  }

  .search-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .verdict-badge {
    font-size: 0.95rem;
    padding: 6px 18px;
  }

  .result-food-name {
    font-size: 1.1rem;
  }

  .nutrition-value {
    font-size: 1rem;
  }

  .result-body {
    padding: var(--sp-md);
  }
}
