/* Perfect Dose Calculator — Soft Blue Medical Palette */

/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --blue:       #4A90D9;
  --blue-dark:  #3B7EC4;
  --blue-light: #EBF4FF;
  --blue-muted: #A8C9F0;
  --success:    #059669;
  --danger:     #DC2626;
  --danger-bg:  #FEF2F2;
  --warning-bg: #FFFBEB;
  --warning-border: #FCD34D;
  --bg:         #EEF6FF;
  --card:       #FFFFFF;
  --text:       #1E3A5F;
  --text-muted: #6B8EB5;
  --border:     #C5D9EE;
  --shadow:     0 4px 24px rgba(74, 144, 217, 0.10);
  --radius-lg:  18px;
  --radius-md:  12px;
  --radius-sm:   8px;
}

/* ── Base ───────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  font-family: 'Figtree', sans-serif;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Wrapper ────────────────────────────────────────────────────────────── */
.calc-wrapper {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.calc-header {
  text-align: center;
  margin-bottom: 20px;
}
.calc-logo {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: -0.5px;
}
.calc-tagline {
  font-size: 13px;
  color: var(--text-muted);
  margin: 4px 0 0;
  font-weight: 500;
}

/* ── Card ──────────────────────────────────────────────────────────────── */
.calc-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 28px 24px 8px;
  box-shadow: var(--shadow);
  flex: 1;
  position: relative;
}

/* ── Step progress dots ─────────────────────────────────────────────────── */
.step-progress {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
}
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.3s;
}
.dot.active { background: var(--blue); }
.dot.done   { background: var(--blue-muted); }

/* ── Step ──────────────────────────────────────────────────────────────── */
.calc-step {
  display: none;
  padding-bottom: 4px;
}
.calc-step.active {
  display: block;
  animation: fadeUp 0.25s ease-out;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.step-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

/* ── Age mode toggle ───────────────────────────────────────────────────── */
.age-mode-toggle {
  display: flex;
  background: var(--blue-light);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 14px;
  gap: 4px;
}
.mode-btn {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  font-family: 'Figtree', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.mode-btn.active {
  background: var(--card);
  color: var(--blue);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.mode-btn:hover:not(.active) { color: var(--text); }

/* ── Inputs ─────────────────────────────────────────────────────────────── */
.age-input-wrap,
.weight-input-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
}
.age-input-wrap .calc-input,
.weight-input-wrap .calc-input { flex: 1; }

.calc-input {
  width: 100%;
  font-size: 26px;
  font-weight: 600;
  font-family: 'Figtree', sans-serif;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--blue-light);
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}
.calc-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(74, 144, 217, 0.12);
}
.calc-input::placeholder { font-weight: 400; color: var(--blue-muted); }
.calc-input.error { border-color: var(--danger); }

.input-suffix {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 52px;
}

/* ── Unit toggle (weight) ───────────────────────────────────────────────── */
.unit-toggle {
  display: flex;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  flex-shrink: 0;
}
.unit-btn {
  padding: 14px 14px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Figtree', sans-serif;
  border: none;
  background: var(--blue-light);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.unit-btn.active {
  background: var(--blue);
  color: white;
}
.unit-btn:hover:not(.active) { background: #D9E9F7; }

/* ── Warning / ineligible ──────────────────────────────────────────────── */
.calc-warning {
  font-size: 13px;
  color: #92400E;
  margin-top: 8px;
  font-weight: 500;
  background: var(--warning-bg);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}
.calc-ineligible {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-top: 12px;
  font-size: 14px;
  font-weight: 500;
  color: #92400E;
  line-height: 1.5;
}
.calc-ineligible svg { flex-shrink: 0; margin-top: 1px; color: #D97706; }

/* ── Option grid ────────────────────────────────────────────────────────── */
.option-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.option-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--blue-light);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
  font-family: 'Figtree', sans-serif;
  width: 100%;
}
.option-btn:hover {
  border-color: var(--blue);
  background: #DCF0FF;
}
.option-btn.selected {
  border-color: var(--blue);
  background: #DCF0FF;
  box-shadow: 0 0 0 1px var(--blue);
}
.option-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.option-radio {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  background: white;
  transition: border-color 0.15s, background 0.15s;
}
.option-btn.selected .option-radio {
  border-color: var(--blue);
  background: var(--blue);
}
.option-btn.selected .option-radio::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 8px; height: 8px;
  border-radius: 50%;
  background: white;
}
.option-content { flex: 1; }
.option-name { font-size: 15px; font-weight: 600; color: var(--text); }
.option-sub   { font-weight: 400; color: var(--text-muted); }
.option-desc  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.no-meds-msg  { font-size: 14px; color: var(--text-muted); text-align: center; padding: 24px; }

