/* ═══════════════════════════════════════════════════════
   Bio Age Calculator — Premium Design System
   ═══════════════════════════════════════════════════════ */

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

:root {
  --font-sans: 'Inter', 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, sans-serif;
  
  /* Color palette — dark mode premium */
  --bg-body: #0a0e1a;
  --bg-card: rgba(18, 24, 42, 0.85);
  --bg-card-solid: #121a2e;
  --bg-input: rgba(255, 255, 255, 0.04);
  --bg-input-focus: rgba(255, 255, 255, 0.07);
  --bg-option: rgba(255, 255, 255, 0.03);
  --bg-option-hover: rgba(255, 255, 255, 0.06);
  --bg-option-selected: rgba(99, 147, 255, 0.12);
  --bg-secondary: rgba(255, 255, 255, 0.04);
  
  --border-default: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 147, 255, 0.5);
  --border-selected: rgba(99, 147, 255, 0.4);
  
  --text-primary: #e8ecf4;
  --text-secondary: #8b95a8;
  --text-tertiary: #5a6478;
  --text-muted: #3d4558;
  
  /* Accent colors */
  --accent-blue: #6393ff;
  --accent-blue-dim: rgba(99, 147, 255, 0.15);
  --accent-green: #34d399;
  --accent-green-dim: rgba(52, 211, 153, 0.12);
  --accent-amber: #f59e0b;
  --accent-amber-dim: rgba(245, 158, 11, 0.12);
  --accent-red: #f87171;
  --accent-red-dim: rgba(248, 113, 113, 0.12);
  --accent-purple: #a78bfa;
  --accent-purple-dim: rgba(167, 139, 250, 0.12);
  --accent-cyan: #22d3ee;
  --accent-cyan-dim: rgba(34, 211, 238, 0.12);
  
  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #6393ff 0%, #a78bfa 100%);
  --gradient-success: linear-gradient(135deg, #34d399 0%, #22d3ee 100%);
  --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #fb923c 100%);
  --gradient-danger: linear-gradient(135deg, #f87171 0%, #fb7185 100%);
  
  /* Sizing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 100px;
  
  /* Shadows */
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.05);
  --shadow-glow-blue: 0 0 30px rgba(99, 147, 255, 0.15);
  --shadow-glow-green: 0 0 30px rgba(52, 211, 153, 0.15);
  --shadow-button: 0 2px 12px rgba(99, 147, 255, 0.3);
  
  /* Transitions */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-body);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ── Animated Background ──────────────────────────────── */
.app-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.3;
  animation: float 20s ease-in-out infinite;
}

.bg-orb--1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(99, 147, 255, 0.4), transparent 70%);
  top: -10%;
  left: -10%;
  animation-delay: 0s;
}

.bg-orb--2 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(167, 139, 250, 0.35), transparent 70%);
  bottom: -5%;
  right: -5%;
  animation-delay: -7s;
  animation-duration: 25s;
}

.bg-orb--3 {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, rgba(52, 211, 153, 0.25), transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -14s;
  animation-duration: 30s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -30px) scale(1.05); }
  50% { transform: translate(-20px, 20px) scale(0.95); }
  75% { transform: translate(15px, 15px) scale(1.02); }
}

/* ── App Container ────────────────────────────────────── */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 540px;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
  min-height: 100vh;
}

/* ── Card / Glass Panel ───────────────────────────────── */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-card);
  padding: 2rem 1.5rem;
  animation: cardIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
  transform: translateY(20px);
}

@keyframes cardIn {
  to { opacity: 1; transform: translateY(0); }
}

/* ── Header ───────────────────────────────────────────── */
.header {
  text-align: center;
  margin-bottom: 2rem;
}

.header__logo-wrap {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  box-shadow: 0 4px 24px rgba(52, 211, 153, 0.25),
              0 0 0 3px rgba(52, 211, 153, 0.1);
  animation: logoPulse 3s ease-in-out infinite;
  overflow: hidden;
  padding: 4px;
}

.header__logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
}

@keyframes logoPulse {
  0%, 100% {
    box-shadow: 0 4px 24px rgba(52, 211, 153, 0.25),
                0 0 0 3px rgba(52, 211, 153, 0.1);
  }
  50% {
    box-shadow: 0 6px 32px rgba(52, 211, 153, 0.4),
                0 0 0 5px rgba(52, 211, 153, 0.15);
  }
}

.header__title {
  font-size: 1.35rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.25rem;
  letter-spacing: -0.02em;
}

.header__subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 400;
}

/* ── Progress Bar ─────────────────────────────────────── */
.progress {
  display: flex;
  gap: 8px;
  margin-bottom: 2rem;
}

.progress__item {
  flex: 1;
  text-align: center;
}

