/* =====================================================
   HEALTHGROWTH — Calculator Page Styles
   ===================================================== */

/* ---- Calculator Page Layout ---- */
.calc-page-hero {
  background: var(--gradient-hero);
  padding: 3rem 0 2rem;
  position: relative;
  overflow: hidden;
}
.calc-page-hero::before {
  content: '';
  position: absolute;
  top: -30%; right: -10%;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(14,165,233,0.2) 0%, transparent 70%);
  pointer-events: none;
}
.calc-hero-inner {
  position: relative; z-index: 1;
  max-width: 700px;
}
.calc-hero-icon {
  width: 72px; height: 72px;
  border-radius: var(--radius-xl);
  background: var(--color-bg-secondary);
  backdrop-filter: blur(8px);
  border: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.25rem;
  margin-bottom: 1.25rem;
}
.calc-hero-title {
  font-size: clamp(1.75rem, 3.5vw, 2.75rem);
  font-weight: 800;
  color: var(--color-text-primary);
  margin-bottom: 0.875rem;
  letter-spacing: -0.02em;
}
.calc-hero-desc {
  font-size: var(--text-lg);
  color: var(--color-text-secondary);
  line-height: 1.7;
  max-width: 560px;
  margin: 0;
}

/* ---- Calculator Main Layout ---- */
.calc-main {
  padding: 1.5rem 0 5rem;
}
.calc-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 2.5rem;
  align-items: start;
}
.calc-content { min-width: 0; }
.calc-sidebar { position: sticky; top: calc(var(--header-height) + 1.5rem); }

/* ---- Calculator Widget ---- */
.calc-widget {
  background: var(--gradient-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.calc-widget-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  display: flex; align-items: center; gap: 1rem;
}
.calc-widget-header-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-lg);
  background: var(--gradient-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-primary);
}
.calc-widget-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text-primary);
}
.calc-widget-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0;
}
.calc-widget-body { padding: 2rem; }
.calc-widget-footer {
  padding: 1.25rem 2rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
}

/* ---- Result Display ---- */
.result-display {
  margin-top: 1.5rem;
  display: none;
  animation: fadeInUp 0.4s ease both;
}
.result-display.visible { display: block; }
.result-card {
  background: var(--gradient-primary);
  border-radius: var(--radius-xl);
  padding: 2rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.result-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.15) 0%, transparent 60%);
}
.result-card-content { position: relative; z-index: 1; }
.result-primary-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: rgba(255,255,255,0.8);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}
.result-primary-value {
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 900;
  color: #fff;
  line-height: 1;
  letter-spacing: -0.03em;
  margin-bottom: 0.375rem;
}
.result-primary-unit {
  font-size: var(--text-xl);
  font-weight: 500;
  color: rgba(255,255,255,0.8);
  margin-left: 0.25rem;
}
.result-interpretation {
  display: inline-block;
  margin-top: 0.875rem;
  padding: 0.375rem 1rem;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.2);
  font-size: var(--text-sm);
  font-weight: 600;
  color: #fff;
}

/* Breakdowns / Details */
.result-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-top: 1.25rem;
}
.result-breakdown-item {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  text-align: center;
}
.result-breakdown-value {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text-primary);
  display: block;
}
.result-breakdown-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

/* BMI / Scale Gauge */
.bmi-gauge-wrap { margin-top: 1.25rem; }
.bmi-gauge-bar {
  height: 12px;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, #3b82f6 0%, #10b981 25%, #f59e0b 60%, #ef4444 100%);
  position: relative;
  margin-bottom: 0.5rem;
}
.bmi-gauge-indicator {
  position: absolute;
  top: -6px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--color-text-primary);
  transform: translateX(-50%);
  box-shadow: var(--shadow-md);
  transition: left 0.6s cubic-bezier(0.34,1.56,0.64,1);
}
.bmi-gauge-labels {
  display: flex; justify-content: space-between;
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

/* Info Box in Results */
.result-info {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 1.25rem 1.5rem;
  margin-top: 1rem;
}
.result-info-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-border-light);
  font-size: var(--text-sm);
}
.result-info-row:last-child { border-bottom: none; padding-bottom: 0; }
.result-info-label { color: var(--color-text-muted); font-weight: 500; }
.result-info-value { color: var(--color-text-primary); font-weight: 600; }

