/* =====================================================
   WiseRankers Health — Design System
   health.wiserankers.com
   ===================================================== */

/* ---- Variables ---- */
:root {
  --primary: #0EA5E9;
  --primary-dark: #0284C7;
  --secondary: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --purple: #8B5CF6;
  --bg: #F0F9FF;
  --card: #FFFFFF;
  --text: #1E293B;
  --text-muted: #64748B;
  --border: #E2E8F0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(14,165,233,0.10);
  --shadow-card: 0 4px 24px rgba(0,0,0,0.07);
  --transition: 0.2s ease;
  --max-width: 1200px;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: underline; }
img { max-width: 100%; }

/* ---- RTL Support ---- */
[dir="rtl"] { text-align: right; }
[dir="rtl"] .breadcrumb { direction: rtl; }
[dir="rtl"] .header-controls { flex-direction: row-reverse; }
[dir="rtl"] .unit-toggle { flex-direction: row-reverse; }

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

/* ---- Header ---- */
.site-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 20px;
  flex-wrap: wrap;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
}
.logo:hover { color: var(--primary-dark); text-decoration: none; }
.logo-icon { font-size: 1.4rem; }
.site-nav { display: flex; gap: 16px; align-items: center; }
.site-nav a { color: var(--text-muted); font-size: 0.9rem; font-weight: 500; }
.site-nav a:hover { color: var(--primary); text-decoration: none; }
.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  flex-wrap: wrap;
}

/* ---- Unit Toggle ---- */
.unit-toggle {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.unit-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: var(--transition);
  white-space: nowrap;
}
.unit-btn.active {
  background: var(--primary);
  color: #fff;
}
.unit-btn:hover:not(.active) { background: var(--border); }

/* ---- Language Select ---- */
.lang-select {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
  outline: none;
}
.lang-select:focus { border-color: var(--primary); }

/* ---- Breadcrumb ---- */
.breadcrumb {
  padding: 10px 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }

/* ---- AdSense Banner ---- */
.ad-banner { background: #fff; border-bottom: 1px solid var(--border); padding: 8px 0; min-height: 90px; }
.ad-banner .container { text-align: center; }
.ad-slot { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; min-height: 250px; text-align: center; }

/* ---- Main Grid ---- */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  padding: 24px 20px;
  align-items: start;
}
.calculator-area { display: flex; flex-direction: column; gap: 20px; }
.sidebar { display: flex; flex-direction: column; gap: 20px; position: sticky; top: 80px; }

/* ---- Cards ---- */
.calculator-card, .about-card, .related-card, .result-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 28px;
  border: 1px solid var(--border);
}

.calculator-card h1 {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}
.calc-desc {
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: 0.95rem;
}
.about-card h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}
.about-card p { color: var(--text-muted); margin-bottom: 12px; font-size: 0.93rem; }
.about-card table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 0.9rem; }
.about-card th { background: var(--bg); padding: 8px 12px; text-align: left; font-weight: 600; }
.about-card td { padding: 8px 12px; border-top: 1px solid var(--border); }
[dir="rtl"] .about-card th { text-align: right; }

/* ---- Form ---- */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.form-group input[type="number"],
.form-group input[type="date"],
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--text);
  background: #fff;
  transition: var(--transition);
  outline: none;
}
.form-group input:focus, .form-group select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14,165,233,0.12); }
.form-group .input-row { display: flex; gap: 8px; align-items: center; }
.form-group .input-row input { flex: 1; }
.form-group .input-row span { font-size: 0.88rem; color: var(--text-muted); white-space: nowrap; }

/* Radio group */
.radio-group { display: flex; gap: 12px; flex-wrap: wrap; }
.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.93rem;
  padding: 8px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  user-select: none;
}
.radio-label:has(input:checked) { border-color: var(--primary); background: #EFF9FF; color: var(--primary); }
.radio-label input[type="radio"] { accent-color: var(--primary); }

/* Form row (two inputs side by side) */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Hidden fields */
.metric-field.hidden, .imperial-field.hidden { display: none; }

/* Hint text */
.form-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

/* ---- Buttons ---- */
.btn-calc {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 32px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  margin-right: 12px;
  margin-top: 8px;
}
.btn-calc:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(14,165,233,0.3); }
.btn-reset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 8px;
}
.btn-reset:hover { border-color: var(--text-muted); color: var(--text); }
[dir="rtl"] .btn-calc { margin-right: 0; margin-left: 12px; }

