/* ═══════════════════════════════════════════════════
   FamilyMate — Shared Styles
   Font: DM Sans (same as PipelineMate)
   Theme: Dark default, light toggle
═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

/* ─── CSS Variables ──────────────────────────────── */
:root {
  --bg: #0f1923;
  --bg2: #1a2535;
  --bg3: #212f42;
  --card: #1e2d3d;
  --border: #2a3f55;
  --text: #e8edf2;
  --text2: #8fa3b8;
  --text3: #5a7a96;
  --accent: #4f8ef7;
  --accent2: #3a7bd5;
  --green: #34c97b;
  --red: #f05c5c;
  --orange: #f5a623;
  --yellow: #ffd166;
  --purple: #a78bfa;
  --nav-h: 64px;
  --header-h: 60px;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --transition: 0.2s ease;
}

[data-theme="light"] {
  --bg: #f0f4f8;
  --bg2: #e2e9f0;
  --bg3: #d4dde6;
  --card: #ffffff;
  --border: #c8d5e0;
  --text: #1a2535;
  --text2: #4a6380;
  --text3: #7a95aa;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
}

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

html { font-size: 16px; -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ─── Header ─────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 480px;
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-title .logo-tap {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg2);
  color: var(--text2);
  transition: background var(--transition), color var(--transition);
  font-size: 18px;
}
.icon-btn:hover, .icon-btn:active { background: var(--bg3); color: var(--text); }

/* ─── Page Content ───────────────────────────────── */
.page-content {
  padding-top: calc(var(--header-h) + 16px);
  padding-bottom: calc(var(--nav-h) + 24px);
  padding-left: 16px;
  padding-right: 16px;
  min-height: 100vh;
}

/* ─── Bottom Nav ─────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 480px;
  height: var(--nav-h);
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text3);
  font-size: 11px;
  font-weight: 500;
  transition: color var(--transition);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.nav-item svg { width: 22px; height: 22px; stroke-width: 1.8; }
.nav-item.active { color: var(--accent); }
.nav-item.active svg { stroke-width: 2.2; }

/* ─── Cards ──────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ─── Section Title ──────────────────────────────── */
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 20px 0 10px;
}

/* ─── Stat Boxes ─────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.stat-label { font-size: 12px; color: var(--text3); font-weight: 500; margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--text); }
.stat-value.accent { color: var(--accent); }
.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }
.stat-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }

/* ─── List Items ─────────────────────────────────── */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; padding-bottom: 0; }
.list-item:first-child { padding-top: 0; }

.item-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--bg2);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.item-info { flex: 1; min-width: 0; }
.item-name { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }

.item-right { text-align: right; flex-shrink: 0; }
.item-amount { font-size: 15px; font-weight: 700; color: var(--text); }
.item-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; margin-top: 3px; display: inline-block; }
.badge-red { background: rgba(240,92,92,0.15); color: var(--red); }
.badge-orange { background: rgba(245,166,35,0.15); color: var(--orange); }
.badge-green { background: rgba(52,201,123,0.15); color: var(--green); }
.badge-blue { background: rgba(79,142,247,0.15); color: var(--accent); }

/* ─── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  font-family: 'DM Sans', sans-serif;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover, .btn-primary:active { background: var(--accent2); transform: scale(0.98); }
.btn-secondary { background: var(--bg2); color: var(--text); }
.btn-secondary:hover, .btn-secondary:active { background: var(--bg3); }
.btn-danger { background: rgba(240,92,92,0.15); color: var(--red); }
.btn-danger:hover, .btn-danger:active { background: rgba(240,92,92,0.25); }
.btn-full { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 8px; }

/* ─── FAB ────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  right: 50%;
  transform: translateX(calc(50% - 240px + 16px));
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 24px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(79,142,247,0.4);
  cursor: pointer;
  z-index: 90;
  transition: all var(--transition);
  border: none;
}
.fab:active { transform: translateX(calc(50% - 240px + 16px)) scale(0.92); }
@media (max-width: 480px) {
  .fab { right: 16px; transform: none; }
  .fab:active { transform: scale(0.92); }
}

/* ─── Forms ──────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 6px; display: block; }
.form-input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  outline: none;
  transition: border-color var(--transition);
}
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text3); }
select.form-input { appearance: none; cursor: pointer; }

/* ─── Modal / Drawer ─────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal-sheet {
  width: 100%; max-width: 480px;
  background: var(--bg2);
  border-radius: 20px 20px 0 0;
  padding: 20px 20px 36px;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32,0.72,0,1);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-overlay.open .modal-sheet { transform: translateY(0); }

.modal-drag { width: 40px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 16px; }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; }

/* Centered modal variant */
.modal-center {
  align-items: center;
}
.modal-center .modal-sheet {
  border-radius: 20px;
  max-width: 340px;
  margin: 0 16px;
  transform: scale(0.9);
  transition: transform 0.25s ease;
}
.modal-overlay.open .modal-center .modal-sheet { transform: scale(1); }

/* ─── Empty State ────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text3);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.6; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.empty-sub { font-size: 13px; line-height: 1.5; }

/* ─── Category Pills ─────────────────────────────── */
.pill-row {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
  margin-bottom: 16px;
}
.pill-row::-webkit-scrollbar { display: none; }

.pill {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  background: var(--bg2);
  color: var(--text2);
  border: 1px solid var(--border);
  transition: all var(--transition);
  flex-shrink: 0;
}
.pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ─── Chips ──────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  background: var(--bg3);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
}

/* ─── Progress Bar ───────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.5s ease;
}

/* ─── Divider ────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ─── Toast ──────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 80px);
  left: 50%; transform: translateX(-50%);
  background: var(--bg3);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 500;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
#toast.show { opacity: 1; }

/* ─── Loader ─────────────────────────────────────── */
.loader {
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
}
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Expiry Indicator ───────────────────────────── */
.expiry-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.expiry-dot.red { background: var(--red); }
.expiry-dot.orange { background: var(--orange); }
.expiry-dot.green { background: var(--green); }

/* ─── Avatar ─────────────────────────────────────── */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

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

/* ─── Animations ─────────────────────────────────── */
@keyframes fadeIn { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease forwards; }

/* ─── Dev Panel Modal ────────────────────────────── */
.dev-panel-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.dev-panel-row .form-input { flex: 1; }
