/* ============================================================
   MamaZahra — Design System 2.0 (2026)
   Warm-soft: Notion warmth × Airbnb curves × bento grid
   Light mode. Pastel brand. Structured tokens for future dark mode.
   ============================================================ */

:root {
  /* --- Brand (vivid rose: energetic, confident) --- */
  --brand:           #e23680;
  --brand-deep:      #c01f66;
  --brand-soft:      #fad3e5;
  --brand-softer:    #fde9f3;
  --on-brand:        #ffffff;

  /* --- Warm neutrals (Notion-style yellow undertones, anchor for vivid accents) --- */
  --ink:             #2b2724;
  --ink-2:           #55504a;
  --muted:           #7f7870;
  --line:            #e7e0d8;
  --line-strong:     #d6cdc2;
  --surface:         #ffffff;
  --surface-2:       #f9f5f1;
  --surface-3:       #f0eae4;
  --bg:              #f6f1ec;

  /* --- Accent tints (saturated, happy health palette) --- */
  --teal:            #04a08f;
  --teal-deep:       #047a6d;
  --teal-soft:       #c8ece8;
  --lilac:           #6d3fc4;
  --lilac-deep:      #582ba0;
  --lilac-soft:      #e8def9;
  --azure:           #2563e6;
  --azure-deep:      #1a4fc0;
  --azure-soft:      #dfe7fc;
  --amber:           #ee8310;
  --amber-deep:      #c2660a;
  --amber-soft:      #fde5c8;
  --danger:          #c8455c;
  --danger-soft:     #fce6ea;

  /* --- Elevation: multi-layer, low-opacity (Notion philosophy) --- */
  --shadow-1: 0 1px 2px rgba(49,46,44,.04), 0 1px 3px rgba(49,46,44,.03);
  --shadow-2: 0 2px 6px rgba(49,46,44,.05), 0 6px 16px rgba(49,46,44,.04), 0 1px 2px rgba(49,46,44,.03);
  --shadow-3: 0 8px 28px rgba(49,46,44,.10), 0 2px 8px rgba(49,46,44,.05), 0 1px 2px rgba(49,46,44,.04);
  --shadow-brand: 0 8px 24px rgba(226,54,128,.42), 0 2px 6px rgba(226,54,128,.24);
  --ring: 0 0 0 3px rgba(226,54,128,.32);

  /* --- Radii: generous, Airbnb-style scale --- */
  --r-sm:   10px;
  --r-md:   14px;
  --r-lg:   20px;
  --r-xl:   28px;
  --r-full: 9999px;

  /* --- Spacing scale (8px base) --- */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px;
  --s6: 24px; --s7: 32px; --s8: 40px; --s9: 48px;

  /* --- Motion --- */
  --ease: cubic-bezier(.22,.61,.36,1);
  --dur:  .22s;
}

/* future dark mode hook: variables only, no markup changes needed
   :root[data-theme="dark"] { ...override tokens here... } */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'Vazirmatn', 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,h2,h3,h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }

/* ============================================================
   App shell
   ============================================================ */
.app {
  max-width: 480px; margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: 92px;
  position: relative;
}

/* --- Frosted header (2026 restrained glassmorphism) --- */
header.top {
  position: sticky; top: 0; z-index: 40;
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  font-weight: 700; font-size: 16px;
}
header.top .week-badge {
  background: var(--brand); color: var(--on-brand);
  font-size: 12px; font-weight: 700;
  padding: 4px 12px; border-radius: var(--r-full);
  box-shadow: var(--shadow-1);
}

/* --- Brand logo --- */
header.top .brand { display: flex; align-items: center; gap: 7px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 50%;
  object-fit: cover; display: block;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .16);
}
.hero-logo {
  display: block; width: min(200px, 62%); height: auto;
  margin: 0 auto 10px; border-radius: 14px;
  box-shadow: var(--shadow-1);
}