/* Risk Level Indicator */
.risk-meter {
  margin-top: 1.5rem;
}
.risk-meter-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 0.5rem;
}
.risk-segments {
  display: flex; gap: 3px; height: 10px; border-radius: var(--radius-full); overflow: hidden;
}
.risk-segment {
  flex: 1; border-radius: 0;
  opacity: 0.3;
  transition: opacity var(--transition-base);
}
.risk-segment.active { opacity: 1; }
.risk-segment-low { background: #10b981; }
.risk-segment-moderate { background: #f59e0b; }
.risk-segment-high { background: #ef4444; }
.risk-segment-very-high { background: #7c2d12; }
.risk-labels {
  display: flex; justify-content: space-between;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  margin-top: 0.375rem;
}

/* Date Picker for pregnancy/date calcs */
.date-input-group {
  display: grid;
  grid-template-columns: 2fr 1fr 1.5fr;
  gap: 0.5rem;
}

/* ---- Macro Chart ---- */
.macro-chart {
  display: flex;
  height: 20px;
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: 1rem 0;
  gap: 2px;
}
.macro-segment {
  height: 100%;
  border-radius: 0;
  transition: flex var(--transition-slow);
}
.macro-protein { background: #3b82f6; }
.macro-carbs   { background: #f59e0b; }
.macro-fat     { background: #ef4444; }
.macro-legend {
  display: flex; gap: 1.25rem; flex-wrap: wrap;
  font-size: var(--text-sm);
}
.macro-legend-item {
  display: flex; align-items: center; gap: 0.375rem;
  color: var(--color-text-secondary);
  font-weight: 500;
}
.macro-dot { width: 10px; height: 10px; border-radius: 50%; }

/* ---- Sidebar Related Calculators ---- */
.related-calcs { }
.related-calcs-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text-primary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 1rem;
}
.related-calc-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  text-decoration: none;
  color: inherit;
  transition: all var(--transition-fast);
  margin-bottom: 0.625rem;
}
.related-calc-item:hover { border-color: var(--color-primary); background: var(--color-primary-light); color: inherit; transform: translateX(4px); }
.related-calc-icon { font-size: 1.25rem; flex-shrink: 0; }
.related-calc-name { font-size: var(--text-sm); font-weight: 600; color: var(--color-text-primary); }
.related-calc-cat { font-size: var(--text-xs); color: var(--color-text-muted); }

/* ---- Info Card Sidebar ---- */
.info-card {
  background: var(--color-primary-light);
  border: 1px solid rgba(14,165,233,0.2);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  margin-top: 1.5rem;
}
.info-card-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.75rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.info-card ul {
  padding-left: 1.25rem;
  margin: 0;
}
.info-card ul li {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: 0.4rem;
  line-height: 1.5;
}

/* ---- Article Section ---- */
.article-section {
  margin-top: 3rem;
}
.article-header {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 2rem;
}
.article-header-line {
  flex: 1;
  height: 2px;
  background: var(--gradient-primary);
  border-radius: 1px;
}
.article-header-text {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  white-space: nowrap;
}
.article-content {
  background: var(--gradient-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2xl);
  overflow: hidden;
}
.article-nav {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.article-nav::-webkit-scrollbar { display: none; }
.article-nav-tab {
  padding: 1rem 1.5rem;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  border: none;
  background: transparent;
  font-family: var(--font-family);
}
.article-nav-tab:hover { color: var(--color-primary); }
.article-nav-tab.active {
  color: var(--color-primary);
  border-bottom: 2px solid var(--color-primary);
  background: var(--color-primary-light);
}
.article-panel { padding: 2.5rem; display: none; }
.article-panel.active { display: block; animation: fadeIn 0.3s ease; }
.article-panel h2 {
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--color-text-primary);
}
.article-panel h3 {
  font-size: var(--text-xl);
  font-weight: 600;
  margin: 2rem 0 0.875rem;
  color: var(--color-text-primary);
}
.article-panel p {
  font-size: var(--text-base);
  line-height: 1.85;
  color: var(--color-text-secondary);
  margin-bottom: 1.25rem;
}
.article-panel ul, .article-panel ol {
  margin: 1rem 0;
  padding-left: 1.75rem;
}
.article-panel li {
  font-size: var(--text-base);
  color: var(--color-text-secondary);
  line-height: 1.7;
  margin-bottom: 0.5rem;
}
.formula-box {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin: 1.25rem 0;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
}
.formula-box strong { color: var(--color-primary); }
.formula-example {
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-lg);
  padding: 1rem 1.5rem;
  margin-top: 0.75rem;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
}

/* Benefit Cards in Article */
.benefit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.benefit-card {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  display: flex; align-items: flex-start; gap: 0.875rem;
  transition: transform var(--transition-fast);
}
.benefit-card:hover { transform: translateY(-3px); }
.benefit-card-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-lg);
  background: var(--gradient-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-primary);
}
.benefit-card-text h4 {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 0.25rem;
}
.benefit-card-text p {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.5;
}

/* Warning / Tip Box */
.article-tip {
  background: rgba(16,185,129,0.08);
  border: 1px solid rgba(16,185,129,0.2);
  border-left: 4px solid #10b981;
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  display: flex; align-items: flex-start; gap: 0.75rem;
}
.article-tip-icon { font-size: 1.25rem; flex-shrink: 0; }
.article-tip-text { font-size: var(--text-sm); color: var(--color-text-secondary); line-height: 1.65; margin: 0; }
.article-warning {
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.2);
  border-left: 4px solid #f59e0b;
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  display: flex; align-items: flex-start; gap: 0.75rem;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}
.article-warning-icon { font-size: 1.25rem; flex-shrink: 0; }

/* Ranges Table in Article */
.range-table { width: 100%; margin: 1.25rem 0; }
.range-row {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-lg);
  margin-bottom: 0.375rem;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
}
.range-color-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.range-label { font-size: var(--text-sm); font-weight: 600; color: var(--color-text-primary); flex: 1; }
.range-value { font-size: var(--text-sm); color: var(--color-text-muted); font-family: var(--font-mono); }

