/* ============================================================
   Calorie Calculator — Glow UI Dark Theme
   ============================================================ */

/* --- CSS Variables (Dark Mode default) --- */
:root {
  --bg: #121212;
  --bg-card: #181818;
  --bg-hover: #282828;
  --border: #404040;
  --text-muted: #535353;
  --text-secondary: #B3B3B3;
  --text-primary: #FFFFFF;
  --green: #1DB954;
  --green-hover: #1ed760;
  --yellow: #F5C518;
  --red: #C0392B;
  --blue: #4C5CDB;
  --font: 'Inter', sans-serif;
  --radius: 8px;
  --radius-lg: 12px;
  --transition: all 0.2s ease-in-out;
}

[data-theme="light"] {
  --bg: #FFFFFF;
  --bg-card: #F5F5F5;
  --bg-hover: #E8E8E8;
  --border: #D0D0D0;
  --text-muted: #999999;
  --text-secondary: #666666;
  --text-primary: #121212;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

/* --- Global Header --- */
.global-header {
  background: rgba(18, 18, 18, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: 64px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

[data-theme="light"] .global-header {
  background: rgba(255, 255, 255, 0.92);
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 16px; }

.logo {
  color: var(--green);
  font-weight: 800;
  font-size: 20px;
  text-decoration: none;
  white-space: nowrap;
}

.breadcrumb {
  color: var(--text-secondary);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb a { color: var(--text-secondary); text-decoration: none; }
.breadcrumb a:hover { color: var(--text-primary); }
.breadcrumb-sep { color: var(--text-muted); }

.back-to-hub {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 9999px;
  transition: var(--transition);
}
.back-to-hub:hover { color: var(--text-primary); border-color: var(--text-secondary); }

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: var(--transition);
}
.theme-toggle:hover { border-color: var(--text-secondary); background: var(--bg-hover); }

/* --- App Layout (3-column) --- */
.app-layout {
  display: grid;
  grid-template-columns: 160px 1fr 160px;
  gap: 0;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 16px;
}

.sidebar {
  padding: 24px 8px;
  min-width: 0;
}

.main-content {
  min-width: 0;
  padding: 32px 24px;
}

/* --- Ad Slots --- */
.ad-slot {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
}

.ad-slot--sidebar { background: transparent; }
.ad-slot--inline { margin: 24px 0; border-radius: var(--radius); }
.ad-mobile-only { display: none; }

/* --- Hero --- */
.hero {
  margin-bottom: 28px;
}

.hero-title {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.2;
}

.hero-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 600px;
}

/* --- Calculator Card --- */
.calculator-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 32px;
}

/* Unit Toggle */
.unit-toggle {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 4px;
  width: fit-content;
  margin-bottom: 28px;
}

.unit-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: 9999px;
  cursor: pointer;
  transition: var(--transition);
}

.unit-btn--active {
  background: var(--green);
  color: #000;
}

.unit-btn:not(.unit-btn--active):hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* Input Grid */
.input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 24px;
  margin-bottom: 24px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-group--full { grid-column: 1 / -1; }
.input-group--hidden { display: none; }

.input-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
}
.input-wrapper:focus-within { border-color: var(--green); }

.input-wrapper--multi { gap: 0; }

.input-field {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 500;
  padding: 11px 14px;
  width: 100%;
  min-width: 0;
}

.input-field--small { flex: 0 0 60px; text-align: center; padding: 11px 8px; }
.input-field::placeholder { color: var(--text-muted); }

/* Remove number input spinners */
.input-field::-webkit-outer-spin-button,
.input-field::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input-field[type=number] { -moz-appearance: textfield; }

.input-unit {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0 14px 0 4px;
  white-space: nowrap;
}

/* Gender Toggle */
.gender-toggle {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  height: 44px;
}

.gender-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.gender-btn--active {
  background: var(--green);
  color: #000;
}

.gender-btn:not(.gender-btn--active):hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Select */
.select-field {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  padding: 11px 14px;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23B3B3B3' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
.select-field:focus { border-color: var(--green); }
.select-field option { background: #282828; color: var(--text-primary); }

/* Goal Selector */
.goal-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.goal-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
  font-family: var(--font);
}

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

.goal-btn--active {
  border-color: var(--green);
  background: rgba(29, 185, 84, 0.1);
  color: var(--text-primary);
}

.goal-icon { font-size: 22px; }
.goal-label { font-size: 13px; font-weight: 700; }
.goal-desc { font-size: 11px; color: var(--text-muted); }
.goal-btn--active .goal-desc { color: var(--green); }

/* Action Buttons */
.action-btns {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
}

.btn-primary {
  flex: 1;
  background: var(--green);
  color: #000;
  border: none;
  border-radius: 9999px;
  padding: 14px 32px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: var(--transition);
}
.btn-primary:hover { background: var(--green-hover); transform: scale(1.02); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 14px 24px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.btn-secondary:hover { border-color: var(--text-secondary); color: var(--text-primary); }

/* --- Results --- */
.results { border-top: 1px solid var(--border); padding-top: 24px; }

.results-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-primary);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
}

.stat-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

.stat-card--tdee .stat-value { color: var(--green); }
.stat-card--goal .stat-value { color: var(--yellow); }

/* Macro Section */
.macro-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.macro-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  align-items: start;
}

/* Chart */
.chart-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#macroChart { display: block; }

