/* =====================================================
   FloHealth – Main Stylesheet (Mobile-First)
   ===================================================== */

/* ── Variables ── */
:root {
  --primary:         #E91E8C;
  --primary-light:   #F48FB1;
  --primary-dark:    #C2185B;
  --secondary:       #9C27B0;
  --period-color:    #FF6B8A;
  --fertile-color:   #4CAF50;
  --fertile-light:   #A5D6A7;
  --ovulation-color: #2196F3;
  --warning:         #FF9800;

  --bg:          #FFF5F8;
  --card-bg:     #FFFFFF;
  --text:        #2D2D2D;
  --text-light:  #666666;
  --text-muted:  #AAAAAA;
  --border:      #F0E0E8;

  --shadow:    0 2px 16px rgba(233,30,140,0.10);
  --shadow-sm: 0 1px 6px rgba(0,0,0,0.06);
  --radius:    18px;
  --radius-sm: 10px;

  --nav-height:    64px;
  --header-height: 56px;
}

/* ── Theme: Xanh cốm (Matcha) ── */
[data-theme="green"] {
  --primary:         #5D8A35;
  --primary-light:   #96C267;
  --primary-dark:    #3E6620;
  --secondary:       #3A7D55;
  --period-color:    #78A84A;
  --fertile-color:   #2E7D5A;
  --fertile-light:   #B8DDB0;
  --ovulation-color: #00897B;
  --bg:              #F3FAF0;
  --border:          #D3EAC8;
  --shadow:          0 2px 16px rgba(93,138,53,0.12);
}

/* ── Theme: Vàng (Golden) ── */
[data-theme="yellow"] {
  --primary:         #D4860E;
  --primary-light:   #F5C35A;
  --primary-dark:    #A86000;
  --secondary:       #C2690A;
  --period-color:    #F0A500;
  --fertile-color:   #6B9E3F;
  --fertile-light:   #C8E6A0;
  --ovulation-color: #1E88E5;
  --bg:              #FFFBEE;
  --border:          #F0E2B8;
  --shadow:          0 2px 16px rgba(212,134,14,0.12);
}

/* ── Theme Switcher Widget ── */
.theme-switcher-btn {
  width: 34px; height: 34px;
  border: none; background: var(--bg);
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; transition: background 0.2s;
  flex-shrink: 0;
}
.theme-switcher-btn:hover { background: var(--border); }

