/* =====================
   Variables & Reset
   ===================== */
:root {
  --primary: #14532d;
  --primary-dark: #0f3d21;
  --primary-light: #166534;
  --primary-pale: #dcfce7;
  --primary-border: #bbf7d0;
  --accent: #16a34a;
  --text-primary: #111827;
  --text-secondary: #374151;
  --text-muted: #6b7280;
  --bg: #ffffff;
  --bg-section: #f9fafb;
  --border: #e5e7eb;
  --border-focus: #14532d;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #dc2626;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08), 0 2px 12px rgba(0,0,0,0.05);
  --font: 'Inter', sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-section);
  color: var(--text-primary);
  min-height: 100vh;
}

/* =====================
   Header
   ===================== */
.header {
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  box-shadow: 0 2px 8px rgba(20,83,45,0.3);
}

.header .logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header .logo-icon { font-size: 1.5rem; }

.header .logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.navbar .logo-text {
  color: #15803d;
}

.nav-badge {
  font-size: 0.8rem;
  font-weight: 500;
  color: rgba(255,255,255,0.75);
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 5px 14px;
  border-radius: 50px;
}

/* =====================
   Main Content
   ===================== */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.page-title {
  margin-bottom: 28px;
}

.page-title h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
}

.page-title p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* =====================
   Layout Grid
   ===================== */
.calculator-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
  align-items: start;
}

.results-panel {
  display: grid;
  gap: 18px;
  min-width: 0;
}

/* =====================
   Cards
   ===================== */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary-pale);
}

/* =====================
   Input Card
   ===================== */
.input-card {
  position: sticky;
  top: 24px;
  min-width: 0;
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.label-hint {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
}

/* Select */
.form-select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--bg);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(20,83,45,0.1);
}

.tea-description {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  background: var(--primary-pale);
  border-left: 3px solid var(--primary);
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
}

/* Number Inputs */
.input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-input {
  width: 100px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  outline: none;
  text-align: center;
}

.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(20,83,45,0.1);
}

.input-unit {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Calculate Button */
.calculate-btn {
  width: 100%;
  padding: 12px 20px;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  letter-spacing: 0.2px;
}

.calculate-btn:hover {
  background: var(--primary-dark);
}

.calculate-btn:active {
  background: var(--primary-light);
}

/* =====================
   Result Hero Card
   ===================== */
.result-hero-card {
  border-left: 4px solid var(--primary);
}

.result-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.caffeine-display {}

.caffeine-number {
  font-size: 3rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.caffeine-unit {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Health Badge */
.health-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 50px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid;
}

.health-badge.waiting  { background: #f3f4f6; border-color: #d1d5db; color: var(--text-muted); }
.health-badge.healthy  { background: #dcfce7; border-color: #86efac; color: #15803d; }
.health-badge.moderate { background: #fef9c3; border-color: #fde047; color: #92400e; }
.health-badge.caution  { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }

.result-tea-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.result-meta-row {
  display: flex;
  gap: 32px;
  margin-bottom: 20px;
}

.result-meta-item {}

.meta-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.meta-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Daily Limit Bar */
.limit-bar-section {}

.limit-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.limit-bar-track {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.limit-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.5s ease, background 0.4s ease;
  max-width: 100%;
}

.limit-bar-fill.moderate { background: #d97706; }
.limit-bar-fill.caution  { background: #dc2626; }

/* =====================
   Stats Grid
   ===================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 0;
}

.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}

.stat-icon { font-size: 1.4rem; margin-bottom: 6px; }

.stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 3px;
}

.stat-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* =====================
   Insights
   ===================== */
.insights-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.insight-placeholder {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 12px 0;
}

.insight-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid;
}

.insight-item.positive { background: #f0fdf4; border-color: #bbf7d0; }
.insight-item.neutral  { background: #fffbeb; border-color: #fde68a; }
.insight-item.negative { background: #fff1f2; border-color: #fecdd3; }

.insight-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 1px; }

.insight-text h4 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 3px;
}

.insight-item.positive .insight-text h4 { color: #15803d; }
.insight-item.neutral  .insight-text h4 { color: #92400e; }
.insight-item.negative .insight-text h4 { color: #b91c1c; }

.insight-text p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* =====================
   Comparison Bars
   ===================== */
.comparison-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.comp-item {
  display: grid;
  grid-template-columns: 100px 1fr 60px;
  align-items: center;
  gap: 12px;
}

.comp-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.comp-bar-wrap {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.comp-bar {
  height: 100%;
  border-radius: 4px;
}

.comp-bar.comp-your   { background: var(--primary); transition: width 0.5s ease; }
.comp-bar.comp-ref    { background: #9ca3af; }
.comp-bar.comp-warn   { background: #d97706; }
.comp-bar.comp-danger { background: #dc2626; }

.comp-value {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: right;
}

/* =====================
   Nutrition Table
   ===================== */
.nutrition-table {
  display: flex;
  flex-direction: column;
}

.nutrition-row {
  display: grid;
  grid-template-columns: 1fr 80px 90px;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.nutrition-row:last-child { border-bottom: none; }

.nut-name {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.nut-bar-wrap {
  height: 5px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
}

.nut-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
}

.nut-value {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
}

/* =====================
   Footer
   ===================== */
.footer {
  text-align: center;
  padding: 28px 20px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.8;
}

/* =====================
   Responsive
   ===================== */
@media (max-width: 900px) {
  .main-content {
    padding: 28px 0 56px;
  }

  .calculator-grid {
    grid-template-columns: 1fr;
  }

  .input-card {
    position: static;
  }
}

@media (max-width: 600px) {
  .main-content {
    padding: 20px 0 48px;
  }

  .page-title {
    margin-bottom: 22px;
  }

  .page-title h1 {
    font-size: 1.45rem;
  }

  .page-title p {
    font-size: 0.9rem;
    line-height: 1.6;
  }

  .card {
    padding: 20px;
  }

  .form-label {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .input-row {
    align-items: stretch;
  }

  .form-input {
    width: 100%;
    min-width: 0;
  }

  .input-unit {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
  }

  .calculate-btn {
    min-height: 46px;
  }

  .result-top {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .caffeine-number {
    font-size: 2.45rem;
  }

  .health-badge {
    max-width: 100%;
    white-space: normal;
  }

  .result-meta-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }

  .meta-value {
    font-size: 1.05rem;
  }

  .meta-label {
    font-size: 0.66rem;
    line-height: 1.35;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .comp-item {
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
  }

  .comp-bar-wrap {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .comp-value {
    text-align: right;
  }

  .nutrition-row {
    grid-template-columns: 1fr 72px;
    gap: 8px 12px;
  }

  .nut-bar-wrap {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .header {
    padding: 12px 16px;
  }
}

@media (max-width: 420px) {
  .card {
    padding: 18px;
  }

  .result-meta-row,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-card {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 12px;
    text-align: left;
  }

  .stat-icon {
    grid-row: span 3;
    margin-bottom: 0;
  }

  .limit-bar-label {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}