/* --- Floating frosted bottom nav --- */
nav.bottom {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: calc(100% - 24px); max-width: 456px;
  margin-bottom: 12px;
  z-index: 40;
  display: flex;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(16px) saturate(1.5);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  border: 1px solid color-mix(in srgb, var(--line) 90%, transparent);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-3);
  padding: 6px;
}
nav.bottom button {
  flex: 1; border: 0; background: none; font-family: inherit;
  font-size: 10.5px; color: var(--muted);
  padding: 8px 0 7px; cursor: pointer; border-radius: var(--r-full);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
nav.bottom button .ic { font-size: 20px; display: block; line-height: 1.2; }
nav.bottom button.active {
  color: var(--brand-deep); font-weight: 700;
  background: var(--brand-soft);
}

/* ============================================================
   Screens & cards
   ============================================================ */
.screen { display: none; padding: 16px; animation: fadeUp .3s var(--ease); }
.screen.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: 16px;
  margin-bottom: 12px;
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.card h3 { font-size: 16px; margin-bottom: 8px; }
.card p, .card li { font-size: 14px; line-height: 1.8; color: var(--ink-2); }
.card.hoverable:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); }
.card.clickable { cursor: pointer; }
.card.clickable:active { transform: scale(.985); }

/* --- Bento grid (2026 modular layout) --- */
.bento {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.bento .card { margin-bottom: 0; }
.bento .span2 { grid-column: span 2; }

/* --- Tinted surface cards --- */
.card.tint-brand  { background: var(--brand-softer); border-color: color-mix(in srgb, var(--brand) 22%, var(--line)); }
.card.tint-teal   { background: var(--teal-soft); border-color: color-mix(in srgb, var(--teal) 24%, var(--line)); }
.card.tint-lilac  { background: var(--lilac-soft); border-color: color-mix(in srgb, var(--lilac) 24%, var(--line)); }
.card.tint-amber  { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 24%, var(--line)); }
.card.tint-azure  { background: var(--azure-soft); border-color: color-mix(in srgb, var(--azure) 24%, var(--line)); }

.muted { color: var(--muted); font-size: 13px; }
.subtle { color: var(--ink-2); font-size: 13.5px; }

/* --- Hero gradient card --- */
.hero-card {
  background: linear-gradient(135deg, var(--brand-soft) 0%, var(--lilac-soft) 55%, var(--teal-soft) 100%);
  border: 1px solid color-mix(in srgb, var(--brand) 20%, var(--line));
  border-radius: var(--r-xl);
  padding: 20px;
  box-shadow: var(--shadow-2);
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
}
.hero-card::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at 88% 12%, rgba(255,255,255,.7), transparent 55%);
  pointer-events: none;
}

/* --- Big stat (bento metric) --- */
.stat-num { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; color: var(--ink); }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ============================================================
   Badges / pills / chips
   ============================================================ */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 700;
  border-radius: var(--r-full);
  padding: 3px 11px;
  border: 1px solid transparent;
}
.tag.teal  { background: var(--teal-soft);  color: var(--teal-deep); border-color: color-mix(in srgb, var(--teal) 20%, transparent); }
.tag.pink  { background: var(--brand-soft); color: var(--brand-deep); border-color: color-mix(in srgb, var(--brand) 20%, transparent); }
.tag.lilac { background: var(--lilac-soft); color: var(--lilac-deep); border-color: color-mix(in srgb, var(--lilac) 20%, transparent); }
.tag.amber { background: var(--amber-soft); color: var(--amber-deep); border-color: color-mix(in srgb, var(--amber) 20%, transparent); }
.tag.azure { background: var(--azure-soft); color: var(--azure-deep); border-color: color-mix(in srgb, var(--azure) 20%, transparent); }
.tag.gray  { background: var(--surface-3);  color: var(--muted); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: block; width: 100%; border: 0; border-radius: var(--r-md);
  background: var(--brand); color: var(--on-brand);
  font-family: inherit; font-size: 15px; font-weight: 700;
  padding: 13px 16px; cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
.btn:hover { background: var(--brand-deep); box-shadow: var(--shadow-2); }
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost {
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line-strong); box-shadow: none;
}
.btn.ghost:hover { background: var(--surface-3); }
.btn.teal { background: var(--teal); }
.btn.teal:hover { background: var(--teal-deep); }
.btn.azure { background: var(--azure); }
.btn.azure:hover { background: var(--azure-deep); }
.btn.danger { background: var(--danger); }
.btn.sm { width: auto; display: inline-block; padding: 8px 16px; font-size: 13px; }