.chart-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  align-self: flex-start;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}
.legend-dot--protein { background: var(--green); }
.legend-dot--carbs { background: var(--yellow); }
.legend-dot--fat { background: var(--red); }

/* Macro Cards */
.macro-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.macro-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  border-left: 3px solid var(--border);
}

.macro-card--protein { border-left-color: var(--green); }
.macro-card--carbs { border-left-color: var(--yellow); }
.macro-card--fat { border-left-color: var(--red); }

.macro-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.macro-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.macro-pct {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.macro-grams {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
  display: block;
  margin-bottom: 8px;
}

.macro-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}

.macro-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}
.macro-bar-fill--protein { background: var(--green); }
.macro-bar-fill--carbs { background: var(--yellow); }
.macro-bar-fill--fat { background: var(--red); }

.macro-kcal {
  font-size: 12px;
  color: var(--text-secondary);
}

/* --- Educational Content --- */
.content-article {
  margin-bottom: 32px;
}

.content-section {
  margin-bottom: 32px;
}

.content-section h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.content-section p {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.75;
  margin-bottom: 12px;
}

.content-section p:last-child { margin-bottom: 0; }

.content-section strong { color: var(--text-primary); }

/* Formula Box */
.formula-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 16px 0;
}

.formula-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--green);
  margin-bottom: 10px !important;
}

.formula-text {
  font-size: 14px;
  font-family: 'Courier New', monospace;
  color: var(--text-primary) !important;
  line-height: 1.8 !important;
  margin-bottom: 4px !important;
}

/* Activity Table */
.activity-table {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 16px;
}

.activity-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  border-bottom: 1px solid var(--border);
}
.activity-row:last-child { border-bottom: none; }

.activity-cell {
  padding: 14px 16px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.activity-cell--label {
  background: var(--bg-card);
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.activity-multiplier {
  font-size: 12px;
  font-weight: 600;
  color: var(--green);
  font-family: monospace;
}

/* Macro Guide Grid */
.macro-guide-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.macro-guide-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  border-top: 3px solid var(--border);
}

.macro-guide-card--protein { border-top-color: var(--green); }
.macro-guide-card--carbs { border-top-color: var(--yellow); }
.macro-guide-card--fat { border-top-color: var(--red); }

.macro-guide-card h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.macro-guide-kcal {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  font-family: monospace;
}

.macro-guide-card p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* Tips List */
.tips-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
}

.tips-list li {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
  padding-left: 20px;
  position: relative;
}

.tips-list li::before {
  content: "→";
  position: absolute;
  left: 0;
  color: var(--green);
  font-weight: 700;
}

.tips-list strong { color: var(--text-primary); }

/* --- FAQ --- */
.faq-section { margin-bottom: 32px; }

.faq-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
  transition: var(--transition);
}

.faq-item[open] { border-color: var(--green); }

.faq-question {
  padding: 16px 20px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition);
  background: var(--bg-card);
}

.faq-question::-webkit-details-marker { display: none; }
.faq-question::after { content: "+"; color: var(--green); font-size: 20px; font-weight: 300; }
.faq-item[open] .faq-question::after { content: "−"; }

.faq-question:hover { background: var(--bg-hover); }

.faq-answer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.faq-answer p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.75;
}

.faq-answer strong { color: var(--text-primary); }

/* --- Cross-Links --- */
.cross-links {
  margin-bottom: 24px;
}

.cross-links h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.cross-links-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.cross-link-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: var(--transition);
}

.cross-link-card:hover {
  background: var(--bg-hover);
  border-color: var(--green);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.cross-link-icon { font-size: 24px; }
.cross-link-name { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.cross-link-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }

/* --- Global Footer --- */
.global-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 28px 32px;
  text-align: center;
  margin-top: 24px;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--text-secondary);
  font-size: 13px;
  text-decoration: none;
  transition: var(--transition);
}
.footer-links a:hover { color: var(--text-primary); }

.footer-copyright {
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================================
   Responsive — Tablet
   ============================================================ */
@media (max-width: 1100px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar { display: none; }
  .ad-mobile-only { display: block; }

  .main-content { padding: 24px 16px; }
}

@media (max-width: 768px) {
  .global-header { padding: 0 16px; height: 56px; }
  .breadcrumb { display: none; }

  .hero-title { font-size: 1.7rem; }

  .calculator-card { padding: 20px 16px; }

  .input-grid { grid-template-columns: 1fr; }
  .input-group--full { grid-column: 1; }

  .goal-selector { grid-template-columns: repeat(3, 1fr); }
  .goal-btn { padding: 12px 6px; }
  .goal-label { font-size: 11px; }

  .stats-grid { grid-template-columns: 1fr; gap: 10px; }
  .stat-value { font-size: 1.5rem; }

  .macro-layout { grid-template-columns: 1fr; }
  .chart-wrap { flex-direction: row; align-items: center; }
  .chart-legend { margin-left: 0; }
  #macroChart { width: 140px !important; height: 140px !important; }

  .activity-row { grid-template-columns: 1fr; }
  .activity-cell--label { border-bottom: 1px solid var(--border); }

  .macro-guide-grid { grid-template-columns: 1fr; }

  .cross-links-grid { grid-template-columns: 1fr; }

  .footer-links { gap: 16px; }
}

@media (max-width: 480px) {
  .goal-selector { grid-template-columns: 1fr; }
  .action-btns { flex-direction: column; }
  .btn-secondary { text-align: center; }
}