/* ---- Category Page ---- */
.category-hero {
  background: var(--gradient-hero);
  padding: 4rem 0 3rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.category-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center top, rgba(14,165,233,0.2) 0%, transparent 60%);
  pointer-events: none;
}
.category-hero-content { position: relative; z-index: 1; }
.category-hero-icon {
  width: 80px; height: 80px;
  margin: 0 auto 1.5rem;
  border-radius: var(--radius-2xl);
  background: var(--color-bg-secondary);
  backdrop-filter: blur(8px);
  border: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem;
}
.category-hero-title {
  font-size: clamp(1.875rem, 4vw, 3rem);
  font-weight: 800;
  color: var(--color-text-primary);
  margin-bottom: 1rem;
}
.category-hero-desc {
  font-size: var(--text-xl);
  color: var(--color-text-secondary);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.7;
}

.category-grid-section { padding: 4rem 0 5rem; }
.calc-count-badge {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.375rem 1rem;
  border-radius: var(--radius-full);
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: 2rem;
}

/* ---- Responsive Overrides for Calculator Pages ---- */

/* Tablet: collapse sidebar below main content */
@media (max-width: 1024px) {
  .calc-layout {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  .calc-sidebar { position: static; }
}

/* =====================================================
   MOBILE — Full Responsive Fix (max-width: 768px)
   Desktop styles are NOT changed here.
   ===================================================== */
@media (max-width: 768px) {

  /* --- Calculator Page Hero --- */
  .calc-page-hero {
    padding: 1.75rem 0 1.25rem;
  }
  .calc-hero-icon {
    width: 52px;
    height: 52px;
    font-size: 1.625rem;
    margin-bottom: 0.875rem;
  }
  .calc-hero-title {
    font-size: clamp(1.4rem, 6vw, 1.875rem);
    margin-bottom: 0.625rem;
  }
  .calc-hero-desc {
    font-size: 0.9375rem;
    line-height: 1.65;
  }

  /* --- Calculator Main Layout --- */
  .calc-main { padding: 1rem 0 3rem; }
  .calc-layout {
    grid-template-columns: 1fr !important;
    gap: 1.5rem;
  }
  .calc-sidebar {
    position: static !important;
    /* Hide categories sidebar on mobile to reduce clutter */
  }
  /* Hide the full categories sidebar in the calc page on mobile */
  .category-sidebar-in-calc { display: none; }

  /* --- Calculator Widget --- */
  .calc-widget {
    border-radius: var(--radius-xl);
  }
  .calc-widget-header {
    padding: 1rem 1.25rem;
    gap: 0.75rem;
  }
  .calc-widget-header-icon {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
  .calc-widget-title { font-size: 1rem; }
  .calc-widget-subtitle { font-size: 0.8125rem; }
  .calc-widget-body { padding: 1.125rem; }
  .calc-widget-footer { padding: 1rem 1.125rem; }

  /* --- Form elements inside widget --- */
  .form-group { margin-bottom: 1rem; }
  .form-row {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }
  .form-control {
    padding: 0.6875rem 0.875rem;
    font-size: 1rem; /* Prevents iOS zoom on focus */
  }
  .form-control-with-unit input {
    padding: 0.6875rem 0.875rem;
    font-size: 1rem;
  }
  .form-unit {
    padding: 0 0.75rem;
    font-size: 0.8125rem;
  }
  .form-label { font-size: 0.875rem; }

  /* Unit toggle: make text smaller so it fits on narrow screens */
  .unit-toggle button {
    font-size: 0.8125rem;
    padding: 0.3125rem 0.625rem;
  }

  /* Calculate & Reset buttons row */
  .calc-widget-body form > div[style*="display:flex"] {
    flex-direction: column;
    gap: 0.5rem !important;
  }

  /* --- Result Display --- */
  .result-card { padding: 1.25rem; }
  .result-primary-value {
    font-size: clamp(2rem, 10vw, 2.75rem);
  }
  .result-breakdown {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
  .result-breakdown-item { padding: 0.75rem; }
  .result-breakdown-value { font-size: 1.125rem; }
  .result-info { padding: 1rem; }
  .result-info-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    padding: 0.625rem 0;
  }
  .result-info-value { font-size: 0.9375rem; }

  /* --- Date input group --- */
  .date-input-group {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem;
  }
  .date-input-group > *:first-child {
    grid-column: 1 / -1; /* Month spans full width */
  }

  /* --- Article Section --- */
  .article-section { margin-top: 1.5rem; }
  .article-content { border-radius: var(--radius-xl); }
  .article-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .article-nav::-webkit-scrollbar { display: none; }
  .article-nav-tab {
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    flex-shrink: 0; /* Prevent tabs from wrapping/squishing */
  }
  .article-panel {
    padding: 1.125rem;
  }
  .article-panel h2 { font-size: 1.25rem; }
  .article-panel h3 { font-size: 1.0625rem; }
  .article-panel p  { font-size: 0.9375rem; line-height: 1.75; }
  .article-panel li { font-size: 0.9375rem; }

  /* Formula boxes */
  .formula-box {
    padding: 1rem;
    font-size: 0.8125rem;
    overflow-x: auto;
  }
  .formula-example { padding: 0.75rem 1rem; font-size: 0.8125rem; }

  /* Benefit cards */
  .benefit-grid { grid-template-columns: 1fr !important; }
  .benefit-card { padding: 1rem; }

  /* Range table */
  .range-row { padding: 0.625rem 0.75rem; gap: 0.625rem; }
  .range-label { font-size: 0.8125rem; }
  .range-value { font-size: 0.8125rem; }

  /* --- Sidebar related calcs (keep, just stack below) --- */
  .related-calc-item { padding: 0.75rem; }
  .related-calc-name { font-size: 0.8125rem; }

  /* --- Info card --- */
  .info-card { padding: 1rem; }
  .info-card ul li { font-size: 0.875rem; }

  /* --- Category Hero (for category index pages) --- */
  .category-hero { padding: 2.5rem 0 2rem; }
  .category-hero-icon {
    width: 60px; height: 60px;
    font-size: 1.875rem;
    margin-bottom: 1rem;
  }
  .category-hero-title { font-size: clamp(1.5rem, 6vw, 2rem); }
  .category-hero-desc { font-size: 1rem; }
  .category-grid-section { padding: 2rem 0 3rem; }

  /* --- Breadcrumb wrapping --- */
  .breadcrumb { font-size: 0.8125rem; gap: 0.375rem; margin-bottom: 1rem; }
}

/* Extra small (< 480px) */
@media (max-width: 480px) {
  .calc-widget-body { padding: 1rem; }
  .calc-widget-header { padding: 0.875rem 1rem; }
  .article-panel { padding: 1rem; }
  .result-breakdown {
    grid-template-columns: 1fr 1fr;
    gap: 0.375rem;
  }
  .result-breakdown-item { padding: 0.625rem 0.5rem; }
  .result-breakdown-value { font-size: 1rem; }
  /* Single-column breakdown for very narrow phones */
  .result-breakdown.breakdown-narrow { grid-template-columns: 1fr; }
  .unit-toggle button {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }
}

/* Responsive borders for legal pages */
.legal-bordered-content {
  border-right: 1px solid #e2e8f0;
  padding-right: 2.5rem;
}
@media (max-width: 1024px) {
  .legal-bordered-content {
    border-right: none;
    padding-right: 0;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 2.5rem;
    margin-bottom: 1rem;
  }
}