.progress__bar {
  height: 3px;
  border-radius: 2px;
  background: var(--border-default);
  margin-bottom: 6px;
  overflow: hidden;
  position: relative;
}

.progress__bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-primary);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 2px;
}

.progress__item--active .progress__bar::after,
.progress__item--done .progress__bar::after {
  transform: scaleX(1);
}

.progress__label {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 500;
  transition: color var(--transition-normal);
  letter-spacing: 0.01em;
}

.progress__item--active .progress__label {
  color: var(--accent-blue);
}

.progress__item--done .progress__label {
  color: var(--text-secondary);
}

/* ── Form Elements ────────────────────────────────────── */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.form-label__hint {
  font-weight: 400;
  color: var(--text-tertiary);
  font-size: 0.75rem;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  transition: all var(--transition-fast);
  outline: none;
}

.form-input:focus {
  background: var(--bg-input-focus);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 147, 255, 0.1);
}

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

.form-input--sm {
  width: 140px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ── BMI Badge ────────────────────────────────────────── */
.bmi-badge {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-default);
  transition: all var(--transition-normal);
}

.bmi-badge__icon {
  font-size: 22px;
  color: var(--accent-blue);
  opacity: 0.7;
}

.bmi-badge__value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.bmi-badge__label {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.bmi-badge__status {
  font-size: 0.72rem;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-weight: 500;
  margin-left: auto;
}

.bmi-badge__status--normal {
  background: var(--accent-green-dim);
  color: var(--accent-green);
}

.bmi-badge__status--underweight {
  background: var(--accent-amber-dim);
  color: var(--accent-amber);
}

.bmi-badge__status--overweight {
  background: var(--accent-amber-dim);
  color: var(--accent-amber);
}

.bmi-badge__status--obese {
  background: var(--accent-red-dim);
  color: var(--accent-red);
}

/* ── Option Buttons (Lifestyle) ───────────────────────── */
.question-block {
  margin-bottom: 1.5rem;
}

.question-block__header {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 0.75rem;
}

.question-block__icon {
  font-size: 18px;
  color: var(--accent-blue);
  opacity: 0.7;
}

.question-block__label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.option-btn {
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-option);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: var(--font-sans);
  text-align: left;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
  font-weight: 400;
}

.option-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.option-btn:hover {
  background: var(--bg-option-hover);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.option-btn--selected {
  background: var(--bg-option-selected);
  border-color: var(--border-selected);
  color: var(--accent-blue);
  font-weight: 500;
}

.option-btn--selected::before {
  opacity: 0.06;
}

.option-btn--selected:hover {
  background: var(--bg-option-selected);
  border-color: var(--border-selected);
}

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0.8rem 1.5rem;
  border-radius: var(--radius-md);
  border: none;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

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

.btn--primary:hover {
  box-shadow: 0 4px 20px rgba(99, 147, 255, 0.45);
  transform: translateY(-1px);
}

.btn--primary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-button);
}

.btn--ghost {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

.btn--ghost:hover {
  background: var(--bg-option-hover);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.12);
}

.btn--full {
  width: 100%;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 1.5rem;
}

.btn-row .btn--ghost { flex: 1; }
.btn-row .btn--primary { flex: 2; }

/* ── Info Box ─────────────────────────────────────────── */
.info-box {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  background: var(--accent-blue-dim);
  border: 1px solid rgba(99, 147, 255, 0.15);
  margin-bottom: 1.5rem;
}

.info-box__icon {
  font-size: 18px;
  color: var(--accent-blue);
  flex-shrink: 0;
  margin-top: 2px;
}

.info-box__text {
  font-size: 0.78rem;
  color: rgba(99, 147, 255, 0.85);
  line-height: 1.7;
}

