/* ============================================================
   BMI Calculator — Design System & Styles
   ============================================================ */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap');

/* ============================================================
   CSS Custom Properties (Design Tokens)
   ============================================================ */
:root {
  /* Colors */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-gradient: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  --success: #16a34a;
  --success-light: #f0fdf4;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --info: #0891b2;
  --info-light: #ecfeff;

  /* Text */
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;

  /* Surfaces */
  --bg: #f9fafb;
  --bg-alt: #f3f4f6;
  --white: #ffffff;
  --card-nested-bg: var(--bg-alt);
  --border: #e5e7eb;
  --border-focus: #2563eb;

  /* Effects */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1), 0 10px 10px rgba(0, 0, 0, 0.04);

  /* Spacing & Sizing */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: all 0.15s ease;
  --transition: all 0.2s ease;
  --transition-slow: all 0.3s ease;

  /* Layout */
  --max-width: 960px;
  --header-height: 64px;
}

/* ============================================================
   Dark Theme (Slate Colors)
   ============================================================ */
[data-theme="dark"] {
  --bg: #0f172a;
  --bg-alt: #1e293b;
  --white: #1e293b;
  --card-nested-bg: var(--bg);
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --border: #334155;
  --border-focus: #3b82f6;

  --primary-light: rgba(37, 99, 235, 0.2);
  --success-light: rgba(22, 163, 74, 0.2);
  --warning-light: rgba(217, 119, 6, 0.2);
  --danger-light: rgba(220, 38, 38, 0.2);
  --info-light: rgba(8, 145, 178, 0.2);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 400;
  color: var(--text-secondary);
  background-color: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Skip to content (accessibility) */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 1000;
  padding: 8px 16px;
  background: var(--primary);
  color: #ffffff;
  border-radius: var(--radius-sm);
  font-weight: 700;
  text-decoration: none;
  transition: var(--transition-fast);
}

.skip-link:focus {
  top: 8px;
  color: #ffffff;
  text-decoration: none;
}

/* ============================================================
   Typography
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.3;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }

p {
  margin-bottom: 1rem;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition-fast);
}

a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* ============================================================
   Layout
   ============================================================ */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
}

main {
  flex: 1;
  padding: 32px 0;
}

/* ============================================================
   Header
   ============================================================ */
.header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: var(--header-height);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  gap: 12px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 800;
  font-size: 1.125rem;
  white-space: nowrap;
  flex-shrink: 0;
}

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

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.header-nav::-webkit-scrollbar {
  display: none;
}

.nav-link {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.875rem;
  white-space: nowrap;
  transition: var(--transition-fast);
  text-decoration: none;
}

.nav-link:hover {
  color: var(--primary);
  background: var(--primary-light);
  text-decoration: none;
}

.nav-link.active {
  color: #ffffff;
  background: var(--primary);
  font-weight: 700;
}

.nav-link.active:hover {
  color: #ffffff;
  background: var(--primary);
  text-decoration: none;
}

/* Theme Switcher Toggle */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition-fast);
  outline: none;
  padding: 0;
  flex-shrink: 0;
}

.theme-toggle-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  transform: rotate(15deg);
}

.theme-toggle-btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Mobile nav toggle */
.mobile-nav-toggle {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 1.25rem;
}

@media (max-width: 940px) {
  .header-inner {
    height: var(--header-height);
    padding-top: 0;
    padding-bottom: 0;
  }

  .mobile-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--white);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1.125rem;
    transition: var(--transition-fast);
    outline: none;
    padding: 0;
    flex-shrink: 0;
  }

  .mobile-nav-toggle:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
  }

  .header-nav {
    display: none;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 16px;
    gap: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 200;
  }

  .header-nav.open {
    display: flex;
    animation: slideDown 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .nav-link {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    text-align: left;
  }

  [dir="rtl"] .nav-link {
    text-align: right;
  }
}

