/* ============================================================
   BMI Calculator - style.css
   Glow UI Design System (Spotify-based dark theme)
   ============================================================ */

/* --- CSS Variables --- */
: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;

  /* BMI gauge colors */
  --underweight: #4C9BE8;
  --normal: #1DB954;
  --overweight: #F5C518;
  --obese: #E74C3C;
}

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

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

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  transition: background 0.2s, color 0.2s;
  min-height: 100vh;
}

a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-hover); }

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

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

.header-left {
  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);
}

.breadcrumb a:hover {
  color: var(--text-primary);
}

.breadcrumb-sep {
  color: var(--text-muted);
}

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

.back-btn {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 9999px;
  transition: all 0.2s;
  white-space: nowrap;
}

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

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 9999px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s;
}

.theme-toggle:hover {
  border-color: var(--text-secondary);
}

/* --- App Layout --- */
.app-layout {
  display: grid;
  grid-template-columns: 160px 1fr 160px;
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 16px;
  align-items: start;
}

/* --- Sidebars --- */
.sidebar {
  position: sticky;
  top: 88px;
}

/* --- Main Content --- */
.main-content {
  min-width: 0;
}

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

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

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

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

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

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

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

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

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

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

.input-group--hidden {
  display: none;
}

.input-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.optional-label {
  font-weight: 400;
  color: var(--text-muted);
}

.input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.input-wrap:focus-within {
  border-color: var(--green);
}

.input-field {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  padding: 12px 14px;
  font-size: 16px;
  font-family: 'Inter', sans-serif;
  color: var(--text-primary);
  width: 100%;
}

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

/* Remove number 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 {
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  border-left: 1px solid var(--border);
}

/* Imperial height */
.height-imperial-wrap {
  display: flex;
  gap: 8px;
}

.height-imperial-wrap .input-wrap {
  flex: 1;
}

/* Gender group */
.gender-group {
  display: flex;
  gap: 8px;
}

.gender-btn {
  flex: 1;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

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

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

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

.btn-calculate {
  flex: 1;
  padding: 14px;
  background: var(--green);
  color: #000;
  border: none;
  border-radius: 9999px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.03em;
}

.btn-calculate:hover {
  background: var(--green-hover);
  transform: scale(1.02);
}

.btn-calculate:active {
  transform: scale(0.98);
}

.btn-reset {
  padding: 14px 24px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 9999px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

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

/* --- Results Panel --- */
.results-panel {
  border-top: 1px solid var(--border);
  padding-top: 24px;
  animation: fadeIn 0.3s ease;
}

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

.bmi-display {
  text-align: center;
  margin-bottom: 24px;
}

.bmi-value {
  font-size: 4rem;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 8px;
  transition: color 0.3s;
}

.bmi-category {
  font-size: 1.25rem;
  font-weight: 700;
  padding: 6px 20px;
  border-radius: 9999px;
  display: inline-block;
  transition: background 0.3s, color 0.3s;
}

/* Category color states */
.state--underweight .bmi-value { color: var(--underweight); }
.state--underweight .bmi-category { background: rgba(76,155,232,0.15); color: var(--underweight); }

.state--normal .bmi-value { color: var(--normal); }
.state--normal .bmi-category { background: rgba(29,185,84,0.15); color: var(--normal); }

.state--overweight .bmi-value { color: var(--overweight); }
.state--overweight .bmi-category { background: rgba(245,197,24,0.15); color: var(--overweight); }

.state--obese .bmi-value { color: var(--obese); }
.state--obese .bmi-category { background: rgba(231,76,60,0.15); color: var(--obese); }

/* --- BMI Gauge --- */
.gauge-container {
  position: relative;
  margin-bottom: 20px;
  padding-bottom: 24px;
}

.gauge-track {
  display: flex;
  height: 16px;
  border-radius: 8px;
  overflow: hidden;
}

.gauge-segment {
  font-size: 0; /* hide text, for accessibility only */
  flex-shrink: 0;
}

.gauge-seg--underweight { flex: 2.5; background: var(--underweight); }
.gauge-seg--normal { flex: 6.5; background: var(--normal); }
.gauge-seg--overweight { flex: 5; background: var(--overweight); }
.gauge-seg--obese { flex: 10; background: var(--obese); }

.gauge-marker {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: left 0.5s cubic-bezier(0.34,1.56,0.64,1);
}

.gauge-marker-dot {
  width: 20px;
  height: 20px;
  background: #fff;
  border: 3px solid #121212;
  border-radius: 50%;
  margin-top: -2px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.gauge-marker-line {
  width: 2px;
  height: 0;
  background: transparent;
}

.gauge-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  padding: 0 2px;
}

/* Healthy weight box */
.healthy-weight-box {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.healthy-weight-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.healthy-weight-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--green);
}

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

.ad-slot--mobile-inline {
  display: none;
  margin: 16px 0;
}

.ad-slot--article {
  margin: 32px 0;
}

.ad-slot--bottom {
  margin-top: 32px;
}

/* --- Content Sections --- */
.content-sections {
  margin-top: 8px;
}

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

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

.content-section h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 20px 0 8px;
}

.content-section p {
  color: var(--text-secondary);
  margin-bottom: 14px;
  font-size: 0.95rem;
}

.content-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.content-list li {
  color: var(--text-secondary);
  padding-left: 20px;
  position: relative;
  font-size: 0.95rem;
}

.content-list li::before {
  content: '•';
  color: var(--green);
  position: absolute;
  left: 4px;
  font-weight: 700;
}

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

/* Formula Box */
.formula-box {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  border-radius: 6px;
  padding: 16px 20px;
  margin: 16px 0;
  font-size: 1rem;
  color: var(--text-primary);
}

.formula-note {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 6px;
  display: inline-block;
}

/* BMI Table */
.table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.bmi-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.bmi-table th {
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 16px;
  text-align: left;
}

.bmi-table td {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: top;
}

.bmi-table tr:hover td {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Row color accents */
.row--underweight td:first-child { color: var(--underweight); font-weight: 600; }
.row--normal td:first-child { color: var(--normal); font-weight: 600; }
.row--overweight td:first-child { color: var(--overweight); font-weight: 600; }
.row--obese1 td:first-child,
.row--obese2 td:first-child,
.row--obese3 td:first-child { color: var(--obese); font-weight: 600; }

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

.faq-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}

.faq-item:hover {
  border-color: var(--text-muted);
}

.faq-q {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.faq-a {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0;
}

/* --- Cross-Links --- */
.cross-links {
  padding: 40px 0;
  border-top: 1px solid var(--border);
}

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

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

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

.cross-card:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
  transform: translateY(-2px);
}

.cross-icon {
  font-size: 1.5rem;
}

.cross-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}

.cross-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* --- Global Footer --- */
.global-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 32px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

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

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--text-primary);
}

.footer-copyright {
  color: var(--text-muted);
}

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

  .sidebar {
    display: none;
  }

  .ad-slot--mobile-inline {
    display: flex;
  }
}

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

  .breadcrumb {
    display: none;
  }

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

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

  .action-row {
    flex-direction: column;
  }

  .btn-reset {
    width: 100%;
    text-align: center;
  }

  .bmi-value {
    font-size: 3rem;
  }

  .calculator-card {
    padding: 20px;
  }

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