/* ─── Primacare Family Dashboard — Mobile-first ─────────────────────────── */

:root {
  --bg: #FEFCF8;
  --bg-alt: #F7F2E9;
  --green: #2C5F2E;
  --green-lt: #3D7A3E;
  --sand: #E8D5B7;
  --sand-lt: #F0E8D6;
  --ember: #C9622F;
  --ember-lt: #E07A45;
  --text: #2A2520;
  --text-soft: #5C5248;
  --muted: #9B8D7E;
  --border: #DDD4C4;
  --card: #FFFFFF;
  --radius: 16px;
  --radius-sm: 10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: 'DM Serif Display', Georgia, serif; font-weight: 400; line-height: 1.15; }

.section-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ember);
  display: block;
  margin-bottom: 0.5rem;
}

/* ─── App Shell ──────────────────────────────────────────────────────────── */
.app-header {
  background: var(--green);
  color: white;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(44,95,46,0.25);
}

.app-header .logo {
  font-family: 'DM Serif Display', serif;
  font-size: 1.25rem;
  color: white;
  text-decoration: none;
}

.app-header .logo span { color: var(--sand); }

.senior-switch {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  color: white;
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
}

.app-main { padding: 1.25rem 1rem 6rem; max-width: 600px; margin: 0 auto; }

/* ─── Emergency Button ────────────────────────────────────────────────────── */
.emergency-section { margin-bottom: 1.5rem; text-align: center; }

.btn-emergency {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--ember);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 0.9rem 2.5rem;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(201,98,47,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
  letter-spacing: 0.02em;
  position: relative;
  overflow: hidden;
}

.btn-emergency::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%);
}

.btn-emergency:hover { transform: scale(1.04); box-shadow: 0 6px 28px rgba(201,98,47,0.5); }
.btn-emergency:active { transform: scale(0.97); }

.btn-emergency .pulse {
  width: 10px; height: 10px;
  background: white;
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.6); opacity: 0.6; }
}

.emergency-note {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

.emergency-confirm {
  display: none;
  background: var(--card);
  border: 2px solid var(--ember);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-top: 0.75rem;
  text-align: center;
}

.emergency-confirm.show { display: block; }

.emergency-confirm p { font-weight: 600; margin-bottom: 0.75rem; color: var(--ember); }

.confirm-row { display: flex; gap: 0.75rem; justify-content: center; }

.btn-confirm-trigger {
  background: var(--ember);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 0.6rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.btn-cancel {
  background: var(--bg-alt);
  color: var(--text-soft);
  border: none;
  border-radius: 50px;
  padding: 0.6rem 1.5rem;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
}

/* ─── Alert confirmation banner ──────────────────────────────────────────── */
.alert-sent {
  display: none;
  background: #D4EDDA;
  border: 1px solid #28A745;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--green);
  text-align: center;
}

.alert-sent.show { display: block; }

/* ─── Health Summary Card ─────────────────────────────────────────────────── */
.health-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  border: 1px solid var(--border);
}

.health-card h2 { font-size: 1.1rem; margin-bottom: 0.75rem; color: var(--green); }

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

.vital-item {
  background: var(--sand-lt);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
}

.vital-label { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.vital-value { font-size: 1rem; font-weight: 700; color: var(--text); margin-top: 0.15rem; }

.appointments-list { margin-top: 0.75rem; }

.appt-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

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

.appt-date-badge {
  background: var(--ember);
  color: white;
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  text-align: center;
  min-width: 48px;
  flex-shrink: 0;
}

.appt-date-badge .day { font-size: 1.2rem; font-weight: 800; line-height: 1; }
.appt-date-badge .month { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.06em; }

.appt-info { flex: 1; }
.appt-title { font-weight: 600; font-size: 0.9rem; }
.appt-meta { font-size: 0.78rem; color: var(--muted); margin-top: 0.1rem; }

/* ─── Section Cards ──────────────────────────────────────────────────────── */
.section-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  border: 1px solid var(--border);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-card h2 { font-size: 1.1rem; color: var(--text); }

.btn-add {
  background: var(--green);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 0.4rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-add:hover { background: var(--green-lt); }

/* ─── Care Log ───────────────────────────────────────────────────────────── */
.log-entry {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--sand);
}

.log-entry:last-child { border-bottom: none; }

.log-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  font-weight: 700;
}

.icon-meal { background: #FFF3CD; color: #856404; }
.icon-medication { background: #D4EDDA; color: var(--green); }
.icon-walk { background: #E8F4FD; color: #0D6EFD; }
.icon-other { background: var(--sand-lt); color: var(--text-soft); }
.icon-sleep { background: #E2D9F3; color: #5A3E9E; }

.log-body { flex: 1; }
.log-title { font-weight: 600; font-size: 0.9rem; }
.log-notes { font-size: 0.85rem; color: var(--text-soft); margin-top: 0.15rem; }
.log-time { font-size: 0.75rem; color: var(--muted); margin-top: 0.2rem; }

/* ─── Medication Schedule ────────────────────────────────────────────────── */
.med-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  background: var(--sand-lt);
  border-left: 4px solid var(--green);
}

.med-icon {
  width: 36px; height: 36px;
  background: var(--green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.med-body { flex: 1; }
.med-name { font-weight: 700; font-size: 0.95rem; }
.med-dose { font-size: 0.82rem; color: var(--text-soft); }

.med-time-badge {
  background: white;
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 0.25rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--green);
  white-space: nowrap;
}

.med-due-today { border-color: var(--ember); color: var(--ember); }
.med-due-today .med-time-badge { background: var(--ember); color: white; border-color: var(--ember); }

/* ─── Caregiver Activity Feed ────────────────────────────────────────────── */
.activity-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--sand);
}

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

.activity-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.act-visit { background: #E8F4FD; color: #0D6EFD; }
.act-call { background: #FFF3CD; color: #856404; }
.act-med { background: #D4EDDA; color: var(--green); }
.act-meal { background: #FDE8D8; color: var(--ember); }

.activity-body { flex: 1; }
.activity-title { font-weight: 600; font-size: 0.9rem; }
.activity-meta { font-size: 0.78rem; color: var(--muted); margin-top: 0.1rem; }
.activity-duration { font-size: 0.75rem; color: var(--text-soft); background: var(--sand-lt); padding: 0.1rem 0.5rem; border-radius: 4px; display: inline-block; margin-top: 0.2rem; }

/* ─── Add Log Modal ─────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.show { display: flex; }

.modal-sheet {
  background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.5rem;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-sheet h3 { font-size: 1.15rem; margin-bottom: 1rem; }

.form-group { margin-bottom: 1rem; }

.form-group label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-soft); margin-bottom: 0.4rem; text-transform: uppercase; letter-spacing: 0.06em; }

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--green);
}

textarea { resize: vertical; min-height: 80px; }

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

.btn-submit {
  width: 100%;
  background: var(--green);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-submit:hover { background: var(--green-lt); }

.btn-close-modal {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  margin-bottom: 0.75rem;
}

/* ─── Empty States ───────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
}

.empty-state p { font-size: 0.9rem; }

/* ─── Loading ────────────────────────────────────────────────────────────── */
.loading { text-align: center; padding: 1rem; color: var(--muted); font-size: 0.85rem; }

/* ─── Bottom Nav ──────────────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 0.5rem 0;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.4rem 0.75rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 600;
  transition: color 0.15s;
}

.nav-item.active { color: var(--green); }
.nav-item span { font-size: 1.2rem; }