.linkbtn {
  border: 0; background: none; color: var(--brand-deep); font-family: inherit;
  font-size: 13px; font-weight: 700; cursor: pointer; padding: 4px 0;
}
.linkbtn:hover { text-decoration: underline; }

/* ============================================================
   Forms
   ============================================================ */
.fld { display: block; margin-bottom: 14px; }
.fld > span {
  display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-2);
  margin-bottom: 6px;
}
.fld input, .fld select, .fld textarea {
  width: 100%;
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  padding: 12px; font-family: inherit; font-size: 14.5px; color: var(--ink);
  background: var(--surface);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.fld textarea { resize: vertical; min-height: 64px; }
.fld input::placeholder, .fld textarea::placeholder { color: var(--muted); }
.fld input:focus, .fld select:focus, .fld textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: var(--ring);
}
.fld input[type="date"] { direction: ltr; text-align: right; }
/* text inputs that hold a jalali (shamsi) date: always RTL, always tappable.
   On mobile the native date input forced LTR and misaligned inside .fld;
   the shamsi picker replaces it with a readonly text input, so this is the
   single rule that keeps those fields aligned everywhere. */
.fld input[data-jdp],
.fld input.jdp { direction: rtl; text-align: right; cursor: pointer; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-err { color: var(--danger); font-size: 12px; font-weight: 700; margin-top: 4px; }

/* --- Material-ish filled search input --- */
.searchbox {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  padding: 10px 16px;
}
.searchbox input {
  flex: 1; border: 0; background: none; font-family: inherit;
  font-size: 14px; color: var(--ink); outline: none;
}
.searchbox input::placeholder { color: var(--muted); }

/* ============================================================
   Tabs (segmented control)
   ============================================================ */
.tabs {
  display: flex; background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 4px; margin-bottom: 16px;
}
.tab {
  flex: 1; border: 0; border-radius: var(--r-sm);
  background: transparent; font-family: inherit;
  font-size: 13.5px; font-weight: 700; color: var(--muted);
  padding: 9px 0; cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tab.active {
  background: var(--surface); color: var(--brand-deep);
  box-shadow: var(--shadow-1);
}

/* ============================================================
   Lists & rows
   ============================================================ */
.switchrow {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; font-size: 14px;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
.switchrow:last-of-type { border-bottom: 0; }
.switchrow > span { color: var(--ink-2); }
.switchrow > b { color: var(--ink); font-weight: 600; text-align: left; }

.mrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.mstatus { text-align: left; }

.rem { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.rem:last-child { border-bottom: 0; }
.rem input { width: 20px; height: 20px; accent-color: var(--teal); }
.rem.done span { text-decoration: line-through; color: var(--muted); }

.rec { padding: 12px 0; border-bottom: 1px solid var(--line); }
.rec:last-child { border-bottom: 0; }
.rec p { font-size: 13px; }

.notice {
  background: var(--amber-soft);
  border: 1px solid color-mix(in srgb, var(--amber) 30%, var(--line));
  border-radius: var(--r-md);
  padding: 12px 14px; font-size: 13px; line-height: 1.8; margin-bottom: 12px;
  color: #9a5710;
}

/* ============================================================
   Chat
   ============================================================ */
.msgs { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.msg {
  max-width: 80%; padding: 10px 14px;
  border-radius: var(--r-lg); font-size: 14px; line-height: 1.8;
  animation: fadeUp .25s var(--ease);
}
.msg.midwife {
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-1); border: 1px solid var(--line);
  border-start-start-radius: 4px; align-self: flex-start;
}
.msg.me {
  background: var(--brand); color: var(--on-brand);
  border-start-end-radius: 4px; align-self: flex-end;
  box-shadow: var(--shadow-brand);
}
.chatbar { display: flex; gap: 8px; }
.chatbar input {
  flex: 1; border: 1px solid var(--line-strong); border-radius: var(--r-full);
  padding: 11px 16px; font-family: inherit; font-size: 14px;
  background: var(--surface);
}
.chatbar input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.chatbar button {
  border: 0; border-radius: var(--r-full); background: var(--teal); color: #fff;
  font-family: inherit; font-weight: 700; padding: 0 18px; cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.chatbar button:hover { background: var(--teal-deep); }

/* ============================================================
   Cycle calendar
   ============================================================ */
.cal-head, .cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-head span { font-size: 11px; color: var(--muted); font-weight: 700; padding: 4px 0; }
.cal-d {
  aspect-ratio: 1; border: 0; border-radius: 50%; background: transparent;
  font-family: inherit; font-size: 13.5px; color: var(--ink); cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.cal-d.blank { visibility: hidden; }
.cal-d.today { outline: 2px solid var(--teal); outline-offset: -2px; }
.cal-d.p-period { background: var(--brand-soft); color: var(--brand-deep); font-weight: 700; }
.cal-d.p-fertile { background: var(--teal-soft); color: var(--teal-deep); font-weight: 700; }
.cal-d.sel { outline: 2px solid var(--brand); outline-offset: -2px; }

.logrow { display: flex; gap: 8px; }
.logrow button {
  flex: 1; border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface-2);
  font-family: inherit; font-size: 14px; font-weight: 700; padding: 10px 0;
  cursor: pointer; color: var(--ink);
  transition: background var(--dur) var(--ease);
}
.logrow button:active { background: var(--surface-3); }

/* ============================================================
   Progress
   ============================================================ */
.progress {
  height: 10px; background: var(--surface-3);
  border-radius: var(--r-full); overflow: hidden; margin-top: 10px;
}
.progress > div {
  height: 100%; border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--brand), var(--lilac));
  transition: width .5s var(--ease);
}

/* ============================================================
   Switch (toggle)
   ============================================================ */
.switch {
  position: relative; width: 46px; height: 26px;
  background: var(--line-strong); border-radius: var(--r-full);
  border: 0; cursor: pointer; flex: none;
  transition: background var(--dur) var(--ease);
}
.switch::after {
  content: ''; position: absolute; top: 3px; inset-inline-start: 3px;
  width: 20px; height: 20px; background: #fff; border-radius: 50%;
  box-shadow: var(--shadow-1);
  transition: transform var(--dur) var(--ease);
}
.switch.on { background: var(--teal); }
.switch.on::after { transform: translateX(-20px); }

/* ============================================================
   3D fetus viewer
   ============================================================ */
.viewer {
  height: 280px; border-radius: var(--r-lg); overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #fdeef3 0%, #f8dce6 55%, #f3c9d8 100%);
  touch-action: none;
}
.viewer canvas, .viewer svg { width: 100%; height: 100%; display: block; }
.wkrow { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.wkrow button {
  border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface-2);
  font-family: inherit; font-size: 13px; font-weight: 700; padding: 8px 14px;
  cursor: pointer; color: var(--ink);
}
.wkrow span { font-weight: 700; font-size: 15px; }

/* ============================================================
   Loading skeleton (2026: replace spinners)
   ============================================================ */
.skel {
  border-radius: var(--r-md); height: 84px; margin-bottom: 12px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite;
}
.skel-sm { height: 44px; }
.skel-lg { height: 140px; border-radius: var(--r-xl); }

/* ============================================================
   Toast (microinteraction)
   ============================================================ */
.toast {
  position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%) translateY(12px);
  z-index: 90;
  background: var(--ink); color: #fff;
  padding: 11px 20px; border-radius: var(--r-full);
  font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow-3);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

/* ============================================================
   Utilities & animations
   ============================================================ */
.hidden { display: none; }
.fade-in { animation: fadeUp .3s var(--ease); }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(226,54,128,.5); }
  70%  { box-shadow: 0 0 0 12px rgba(226,54,128,0); }
  100% { box-shadow: 0 0 0 0 rgba(226,54,128,0); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer {
  from { background-position: 100% 0; }
  to   { background-position: -100% 0; }
}

/* ============================================================
   Desktop comfort
   ============================================================ */
@media (min-width: 900px) {
  .app { max-width: 720px; }
  .card { padding: 20px; }
  .bento { grid-template-columns: repeat(4, 1fr); }
  .bento .span2 { grid-column: span 2; }
}