/* ── Disclaimer step ────────────────────────────────────────────────────── */
.disclaimer-box {
  background: var(--blue-light);
  border: 1.5px solid var(--blue-muted);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.disclaimer-text {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 0;
}
.disclaimer-text + .disclaimer-text { margin-top: 10px; }
.disclaimer-emergency {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--danger);
  font-weight: 600;
}
.disclaimer-emergency svg { flex-shrink: 0; margin-top: 1px; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  line-height: 1.5;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--blue-light);
  transition: border-color 0.2s, background 0.2s;
}
.checkbox-label:has(input:checked) {
  border-color: var(--blue);
  background: #DCF0FF;
}
.checkbox-label input[type="checkbox"] { display: none; }
.checkbox-custom {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  flex-shrink: 0;
  background: white;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}
.checkbox-label input:checked + .checkbox-custom {
  background: var(--blue);
  border-color: var(--blue);
}
.checkbox-label input:checked + .checkbox-custom::after {
  content: '';
  position: absolute;
  top: 4px; left: 7px;
  width: 5px; height: 9px;
  border: 2px solid white;
  border-top: none; border-left: none;
  transform: rotate(45deg);
}

/* ── Result step ────────────────────────────────────────────────────────── */
.result-card {
  background: linear-gradient(135deg, #4A90D9 0%, #6BA3E8 100%);
  border-radius: var(--radius-lg);
  padding: 28px 24px 24px;
  text-align: center;
  color: white;
  margin-bottom: 14px;
}
.result-meta {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.7;
  margin-bottom: 6px;
}
.result-med-name {
  font-size: 14px;
  font-weight: 600;
  opacity: 0.85;
  margin-bottom: 16px;
}
.result-dose {
  font-family: 'Fraunces', serif;
  font-size: 64px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -3px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.result-unit {
  font-size: 22px;
  font-weight: 500;
  opacity: 0.9;
  margin-top: 4px;
}
.result-form {
  font-size: 12px;
  opacity: 0.65;
  margin-top: 10px;
}

.result-warning {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #92400E;
  line-height: 1.5;
  margin-bottom: 12px;
}
.result-warning svg { flex-shrink: 0; margin-top: 1px; color: #D97706; }

.result-interval {
  font-size: 14px;
  color: var(--text);
  background: var(--blue-light);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  text-align: center;
  line-height: 1.6;
  margin-bottom: 14px;
}
.result-safety {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.btn-start-over {
  width: 100%;
  background: var(--blue-light);
  color: var(--blue);
  border: 2px solid var(--blue-muted);
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  font-family: 'Figtree', sans-serif;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-start-over:hover { background: #DCF0FF; border-color: var(--blue); }

/* ── Navigation ─────────────────────────────────────────────────────────── */
.calc-nav {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-bottom: 8px;
}
.btn {
  font-size: 15px;
  font-weight: 600;
  font-family: 'Figtree', sans-serif;
  padding: 14px 24px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--blue);
  color: white;
  flex: 1;
}
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); }
.btn-primary:disabled {
  background: var(--blue-muted);
  cursor: not-allowed;
  opacity: 0.7;
}

.btn-secondary {
  background: var(--blue-light);
  color: var(--text-muted);
  border: 2px solid var(--border);
}
.btn-secondary:hover { border-color: var(--blue); color: var(--blue); }

/* ── Physician bio ──────────────────────────────────────────────────────── */
.physician-bio {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin: 18px 0 0;
  padding: 16px 18px;
  background: var(--blue-light);
  border-radius: var(--radius-md);
  border: 1px solid var(--blue-muted);
}
.bio-avatar {
  width: 44px; height: 44px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid var(--blue-muted);
}
.bio-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  line-height: 1.5;
}
.bio-text strong { color: var(--blue-dark); }
.bio-text span   { color: var(--text-muted); }

/* ── Footer ─────────────────────────────────────────────────────────────── */
.calc-footer {
  margin-top: 16px;
  text-align: center;
}
.calc-footer p {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.7;
}
.calc-footer a {
  color: var(--text-muted);
  text-decoration: none;
}
.calc-footer a:hover { color: var(--blue); }

/* ── Full-screen warning overlay ───────────────────────────────────────── */
.warning-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(30, 58, 95, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.warning-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 36px 28px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0,0,0,0.25);
}
.warning-icon-wrap {
  width: 64px; height: 64px;
  background: var(--danger-bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}
.warning-title {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--danger);
  margin-bottom: 16px;
}
.warning-body {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 12px;
}
.warning-body:last-of-type { margin-bottom: 24px; }
.warning-card .btn-primary {
  width: 100%;
  background: var(--danger);
}
.warning-card .btn-primary:hover { background: #B91C1C; }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 420px) {
  .calc-wrapper { padding: 16px 12px 40px; }
  .calc-card { padding: 24px 18px 4px; }
  .result-dose { font-size: 52px; }
  .upgrade-plans { grid-template-columns: 1fr; }
  .upgrade-modal-card, .reminder-modal-card { padding: 28px 20px; }
}

/* ── Premium banner (free users) ─────────────────────────────────────── */
.premium-banner {
  background: linear-gradient(135deg, #1E3A5F 0%, #2D5A9E 100%);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 14px;
  animation: fadeUp 0.3s ease-out;
}
.banner-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  font-size: 13px;
  font-weight: 500;
}
.banner-star { flex-shrink: 0; }
.banner-btn {
  background: #F59E0B;
  color: #1E3A5F;
  border: none;
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 700;
  font-family: 'Figtree', sans-serif;
  cursor: pointer;
  margin-left: auto;
  flex-shrink: 0;
}
.banner-dismiss {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  padding: 2px;
  flex-shrink: 0;
}
.banner-dismiss:hover { color: white; }

/* ── Premium sidebar ─────────────────────────────────────────────────── */
.premium-sidebar {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-top: 14px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.25s ease-out;
}
.sidebar-section { margin-bottom: 20px; }
.sidebar-section:last-child { margin-bottom: 0; }
.sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.sidebar-btn {
  width: 100%;
  background: var(--blue-light);
  color: var(--blue);
  border: 2px solid var(--blue-muted);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Figtree', sans-serif;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.sidebar-btn:hover { background: #DCF0FF; border-color: var(--blue); }
.sidebar-link-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-family: 'Figtree', sans-serif;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.sidebar-link-btn:hover { color: var(--blue); }

/* History list */
.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-item {
  background: var(--blue-light);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background 0.15s;
}
.history-item:hover { background: #DCF0FF; }
.history-item .h-date { color: var(--text-muted); font-size: 11px; }
.history-item .h-dose { font-weight: 700; color: var(--blue); }
.history-empty { font-size: 13px; color: var(--text-muted); text-align: center; padding: 12px; }

/* Profiles list */
.profiles-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.profile-item {
  background: var(--blue-light);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background 0.15s;
  border: 1.5px solid transparent;
}
.profile-item:hover { background: #DCF0FF; border-color: var(--blue-muted); }
.profile-item.selected { border-color: var(--blue); background: #DCF0FF; }
.profile-item .p-name { font-weight: 600; color: var(--text); }
.profile-item .p-info { color: var(--text-muted); font-size: 11px; }
.profile-item .p-default-badge {
  background: var(--blue);
  color: white;
  border-radius: 20px;
  padding: 1px 8px;
  font-size: 10px;
  font-weight: 700;
}
.profiles-empty { font-size: 13px; color: var(--text-muted); text-align: center; padding: 12px; }

/* ── Generic modal overlay ───────────────────────────────────────────── */
.upgrade-modal {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(30, 58, 95, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  animation: fadeUp 0.25s ease-out;
}
.upgrade-modal-card,
.reminder-modal-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 36px 28px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 24px 80px rgba(0,0,0,0.25);
  position: relative;
}
.upgrade-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}
.upgrade-close:hover { color: var(--text); }
.upgrade-header { text-align: center; margin-bottom: 24px; }
.upgrade-crown {
  width: 56px; height: 56px;
  background: #FFFBEB;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
.upgrade-title {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.upgrade-subtitle { font-size: 14px; color: var(--text-muted); line-height: 1.6; }
.upgrade-plans { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.upgrade-plan {
  background: var(--blue-light);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 14px;
  text-align: center;
  position: relative;
  transition: border-color 0.2s;
}
.upgrade-plan:hover { border-color: var(--blue); }
.plan-featured { border-color: var(--blue); background: #DCF0FF; }
.plan-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--blue);
  color: white;
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 10px;
  font-weight: 700;
}
.plan-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 6px; }
.plan-price { font-size: 22px; font-weight: 700; color: var(--text); }
.plan-price span { font-size: 13px; font-weight: 500; }
.plan-desc { font-size: 11px; color: var(--text-muted); margin-top: 4px; line-height: 1.4; }
.plan-select-btn {
  display: block;
  margin-top: 12px;
  background: var(--blue);
  color: white;
  border-radius: var(--radius-sm);
  padding: 9px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  transition: background 0.15s;
}
.plan-select-btn:hover { background: var(--blue-dark); }
.plan-featured .plan-select-btn { background: var(--blue-dark); }
.plan-featured .plan-select-btn:hover { background: #2B5A8C; }
.upgrade-features { margin-bottom: 16px; }
.upgrade-feature { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text); padding: 6px 0; }
.check-icon { color: var(--success); font-weight: 700; font-size: 16px; }
.upgrade-trial-note { font-size: 11px; color: var(--text-muted); text-align: center; line-height: 1.6; }

/* Reminder modal */
.reminder-fields { margin-bottom: 16px; }
.reminder-field { margin-bottom: 14px; }
.sidebar-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.06em; }
.reminder-select {
  width: 100%;
  font-size: 15px;
  font-family: 'Figtree', sans-serif;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--blue-light);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
.reminder-select:focus { border-color: var(--blue); }
.reminder-offline-note { font-size: 12px; color: var(--text-muted); text-align: center; margin-top: 8px; font-style: italic; }