.theme-panel {
  position: fixed;
  top: calc(var(--header-height) + 6px);
  right: max(12px, calc(50vw - 228px));
  background: white;
  border-radius: 16px;
  box-shadow: 0 6px 28px rgba(0,0,0,0.14);
  padding: 14px 16px;
  z-index: 500;
  min-width: 190px;
  display: none;
  border: 1px solid var(--border);
}
.theme-panel.open { display: block; }
.theme-panel-title {
  font-size: 0.72rem; font-weight: 800;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.8px; margin-bottom: 12px;
}
.theme-options {
  display: flex; gap: 10px; justify-content: center;
}
.theme-opt {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; cursor: pointer; padding: 6px;
  border-radius: 10px; transition: background 0.15s;
  border: 2px solid transparent;
  flex: 1;
}
.theme-opt:hover  { background: #F5F5F5; }
.theme-opt.active { border-color: var(--primary); background: var(--bg); }
.theme-swatch {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid rgba(0,0,0,0.08);
}
.theme-opt-label {
  font-size: 0.68rem; font-weight: 800;
  color: var(--text-muted); text-align: center; line-height: 1.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;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: var(--nav-height);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

/* ── Sunflower Background Pattern ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.13;
  background-image:
    url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='110' height='110' viewBox='0 0 110 110'><g transform='translate(55,55)'><ellipse cx='0' cy='-27' rx='7' ry='14' fill='%23FFC107' transform='rotate(0)'/><ellipse cx='0' cy='-27' rx='7' ry='14' fill='%23FFC107' transform='rotate(30)'/><ellipse cx='0' cy='-27' rx='7' ry='14' fill='%23FFC107' transform='rotate(60)'/><ellipse cx='0' cy='-27' rx='7' ry='14' fill='%23FFC107' transform='rotate(90)'/><ellipse cx='0' cy='-27' rx='7' ry='14' fill='%23FFC107' transform='rotate(120)'/><ellipse cx='0' cy='-27' rx='7' ry='14' fill='%23FFC107' transform='rotate(150)'/><ellipse cx='0' cy='-27' rx='7' ry='14' fill='%23FFC107' transform='rotate(180)'/><ellipse cx='0' cy='-27' rx='7' ry='14' fill='%23FFC107' transform='rotate(210)'/><ellipse cx='0' cy='-27' rx='7' ry='14' fill='%23FFC107' transform='rotate(240)'/><ellipse cx='0' cy='-27' rx='7' ry='14' fill='%23FFC107' transform='rotate(270)'/><ellipse cx='0' cy='-27' rx='7' ry='14' fill='%23FFC107' transform='rotate(300)'/><ellipse cx='0' cy='-27' rx='7' ry='14' fill='%23FFC107' transform='rotate(330)'/><circle cx='0' cy='0' r='16' fill='%235D4037'/><circle cx='0' cy='0' r='11' fill='%234E342E' opacity='0.6'/></g></svg>"),
    url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'><g transform='translate(30,30)'><ellipse cx='0' cy='-14' rx='4' ry='7' fill='%23FFB300' transform='rotate(0)'/><ellipse cx='0' cy='-14' rx='4' ry='7' fill='%23FFB300' transform='rotate(45)'/><ellipse cx='0' cy='-14' rx='4' ry='7' fill='%23FFB300' transform='rotate(90)'/><ellipse cx='0' cy='-14' rx='4' ry='7' fill='%23FFB300' transform='rotate(135)'/><ellipse cx='0' cy='-14' rx='4' ry='7' fill='%23FFB300' transform='rotate(180)'/><ellipse cx='0' cy='-14' rx='4' ry='7' fill='%23FFB300' transform='rotate(225)'/><ellipse cx='0' cy='-14' rx='4' ry='7' fill='%23FFB300' transform='rotate(270)'/><ellipse cx='0' cy='-14' rx='4' ry='7' fill='%23FFB300' transform='rotate(315)'/><circle cx='0' cy='0' r='8' fill='%234E342E'/></g></svg>");
  background-size: 160px 160px, 90px 90px;
  background-position: 0 0, 80px 80px;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
input, textarea, select { font-family: inherit; }
img { max-width: 100%; }

/* ── App Shell ── */
.app-container {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  background: var(--bg);
}

/* ── App Header ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
}
.app-logo {
  font-size: 1.25rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.header-action {
  width: 36px; height: 36px;
  border: none; background: var(--bg);
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-light); font-size: 1rem;
  transition: background 0.2s;
}
.header-action:hover { background: var(--border); }

/* ── Bottom Navigation ── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 480px;
  height: var(--nav-height);
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center; justify-content: space-around;
  z-index: 1000;
  box-shadow: 0 -4px 24px rgba(233,30,140,0.08);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-item {
  display: flex; flex-direction: column;
  align-items: center; gap: 3px;
  color: var(--text-muted);
  font-size: 0.65rem; font-weight: 700;
  padding: 6px 18px;
  border-radius: 12px;
  transition: all 0.2s;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.nav-item i { font-size: 1.25rem; transition: transform 0.2s; }
.nav-item.active { color: var(--primary); }
.nav-item.active i { transform: scale(1.1); }

/* ── Page Content ── */
.page-content {
  padding: 16px 16px 24px;
}

/* ── Cards ── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 7px;
}
.card-title i { color: var(--primary); font-size: 0.9rem; }

/* ─────────────────────────────────────────────────────────
   HOME PAGE – Status Circle
   ───────────────────────────────────────────────────────── */
.status-section {
  display: flex; flex-direction: column; align-items: center;
  padding: 28px 16px 24px;
  background: linear-gradient(160deg, #FFF0F7 0%, #F5EEFF 100%);
  border-radius: var(--radius);
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.circle-wrapper {
  position: relative;
  width: 200px; height: 200px;
  margin-bottom: 16px;
}
.circle-svg { width: 200px; height: 200px; transform: rotate(-90deg); }
.circle-bg-track  { fill: none; stroke: #EEE0F0; stroke-width: 12; }
.circle-progress  { fill: none; stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset 1s ease; }

.circle-inner {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center; width: 140px;
}
.circle-day-num {
  font-size: 3.2rem; font-weight: 900; line-height: 1;
}
.circle-day-sub {
  font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; font-weight: 600;
}
.circle-status-label {
  font-size: 0.95rem; font-weight: 800; color: var(--text);
  margin-top: 0; display: inline-block;
  background: white; padding: 4px 14px;
  border-radius: 20px; box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.circle-sub {
  font-size: 0.85rem; color: var(--text-light); margin-top: 6px;
  font-weight: 600;
}

/* Quick stats under circle */
.quick-stats {
  display: grid; grid-template-columns: repeat(2,1fr);
  gap: 10px; width: 100%; margin-top: 6px;
}
.qs-item {
  background: white; border-radius: var(--radius-sm);
  padding: 12px 10px; text-align: center;
  box-shadow: var(--shadow-sm);
}
.qs-val  { font-size: 1.1rem; font-weight: 800; color: var(--primary); }
.qs-label{ font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; font-weight: 600; }

/* ── Notification Banners ── */
.notif-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  margin-bottom: 8px; font-size: 0.875rem; font-weight: 700;
}
.notif-banner.period   { background: #FFEBEF; color: #B71C1C; border-left: 4px solid var(--period-color); }
.notif-banner.fertile  { background: #E8F5E9; color: #1B5E20; border-left: 4px solid var(--fertile-color); }
.notif-banner.water    { background: #E3F2FD; color: #0D47A1; border-left: 4px solid #2196F3; }
.notif-banner.medicine { background: #F3E5F5; color: #4A148C; border-left: 4px solid var(--secondary); }
.notif-banner i { font-size: 1.1rem; flex-shrink: 0; }

/* ── Log today CTA ── */
.log-cta {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--card-bg);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 14px; cursor: pointer; transition: transform 0.15s;
  text-decoration: none; color: inherit;
}
.log-cta:active { transform: scale(0.98); }
.log-cta-left { display: flex; align-items: center; gap: 12px; }
.log-cta-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 1.2rem;
}
.log-cta-title { font-weight: 800; font-size: 0.95rem; }
.log-cta-sub   { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

/* ─────────────────────────────────────────────────────────
   CALENDAR
   ───────────────────────────────────────────────────────── */
.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.cal-month-year { font-size: 1.05rem; font-weight: 800; }
.cal-nav-btn {
  width: 34px; height: 34px; border: none;
  background: var(--bg); border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--primary); font-size: 0.9rem; transition: all 0.2s;
}
.cal-nav-btn:hover { background: var(--primary); color: white; }

.cal-weekdays {
  display: grid; grid-template-columns: repeat(7,1fr);
  margin-bottom: 6px;
}
.cal-wd {
  text-align: center; font-size: 0.68rem; font-weight: 800;
  color: var(--text-muted); padding: 3px 0;
}
.cal-wd:first-child { color: var(--primary-light); }

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

.cal-day {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.82rem; font-weight: 700;
  border-radius: 50%; cursor: pointer; position: relative;
  transition: all 0.15s; color: var(--text);
  -webkit-user-select: none; user-select: none;
}
.cal-day:empty, .cal-day.empty { cursor: default; }
.cal-day:not(.empty):active { transform: scale(0.88); }

.cal-day.today          { border: 2.5px solid var(--primary); color: var(--primary); }
.cal-day.period         { background: var(--period-color); color: white; }
.cal-day.predicted      { background: #FFB3C1; color: #C2185B; }
.cal-day.fertile        { background: var(--fertile-light); color: #2E7D32; }
.cal-day.ovulation      { background: var(--ovulation-color); color: white; }
.cal-day.other-month    { color: #DDD; cursor: default; }

/* Log dot */
.cal-day::after {
  content: ''; width: 4px; height: 4px;
  background: var(--primary); border-radius: 50%;
  position: absolute; bottom: 3px; left: 50%;
  transform: translateX(-50%); display: none;
}
.cal-day.has-log::after { display: block; }
.cal-day.period.has-log::after,
.cal-day.ovulation.has-log::after { background: rgba(255,255,255,0.8); }

/* Legend */
.cal-legend {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--border);
}
.legend-item {
  display: flex; align-items: center; gap: 5px;
  font-size: 0.72rem; color: var(--text-light); font-weight: 600;
}
.legend-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }

/* ─────────────────────────────────────────────────────────
   LOG PAGE
   ───────────────────────────────────────────────────────── */
.date-selector {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  background: var(--card-bg); border-radius: var(--radius);
  padding: 14px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.date-nav {
  width: 32px; height: 32px; border: none; background: var(--bg);
  border-radius: 50%; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  color: var(--primary); font-size: 0.85rem; transition: all 0.2s;
}
.date-nav:hover { background: var(--primary); color: white; }
.date-display { font-weight: 800; font-size: 1rem; text-align: center; min-width: 160px; }
.date-display small { display: block; font-size: 0.72rem; color: var(--text-muted); font-weight: 600; margin-top: 2px; }

.section-title {
  font-size: 0.88rem; font-weight: 800; color: var(--text);
  margin-bottom: 10px; display: flex; align-items: center; gap: 7px;
}
.section-title i { color: var(--primary); }

/* Flow options */
.flow-grid {
  display: grid; grid-template-columns: repeat(4,1fr); gap: 8px;
}
.flow-opt {
  display: flex; flex-direction: column; align-items: center;
  gap: 5px; padding: 12px 4px;
  background: var(--bg); border: 2px solid transparent;
  border-radius: var(--radius-sm); cursor: pointer;
  transition: all 0.2s; font-size: 0.72rem; color: var(--text-muted);
  font-weight: 700;
}
.flow-opt.selected { border-color: var(--primary); background: #FFF0F7; color: var(--primary); }
.flow-opt .flow-icon { font-size: 1.4rem; }

/* Mood / Symptom grid */
.option-grid {
  display: grid; grid-template-columns: repeat(3,1fr); gap: 8px;
}
.opt-item {
  display: flex; flex-direction: column; align-items: center;
  gap: 5px; padding: 11px 4px;
  background: var(--bg); border: 2px solid transparent;
  border-radius: var(--radius-sm); cursor: pointer;
  transition: all 0.2s; font-size: 0.7rem; text-align: center;
  color: var(--text-muted); font-weight: 700; line-height: 1.2;
}
.opt-item.selected { border-color: var(--primary); background: #FFF0F7; color: var(--primary); }
.opt-item i { font-size: 1.35rem; }

/* Numeric inputs row */
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric-item { background: var(--bg); border-radius: var(--radius-sm); padding: 12px; }
.metric-label { font-size: 0.72rem; color: var(--text-muted); font-weight: 700; margin-bottom: 6px;
  display: flex; align-items: center; gap: 5px; }
.metric-input {
  width: 100%; border: 2px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 1rem; font-weight: 700;
  background: white; color: var(--text); outline: none;
  transition: border-color 0.2s;
}
.metric-input:focus { border-color: var(--primary); }

/* Toggle for sexual activity, boolean options */
.bool-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; background: var(--bg);
  border-radius: var(--radius-sm);
}
.bool-label { font-size: 0.88rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.bool-label i { color: var(--primary); }
.switch {
  width: 46px; height: 26px; background: #DDD; border-radius: 13px;
  position: relative; cursor: pointer; transition: background 0.3s; border: none;
  flex-shrink: 0;
}
.switch.on { background: var(--primary); }
.switch::after {
  content: ''; width: 20px; height: 20px; background: white;
  border-radius: 50%; position: absolute; top: 3px; left: 3px;
  transition: transform 0.3s; box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.switch.on::after { transform: translateX(20px); }

/* Notes textarea */
.notes-area {
  width: 100%; border: 2px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 0.9rem; font-family: inherit;
  resize: none; outline: none; transition: border-color 0.2s;
  background: white; color: var(--text); min-height: 90px;
}
.notes-area:focus { border-color: var(--primary); }

/* ─────────────────────────────────────────────────────────
   PROFILE PAGE
   ───────────────────────────────────────────────────────── */
.profile-hero {
  text-align: center; padding: 28px 20px 20px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius); color: white; margin-bottom: 14px;
  box-shadow: 0 4px 20px rgba(233,30,140,0.3);
}
.profile-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  background: rgba(255,255,255,0.25); display: flex;
  align-items: center; justify-content: center;
  font-size: 2rem; margin: 0 auto 10px;
  border: 3px solid rgba(255,255,255,0.5);
}
.profile-hero-name { font-size: 1.2rem; font-weight: 800; }
.profile-hero-user { font-size: 0.82rem; opacity: 0.8; margin-top: 2px; }

.profile-menu-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; border-bottom: 1px solid var(--border); cursor: pointer;
}
.profile-menu-item:last-child { border-bottom: none; }
.pmi-left { display: flex; align-items: center; gap: 10px; }
.pmi-icon {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; color: white;
}
.pmi-title { font-size: 0.9rem; font-weight: 700; }
.pmi-sub   { font-size: 0.75rem; color: var(--text-muted); margin-top: 1px; }

/* ── Toggle rows for notification settings ── */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-label { font-size: 0.88rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.toggle-label i { color: var(--primary); width: 16px; text-align: center; }

/* ─────────────────────────────────────────────────────────
   REPORTS PAGE
   ───────────────────────────────────────────────────────── */
.stats-row {
  display: grid; grid-template-columns: repeat(3,1fr); gap: 10px;
  margin-bottom: 14px;
}
.stat-box {
  text-align: center; padding: 16px 8px;
  background: var(--card-bg); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.stat-num   { font-size: 1.7rem; font-weight: 900; color: var(--primary); line-height: 1; }
.stat-unit  { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); }
.stat-label { font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }

.chart-wrap { position: relative; height: 210px; }

.period-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.period-list-item:last-child { border-bottom: none; }
.pli-left { }
.pli-date  { font-weight: 700; font-size: 0.9rem; }
.pli-dur   { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.pli-badge {
  background: #FFE0EB; color: var(--primary);
  padding: 4px 10px; border-radius: 12px;
  font-size: 0.75rem; font-weight: 800;
}
.pli-edit {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 0.9rem; padding: 4px 6px;
  transition: color 0.2s;
}
.pli-edit:hover { color: var(--primary); }

/* ─────────────────────────────────────────────────────────
   FORMS (auth pages use these too)
   ───────────────────────────────────────────────────────── */
.form-group  { margin-bottom: 14px; }
.form-label  {
  display: block; font-size: 0.83rem; font-weight: 700;
  color: var(--text-light); margin-bottom: 6px;
}
.form-input {
  width: 100%; padding: 12px 14px;
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.95rem; color: var(--text); background: white;
  transition: border-color 0.2s; outline: none;
}
.form-input:focus { border-color: var(--primary); }
input[type="date"]  { color-scheme: light; }
input[type="range"] { -webkit-appearance: none; appearance: none; }

.range-slider {
  width: 100%; height: 6px; border-radius: 3px;
  background: var(--border); outline: none;
  -webkit-appearance: none; appearance: none; cursor: pointer;
}
.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary); cursor: pointer;
  box-shadow: 0 2px 8px rgba(233,30,140,0.4);
}
.range-slider::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary); cursor: pointer; border: none;
}
.range-value {
  display: inline-block; background: var(--primary); color: white;
  padding: 2px 8px; border-radius: 10px; font-size: 0.85rem;
  font-weight: 800; min-width: 32px; text-align: center;
}

/* ─────────────────────────────────────────────────────────
   BUTTONS
   ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; padding: 13px 22px;
  border: none; border-radius: var(--radius-sm);
  font-size: 0.95rem; font-weight: 800; font-family: inherit;
  cursor: pointer; transition: all 0.2s; text-decoration: none;
  letter-spacing: 0.2px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white; box-shadow: 0 4px 16px rgba(233,30,140,0.3);
}
.btn-primary:hover  { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(233,30,140,0.4); }
.btn-primary:active { transform: translateY(0); }
.btn-outline {
  background: transparent; color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-danger {
  background: #FFEBEE; color: #C62828;
  border: none;
}
.btn-ghost { background: var(--bg); color: var(--text-light); border: none; }
.btn-block { width: 100%; }
.btn-sm    { padding: 8px 14px; font-size: 0.82rem; }

/* ─────────────────────────────────────────────────────────
   ALERTS
   ───────────────────────────────────────────────────────── */
.alert {
  padding: 11px 14px; border-radius: var(--radius-sm);
  font-size: 0.875rem; margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px; font-weight: 700;
}
.alert-error   { background: #FFEBEE; color: #B71C1C; border-left: 4px solid #F44336; }
.alert-success { background: #E8F5E9; color: #1B5E20; border-left: 4px solid #4CAF50; }
.alert-info    { background: #E3F2FD; color: #0D47A1; border-left: 4px solid #2196F3; }

/* ─────────────────────────────────────────────────────────
   AUTH PAGES
   ───────────────────────────────────────────────────────── */
.auth-container {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, #FFF5F8 0%, #F8F0FF 100%);
}
.auth-logo {
  font-size: 2.2rem; font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; margin-bottom: 4px;
}
.auth-tagline { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 28px; font-weight: 600; }
.auth-card {
  width: 100%; max-width: 380px;
  background: white; border-radius: 24px;
  padding: 28px 22px; box-shadow: 0 8px 40px rgba(233,30,140,0.12);
}
.auth-title    { font-size: 1.5rem; font-weight: 900; margin-bottom: 2px; }
.auth-subtitle { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 20px; font-weight: 600; }
.auth-link     { text-align: center; margin-top: 18px; font-size: 0.88rem; color: var(--text-light); font-weight: 600; }
.auth-link a   { color: var(--primary); font-weight: 800; }

/* ─────────────────────────────────────────────────────────
   TOAST
   ───────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: calc(var(--nav-height) + 10px); left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(45,45,45,0.95); color: white;
  padding: 11px 20px; border-radius: 20px;
  font-size: 0.875rem; font-weight: 700;
  z-index: 9999; opacity: 0; transition: all 0.3s;
  white-space: nowrap; max-width: 90vw; pointer-events: none;
  backdrop-filter: blur(10px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─────────────────────────────────────────────────────────
   MODAL SHEET (bottom sheet)
   ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 2000; display: flex;
  align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal-sheet {
  background: white; border-radius: 22px 22px 0 0;
  padding: 8px 20px 28px;
  width: 100%; max-width: 480px;
  transform: translateY(100%); transition: transform 0.35s cubic-bezier(0.32,0.72,0,1);
  max-height: 85vh; overflow-y: auto;
  padding-bottom: max(28px, calc(28px + env(safe-area-inset-bottom)));
}
.modal-overlay.show .modal-sheet { transform: translateY(0); }
.modal-handle {
  width: 40px; height: 4px; background: #DDD;
  border-radius: 2px; margin: 12px auto 20px;
}
.modal-title { font-size: 1.1rem; font-weight: 800; margin-bottom: 16px; text-align: center; }

/* ─────────────────────────────────────────────────────────
   SPINNER
   ───────────────────────────────────────────────────────── */
.spinner {
  width: 36px; height: 36px;
  border: 4px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.7s linear infinite;
  margin: 30px auto; display: block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─────────────────────────────────────────────────────────
   RESPONSIVE BREAKPOINTS
   ───────────────────────────────────────────────────────── */

/* Tablet (≥ 600px) */
@media (min-width: 600px) {
  .app-container { max-width: 540px; box-shadow: 0 0 50px rgba(0,0,0,0.08); }
  .bottom-nav    { max-width: 540px; }
  .option-grid   { grid-template-columns: repeat(4,1fr); }
  .quick-stats   { grid-template-columns: repeat(4,1fr); }
  .stats-row     { gap: 14px; }
}

/* Large tablet / desktop (≥ 768px) */
@media (min-width: 768px) {
  body { background: #F0E8F5; }
  .app-container {
    max-width: 480px;
    box-shadow: 0 0 60px rgba(233,30,140,0.12);
    border-radius: 0;
  }
  .bottom-nav { max-width: 480px; }
  .auth-card  { padding: 36px 30px; }
  .page-content { padding: 20px; }
}

/* iPhone SE / very small (≤ 375px) */
@media (max-width: 375px) {
  .flow-grid   { grid-template-columns: repeat(2,1fr); }
  .option-grid { grid-template-columns: repeat(3,1fr); }
  .stats-row   { grid-template-columns: 1fr 1fr; }
  .stats-row .stat-box:last-child { grid-column: 1/-1; }
  .circle-wrapper { width: 180px; height: 180px; }
  .circle-svg     { width: 180px; height: 180px; }
  .circle-day-num { font-size: 2.8rem; }
}

/* Safe area insets for iPhone X+ notch & home bar */
@supports (padding: max(0px)) {
  body        { padding-bottom: max(var(--nav-height), calc(var(--nav-height) + env(safe-area-inset-bottom))); }
  .bottom-nav { padding-bottom: env(safe-area-inset-bottom); height: calc(var(--nav-height) + env(safe-area-inset-bottom)); }
  .app-header { padding-top: max(0px, env(safe-area-inset-top)); height: calc(var(--header-height) + env(safe-area-inset-top)); }
}

/* Dark mode minimal support */
@media (prefers-color-scheme: dark) {
  /* Keep light theme intentionally for medical/health context */
}