@media (max-width: 480px) {
  .header-logo span:not(.logo-icon) {
    font-size: 0;
  }
  .header-logo span:not(.logo-icon)::before {
    content: "BMI";
    font-size: 1.125rem;
    font-weight: 800;
  }

  .lang-label {
    display: none;
  }

  .header-inner {
    padding: 0 8px;
    gap: 8px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .header-controls {
    gap: 4px;
  }

  .unit-toggle-btn {
    padding: 5px 8px;
    font-size: 0.7rem;
  }

  .theme-toggle-btn {
    width: 32px;
    height: 32px;
    font-size: 0.875rem;
  }

  .lang-btn {
    padding: 5px 8px;
  }
}

/* ============================================================
   Unit Toggle (Metric / Imperial)
   ============================================================ */
.unit-toggle {
  display: flex;
  background: var(--bg-alt);
  border-radius: var(--radius-full);
  padding: 3px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.unit-toggle-btn {
  padding: 5px 12px;
  border: none;
  background: transparent;
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.unit-toggle-btn.active {
  background: var(--white);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

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

/* ============================================================
   Language Switcher
   ============================================================ */
.lang-switcher {
  position: relative;
  flex-shrink: 0;
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.lang-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.lang-btn .globe-icon {
  font-size: 0.875rem;
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  list-style: none;
  min-width: 150px;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: var(--transition-fast);
  overflow: hidden;
}

.lang-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.lang-dropdown li {
  padding: 10px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.lang-dropdown li:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.lang-dropdown li.active {
  color: var(--primary);
  background: var(--primary-light);
}

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

.card-elevated {
  box-shadow: var(--shadow-md);
}

.card-header {
  margin-bottom: 20px;
}

.card-header h1,
.card-header h2 {
  margin-bottom: 4px;
}

.card-header p {
  color: var(--text-muted);
  font-size: 0.9375rem;
  margin-bottom: 0;
}

/* ============================================================
   Forms & Inputs
   ============================================================ */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.form-input,
.form-select {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--white);
  transition: var(--transition-fast);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.form-input:invalid:not(:placeholder-shown) {
  border-color: var(--danger);
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

/* Input with unit suffix */
.input-with-unit {
  position: relative;
}

.input-with-unit .form-input {
  padding-right: 60px;
}

.input-unit {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-muted);
  pointer-events: none;
}

/* Height imperial (two fields) */
.height-imperial {
  display: none;
  gap: 12px;
}

.height-imperial.visible {
  display: flex;
}

.height-metric {
  display: block;
}

.height-metric.hidden {
  display: none;
}

/* Inline form groups */
.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

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

.gender-option {
  flex: 1;
}

.gender-option input[type="radio"] {
  display: none;
}

.gender-option label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: center;
}

.gender-option input[type="radio"]:checked + label {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.gender-option label:hover {
  border-color: var(--primary);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  text-decoration: none;
}

.btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.4);
}

.btn-primary {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: var(--shadow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  opacity: 0.95;
  color: #ffffff;
  text-decoration: none;
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-block {
  width: 100%;
}

.btn-lg {
  height: 56px;
  font-size: 1.125rem;
  border-radius: var(--radius);
}

.btn-sm {
  height: 38px;
  padding: 0 12px;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}

.btn-outline:hover {
  background: var(--primary-light);
}

/* ============================================================
   Result Display
   ============================================================ */
.result-section {
  display: none;
  animation: slideDown 0.4s ease;
}

.result-section.visible {
  display: block;
}

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

.result-number {
  font-size: 3rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 8px;
}

.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 700;
}

.result-badge--info {
  background: var(--info-light);
  color: var(--info);
}

.result-badge--success {
  background: var(--success-light);
  color: var(--success);
}

.result-badge--warning {
  background: var(--warning-light);
  color: var(--warning);
}

.result-badge--danger {
  background: var(--danger-light);
  color: var(--danger);
}

.result-description {
  margin-top: 12px;
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.result-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 16px;
  font-weight: 700;
  font-size: 0.9375rem;
}

/* ============================================================
   Progress / Scale Bar
   ============================================================ */
.bmi-scale {
  margin: 20px 0;
}

.bmi-scale-bar {
  position: relative;
  height: 12px;
  border-radius: var(--radius-full);
  background: linear-gradient(
    to right,
    var(--info) 0%,
    var(--info) 18.5%,
    var(--success) 18.5%,
    var(--success) 50%,
    var(--warning) 50%,
    var(--warning) 75%,
    var(--danger) 75%,
    var(--danger) 100%
  );
  overflow: visible;
}

.bmi-scale-marker {
  position: absolute;
  top: -6px;
  width: 24px;
  height: 24px;
  background: #ffffff;
  border: 3px solid var(--text-primary);
  border-radius: 50%;
  transform: translateX(-50%);
  transition: left 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow);
}

.bmi-scale-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* ============================================================
   Result Table
   ============================================================ */
.result-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.9375rem;
}

.result-table th,
.result-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.result-table th {
  font-weight: 700;
  color: var(--text-primary);
  background: var(--bg-alt);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.result-table td {
  color: var(--text-secondary);
  font-weight: 600;
}

.result-table tr:last-child td {
  border-bottom: none;
}

.result-table tr:hover td {
  background: var(--bg);
}

/* Highlight row */
.result-table tr.highlight td {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}

/* BMI chart table (static page) */
.bmi-chart-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  overflow-x: auto;
  display: block;
}

.bmi-chart-table th,
.bmi-chart-table td {
  padding: 8px 10px;
  text-align: center;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.bmi-chart-table th {
  background: var(--bg-alt);
  font-weight: 700;
  color: var(--text-primary);
  position: sticky;
  top: 0;
}

.bmi-chart-table td.underweight { background: var(--info-light); color: var(--info); font-weight: 700; }
.bmi-chart-table td.normal { background: var(--success-light); color: var(--success); font-weight: 700; }
.bmi-chart-table td.overweight { background: var(--warning-light); color: var(--warning); font-weight: 700; }
.bmi-chart-table td.obese { background: var(--danger-light); color: var(--danger); font-weight: 700; }

/* ============================================================
   Categories Legend
   ============================================================ */
.categories-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.category-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 700;
}

.category-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* ============================================================
   Ad Slots
   ============================================================ */
.ad-slot {
  display: none !important; /* Temporarily hidden until Google AdSense approval */
  justify-content: center;
  align-items: center;
  margin: 24px auto;
  max-width: 100%;
  overflow: hidden;
  min-height: 50px;
}

.ad-slot--top {
  margin-top: 16px;
}

.ad-slot--middle {
  margin: 24px auto;
}

.ad-slot--bottom {
  margin-bottom: 16px;
}

/* Placeholder for development */
.ad-placeholder {
  background: var(--bg-alt);
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
}

/* ============================================================
   Footer
   ============================================================ */
.footer {
  background: var(--white);
  border-top: 1px solid var(--border);
  padding: 32px 0;
  margin-top: auto;
}

.footer-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
  text-align: center;
}

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

.footer-links a {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  transition: var(--transition-fast);
}

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

.footer-disclaimer {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  line-height: 1.5;
}

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

/* ============================================================
   Page-Specific: Section Spacing
   ============================================================ */
.page-header {
  text-align: center;
  margin-bottom: 32px;
}

.page-header h1 {
  margin-bottom: 8px;
}

.page-header p {
  color: var(--text-muted);
  font-size: 1.0625rem;
  max-width: 500px;
  margin: 0 auto;
}

.section-title {
  margin-bottom: 16px;
  font-size: 1.25rem;
}

/* Spacer between cards */
.card + .card {
  margin-top: 20px;
}

/* ============================================================
   Content (About page, etc.)
   ============================================================ */
.content-section {
  margin-bottom: 24px;
}

.content-section h2 {
  margin-bottom: 12px;
}

.content-section h3 {
  margin-bottom: 8px;
  font-size: 1.125rem;
}

.content-section ul {
  padding-left: 20px;
  margin-bottom: 12px;
}

.content-section li {
  margin-bottom: 6px;
  line-height: 1.6;
}

/* ============================================================
   404 Page
   ============================================================ */
.error-page {
  text-align: center;
  padding: 60px 20px;
}

.error-page .error-code {
  font-size: 6rem;
  font-weight: 800;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 16px;
}

.error-page h1 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.error-page p {
  color: var(--text-muted);
  margin-bottom: 24px;
}

.error-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

/* ============================================================
   Utility Classes
   ============================================================ */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-0 { margin-top: 0; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.hidden { display: none !important; }

/* ============================================================
   Animations
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.animate-fade-in {
  animation: fadeIn 0.4s ease;
}

.animate-pulse {
  animation: pulse 0.3s ease;
}

/* ============================================================
   RTL Support (Arabic)
   ============================================================ */
[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

[dir="rtl"] .header-inner {
  flex-direction: row-reverse;
}

[dir="rtl"] .header-nav {
  flex-direction: row-reverse;
}

[dir="rtl"] .header-controls {
  flex-direction: row-reverse;
}

[dir="rtl"] .lang-dropdown {
  right: auto;
  left: 0;
}

[dir="rtl"] .form-select {
  background-position: left 12px center;
  padding-right: 16px;
  padding-left: 40px;
}

[dir="rtl"] .input-unit {
  right: auto;
  left: 16px;
}

[dir="rtl"] .input-with-unit .form-input {
  padding-right: 16px;
  padding-left: 60px;
}

[dir="rtl"] .result-table th,
[dir="rtl"] .result-table td {
  text-align: right;
}

[dir="rtl"] .footer-links {
  flex-direction: row-reverse;
}

/* Progress bars always stay LTR */
[dir="rtl"] .bmi-scale-bar {
  direction: ltr;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }

  .container {
    padding: 0 12px;
  }

  main {
    padding: 20px 0;
  }

  .card {
    padding: 20px 16px;
    border-radius: var(--radius-sm);
  }

  .result-number {
    font-size: 2.5rem;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .gender-group {
    gap: 8px;
  }

  .bmi-scale-labels {
    font-size: 0.6875rem;
  }

  .btn-lg {
    height: 52px;
    font-size: 1rem;
  }

  .error-page .error-code {
    font-size: 4rem;
  }
}

@media (min-width: 769px) {
  .container {
    padding: 0 24px;
  }
}

/* ============================================================
   Print Styles
   ============================================================ */
@media print {
  .header,
  .footer,
  .ad-slot,
  .unit-toggle,
  .lang-switcher,
  .skip-link {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}

/* ============================================================
   Cookie Consent Banner
   ============================================================ */
.cookie-consent-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.05);
  padding: 16px 24px;
  z-index: 1000;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cookie-consent-banner--visible {
  transform: translateY(0);
}

.cookie-consent-content {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.cookie-consent-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0;
  line-height: 1.5;
}

.cookie-consent-btn {
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .cookie-consent-content {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    gap: 12px;
  }
}

/* ============================================================
   Educational Guide & CTA Card Grid
   ============================================================ */
.content-section {
  margin-top: 32px;
  padding: 32px;
}

.content-block {
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 24px;
}

.content-block:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.subsection-title {
  font-size: 1.25rem;
  margin-bottom: 12px;
  color: var(--text-primary);
}

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

.categories-list li {
  padding-left: 16px;
  border-left: 3px solid var(--primary-hover);
}

[dir="rtl"] .categories-list li {
  padding-left: 0;
  padding-right: 16px;
  border-left: none;
  border-right: 3px solid var(--primary-hover);
}

.category-list-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.cta-section {
  margin-top: 32px;
}

.cta-section-desc {
  margin-bottom: 24px;
}

.cta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.cta-card {
  background: var(--card-nested-bg, var(--bg-alt));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

.cta-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.cta-card-title {
  font-size: 1rem;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.cta-card-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  flex: 1; /* push button to bottom */
}

@media (max-width: 768px) {
  .content-section {
    padding: 20px;
  }
  .cta-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* ============================================================
   Cookie Consent Banner Actions & Links
   ============================================================ */
.cookie-consent-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.cookie-consent-link {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  text-decoration: underline;
  font-weight: 500;
}

.cookie-consent-link:hover {
  color: var(--primary);
}

@media (max-width: 600px) {
  .cookie-consent-actions {
    justify-content: center;
    width: 100%;
  }
}