/* ── Biomarker Input ──────────────────────────────────── */
.bio-input-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.bio-input-note {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════
   RESULTS PAGE
   ══════════════════════════════════════════════════════════ */

/* ── Age Comparison ───────────────────────────────────── */
.result-hero {
  text-align: center;
  margin-bottom: 2rem;
  padding: 1.5rem 0;
}

.age-comparison {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  margin-bottom: 1.5rem;
}

.age-block {
  text-align: center;
}

.age-block__label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.age-block__value {
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}

.age-block__value--chronological {
  color: var(--text-tertiary);
}

.age-block__value--biological {
  /* color set dynamically */
}

.age-arrow {
  font-size: 28px;
  color: var(--text-muted);
  animation: arrowPulse 2s ease-in-out infinite;
}

@keyframes arrowPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

/* ── Status Badge ─────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.5rem 1.5rem;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 600;
  animation: badgeIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s both;
}

@keyframes badgeIn {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

/* ── Age Bar / Scale ──────────────────────────────────── */
.age-scale {
  margin-bottom: 2rem;
  animation: fadeIn 0.5s 0.4s both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.age-bar {
  position: relative;
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  margin-bottom: 10px;
  overflow: visible;
}

.age-bar__segment {
  position: absolute;
  height: 100%;
  opacity: 0.4;
}

.age-bar__segment--young {
  left: 0;
  width: 33%;
  background: linear-gradient(90deg, #34d399, #22d3ee);
  border-radius: 4px 0 0 4px;
}

.age-bar__segment--normal {
  left: 33%;
  width: 34%;
  background: linear-gradient(90deg, #6393ff, #a78bfa);
}

.age-bar__segment--old {
  left: 67%;
  width: 33%;
  background: linear-gradient(90deg, #f59e0b, #f87171);
  border-radius: 0 4px 4px 0;
}

.age-bar__dot {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid var(--bg-card-solid);
  box-sizing: border-box;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 12px rgba(0,0,0,0.3);
  transition: left 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 2;
}

.age-bar__dot::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: inherit;
  opacity: 0.2;
  animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { transform: scale(1); opacity: 0.2; }
  50% { transform: scale(1.3); opacity: 0.1; }
}

.age-scale__labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* ── Recommendations ──────────────────────────────────── */
.recs {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1.5rem;
  animation: fadeInUp 0.5s 0.5s both;
}

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

.recs__header {
  background: rgba(255, 255, 255, 0.03);
  padding: 0.75rem 1.15rem;
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  gap: 8px;
}

.recs__header-icon {
  font-size: 16px;
  color: var(--accent-purple);
}

.recs__title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.rec-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--border-default);
  transition: background var(--transition-fast);
}

.rec-item:last-child {
  border-bottom: none;
}

.rec-item:hover {
  background: rgba(255, 255, 255, 0.02);
}

.rec-item__icon {
  font-size: 20px;
  color: var(--accent-blue);
  flex-shrink: 0;
  margin-top: 1px;
  opacity: 0.7;
}

.rec-item__text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ── Disclaimer ───────────────────────────────────────── */
.disclaimer {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 1.5rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  animation: fadeIn 0.5s 0.6s both;
}

.disclaimer i {
  font-size: 14px;
  vertical-align: -2px;
  margin-right: 4px;
  color: var(--accent-amber);
  opacity: 0.6;
}

/* ── Gauge / Circular Visualization ───────────────────── */
.gauge-container {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto 1.5rem;
}

.gauge-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 8;
}

.gauge-fill {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 1.2s cubic-bezier(0.16, 1, 0.3, 1),
              stroke 0.5s ease;
}

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.gauge-center__value {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}

.gauge-center__label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 4px;
}

/* ── Animations Utility ───────────────────────────────── */
.anim-stagger > * {
  animation: fadeInUp 0.4s both;
}

.anim-stagger > *:nth-child(1) { animation-delay: 0.05s; }
.anim-stagger > *:nth-child(2) { animation-delay: 0.1s; }
.anim-stagger > *:nth-child(3) { animation-delay: 0.15s; }
.anim-stagger > *:nth-child(4) { animation-delay: 0.2s; }
.anim-stagger > *:nth-child(5) { animation-delay: 0.25s; }
.anim-stagger > *:nth-child(6) { animation-delay: 0.3s; }
.anim-stagger > *:nth-child(7) { animation-delay: 0.35s; }
.anim-stagger > *:nth-child(8) { animation-delay: 0.4s; }

/* ── Number Animation ─────────────────────────────────── */
.num-animate {
  display: inline-block;
  animation: numPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes numPop {
  from { opacity: 0; transform: scale(0.5) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 480px) {
  .app-container {
    padding: 1rem 0.75rem 2rem;
  }
  
  .card {
    padding: 1.5rem 1.15rem;
    border-radius: var(--radius-lg);
  }

  .header__title {
    font-size: 1.2rem;
  }

  .age-block__value {
    font-size: 2.8rem;
  }

  .age-comparison {
    gap: 1.5rem;
  }

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

  .gauge-container {
    width: 170px;
    height: 170px;
  }
}

/* ── Scrollbar ────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ── Selection ────────────────────────────────────────── */
::selection {
  background: rgba(99, 147, 255, 0.3);
  color: #fff;
}

/* ── Input number spin buttons ────────────────────────── */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* ── Particles ────────────────────────────────────────── */
.particle {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  width: 4px;
  height: 4px;
  background: var(--accent-blue);
  border-radius: 50%;
  opacity: 0;
  animation: particleFade 4s ease-out forwards;
}

@keyframes particleFade {
  0% { opacity: 0; transform: translateY(0) scale(0); }
  10% { opacity: 0.6; transform: translateY(-10px) scale(1); }
  100% { opacity: 0; transform: translateY(-80px) scale(0.3); }
}