/* ---- Result Card ---- */
.result-card {
  border: 2px solid var(--secondary);
  background: linear-gradient(135deg, #f0fdf4 0%, #fff 100%);
  padding: 24px;
  margin-top: 20px;
}
.result-card.hidden { display: none; }
.result-header { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.result-value {
  font-size: 3rem;
  font-weight: 900;
  color: var(--primary);
  line-height: 1.1;
}
.result-unit { font-size: 1.2rem; font-weight: 500; color: var(--text-muted); margin-left: 6px; }
.result-label {
  font-size: 1.1rem;
  font-weight: 700;
  margin-top: 4px;
  padding: 6px 16px;
  border-radius: 20px;
  display: inline-block;
}
.result-normal { background: #dcfce7; color: #16a34a; }
.result-warning { background: #fef3c7; color: #d97706; }
.result-danger { background: #fee2e2; color: #dc2626; }
.result-info { background: #dbeafe; color: #2563eb; }
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.result-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}
.result-item-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.result-item-value { font-size: 1.25rem; font-weight: 800; color: var(--primary); margin-top: 2px; }
.result-item-sub { font-size: 0.8rem; color: var(--text-muted); }

/* BMI Visual Scale */
.bmi-scale { margin-top: 16px; }
.scale-bar {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(to right, #3B82F6 0%, #22C55E 30%, #F59E0B 60%, #EF4444 85%, #7F1D1D 100%);
  position: relative;
}
.scale-indicator {
  position: absolute;
  top: -4px;
  width: 20px;
  height: 20px;
  background: #fff;
  border: 3px solid var(--text);
  border-radius: 50%;
  transform: translateX(-50%);
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  transition: left 0.4s ease;
}
.scale-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Heart Rate Zones */
.zones-table { width: 100%; margin-top: 12px; }
.zone-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}
.zone-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
}
.zone-bpm { font-size: 1rem; font-weight: 700; }
.zone-pct { font-size: 0.8rem; color: var(--text-muted); }

/* Error message */
.error-msg {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fca5a5;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-top: 12px;
  font-size: 0.9rem;
}

/* ---- Related Card ---- */
.related-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 12px; }
.related-card ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.related-card li a {
  display: block;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--text);
  border: 1px solid var(--border);
  transition: var(--transition);
}
.related-card li a:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; background: #EFF9FF; }

/* ---- Disclaimer ---- */
.disclaimer {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.82rem;
  color: #92400e;
  margin-top: 16px;
}

/* ---- Footer ---- */
.site-footer {
  background: #1E293B;
  color: #94a3b8;
  padding: 32px 0;
  margin-top: 48px;
  text-align: center;
}
.site-footer p { margin-bottom: 6px; font-size: 0.88rem; }
.site-footer a { color: #7dd3fc; }
.footer-links { display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; margin-bottom: 12px; }
.footer-links a { color: #94a3b8; font-size: 0.85rem; }
.footer-links a:hover { color: #fff; text-decoration: none; }

/* ---- Index Page — Calculator Grid ---- */
.index-hero {
  background: linear-gradient(135deg, #0EA5E9 0%, #0284C7 50%, #10B981 100%);
  color: #fff;
  padding: 60px 20px;
  text-align: center;
}
.index-hero h1 { font-size: 2.5rem; font-weight: 900; margin-bottom: 12px; }
.index-hero p { font-size: 1.1rem; opacity: 0.9; max-width: 600px; margin: 0 auto; }
.search-bar {
  display: flex;
  max-width: 500px;
  margin: 24px auto 0;
  gap: 0;
}
.search-bar input {
  flex: 1;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  font-size: 1rem;
  outline: none;
}
.search-bar button {
  padding: 14px 24px;
  background: #0c4a6e;
  color: #fff;
  border: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  cursor: pointer;
  font-weight: 700;
}
.calcs-section { padding: 40px 20px; }
.calcs-section h2 { font-size: 1.4rem; font-weight: 800; margin-bottom: 20px; color: var(--text); }
.calcs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.calc-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  gap: 14px;
  align-items: flex-start;
  transition: var(--transition);
  box-shadow: var(--shadow);
}
.calc-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(14,165,233,0.18);
  transform: translateY(-2px);
  text-decoration: none;
  color: var(--text);
}
.calc-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.calc-card-body h3 { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.calc-card-body p { font-size: 0.82rem; color: var(--text-muted); line-height: 1.4; }
.calc-category-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .main-grid { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .index-hero h1 { font-size: 1.8rem; }
}
@media (max-width: 600px) {
  .header-inner { padding: 10px 16px; gap: 12px; }
  .logo { font-size: 1rem; }
  .header-controls { width: 100%; justify-content: space-between; }
  .calculator-card, .about-card { padding: 20px 16px; }
  .calculator-card h1 { font-size: 1.4rem; }
  .result-value { font-size: 2.2rem; }
  .form-row { grid-template-columns: 1fr; }
  .calcs-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 420px) {
  .calcs-grid { grid-template-columns: 1fr; }
}

/* ---- Health Age specific ---- */
.score-bar-wrap { margin: 6px 0 16px; }
.score-bar-track { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: 4px; background: var(--secondary); transition: width 0.4s ease; }
.health-age-result {
  text-align: center;
  padding: 24px;
}
.health-age-number { font-size: 4rem; font-weight: 900; line-height: 1; }
.health-age-label { font-size: 1rem; color: var(--text-muted); margin-top: 4px; }
.health-age-delta { font-size: 1.1rem; font-weight: 700; margin-top: 8px; padding: 4px 16px; border-radius: 20px; display: inline-block; }

/* ---- Sleep circles ---- */
.sleep-times { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.sleep-time-pill {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
}
.sleep-time-pill .cycles { font-size: 0.72rem; color: var(--text-muted); display: block; }

/* ---- Fertile window calendar ---- */
.fertile-strip {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.fertile-day {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.fertile-day.peak { background: #fde68a; color: #92400e; border-color: #fbbf24; }
.fertile-day.fertile { background: #dcfce7; color: #16a34a; border-color: #86efac; }
.fertile-day.ovulation { background: #f0fdf4; border: 2px solid #22c55e; color: #15803d; font-weight: 800; }

/* ---- Questionnaire style (health-age, diabetes-risk, cardio-risk) ---- */
.question-group {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}
.question-group label.q-label {
  font-weight: 700;
  color: var(--text);
  font-size: 0.92rem;
  margin-bottom: 8px;
  display: block;
}
.question-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 0.93rem;
  color: var(--text);
  outline: none;
}
.question-group select:focus { border-color: var(--primary); }
