/* Care for Kylie — Design System */
:root {
  --bg-primary: #faf8f5;
  --bg-card: #ffffff;
  --bg-sidebar: #f5f0eb;
  --text-primary: #2d3436;
  --text-secondary: #636e72;
  --text-muted: #b2bec3;
  --accent-primary: #2d6a4f;
  --accent-light: #95d5b2;
  --accent-warm: #d4a574;
  --status-normal: #2d6a4f;
  --status-warning: #e17055;
  --status-critical: #d63031;
  --status-info: #0984e3;
  --cycle-completed: #00b894;
  --cycle-active: #0984e3;
  --cycle-scheduled: #b2bec3;
  --cycle-delayed: #e17055;
  --font-heading: 'Playfair Display', Georgia, serif;
  --font-body: 'Source Sans 3', -apple-system, sans-serif;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

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

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

body {
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: 600; line-height: 1.3; }

img { max-width: 100%; height: auto; }

/* ===== PUBLIC PAGE ===== */
.public-page { background: var(--bg-primary); }

.hero {
  background: linear-gradient(135deg, #2d6a4f 0%, #40916c 50%, #52b788 100%);
  color: white;
  padding: 80px 20px;
  text-align: center;
}
.hero-inner { max-width: 700px; margin: 0 auto; }
.hero-title { font-size: 3rem; margin-bottom: 12px; font-weight: 700; }
.hero-subtitle { font-size: 1.25rem; opacity: 0.9; font-weight: 300; }

.public-main { max-width: 900px; margin: 0 auto; padding: 40px 20px; }

.public-main section { margin-bottom: 48px; }
.public-main h2 { font-size: 1.75rem; margin-bottom: 16px; color: var(--accent-primary); }

.container { max-width: 900px; margin: 0 auto; }

.update-card, .help-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.update-date { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 8px; }
.update-content { white-space: pre-wrap; }

.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.help-card { text-align: center; }
.help-icon { font-size: 2.5rem; margin-bottom: 12px; }
.help-card h3 { margin-bottom: 8px; }

.public-footer {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-muted);
  border-top: 1px solid #e9e5e0;
}
.footer-link { color: var(--text-muted); font-size: 0.875rem; }

/* ===== LOGIN ===== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  flex-direction: column;
  padding: 20px;
}
.login-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 420px;
}
.login-title { font-size: 1.5rem; text-align: center; margin-bottom: 4px; }
.login-subtitle { text-align: center; color: var(--text-muted); margin-bottom: 24px; }
.login-form .form-group { margin-bottom: 16px; }
.login-back { margin-top: 20px; color: var(--text-muted); font-size: 0.875rem; }

/* ===== PORTAL LAYOUT ===== */
.portal-page { display: flex; min-height: 100vh; }

.portal-nav {
  width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid #e9e5e0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s;
}
.nav-header {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-brand {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-primary);
}
.nav-brand:hover { text-decoration: none; }
.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: 8px; }
.nav-toggle span { display: block; width: 22px; height: 2px; background: var(--text-primary); margin: 4px 0; transition: 0.3s; }
.nav-links { list-style: none; padding: 0 8px; }
.nav-links li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
}
.nav-links li a:hover { background: rgba(45,106,79,0.08); color: var(--accent-primary); text-decoration: none; }
.nav-links li a.active { background: rgba(45,106,79,0.12); color: var(--accent-primary); font-weight: 600; }
.nav-icon { font-size: 1.1rem; width: 24px; text-align: center; flex-shrink: 0; }
.nav-divider { border-top: 1px solid #e0dbd5; margin: 8px 12px; }
.nav-logout { color: var(--text-muted) !important; }

.portal-main {
  flex: 1;
  margin-left: 240px;
  padding: 24px;
  max-width: 1200px;
}

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 { font-size: 1.75rem; }

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f0ebe5;
}
.card-header h2 { font-size: 1.1rem; margin: 0; }
.card-body { padding: 20px; }
.card-link { font-size: 0.85rem; color: var(--accent-primary); }
.card-full { margin-bottom: 16px; }
.card-wide { grid-column: span 2; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

/* ===== ALERTS ===== */
.alerts-container { margin-bottom: 20px; }
.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-weight: 500;
}
.alert-critical { background: #fde8e8; color: #c0392b; border-left: 4px solid #d63031; }
.alert-warning { background: #fef3e2; color: #d35400; border-left: 4px solid #e17055; }
.alert-error { background: #fde8e8; color: #c0392b; border-left: 4px solid #d63031; }
.alert-success { background: #e8f5e9; color: #2d6a4f; border-left: 4px solid #2d6a4f; }

/* ===== FORMS ===== */
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.form-group label { font-weight: 500; font-size: 0.9rem; color: var(--text-secondary); }
.form-row { display: flex; gap: 16px; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="time"], input[type="datetime-local"], input[type="tel"],
input[type="url"], select, textarea {
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  font-family: var(--font-body);
  background: white;
  transition: border-color 0.2s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(45,106,79,0.1);
}
textarea { resize: vertical; }

input[type="range"] {
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 4px;
  background: #e0dbd5;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.checkbox-label input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent-primary); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  font-family: var(--font-body);
  border: none;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--accent-primary); color: white; }
.btn-primary:hover { background: #245a42; }
.btn-outline { background: transparent; border: 1px solid var(--accent-primary); color: var(--accent-primary); }
.btn-outline:hover { background: rgba(45,106,79,0.05); }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-full { width: 100%; }
.btn-action {
  background: var(--bg-sidebar);
  color: var(--text-primary);
  border: 1px solid #e0dbd5;
  flex: 1;
  min-width: 140px;
}
.btn-action:hover { background: #ebe5dd; }

.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ===== TABLES ===== */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 2px solid #f0ebe5;
  position: sticky;
  top: 0;
  background: white;
}
.table td { padding: 10px 12px; border-bottom: 1px solid #f5f0eb; font-size: 0.925rem; }
.table tbody tr:nth-child(even) { background: #faf8f5; }
.table tbody tr:hover { background: #f5f0eb; }
.row-high td { background: rgba(214,48,49,0.04) !important; }
.row-low td { background: rgba(225,112,85,0.04) !important; }

.table-mini { width: 100%; border-collapse: collapse; }
.table-mini td { padding: 6px 8px; font-size: 0.85rem; border-bottom: 1px solid #f5f0eb; }

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-danger { background: rgba(214,48,49,0.1); color: #d63031; }
.badge-warning { background: rgba(225,112,85,0.1); color: #e17055; }
.badge-success { background: rgba(0,184,148,0.1); color: #00b894; }
.badge-info { background: rgba(9,132,227,0.1); color: #0984e3; }
.badge-muted { background: rgba(178,190,195,0.2); color: var(--text-secondary); }

/* ===== MODAL ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal.open { display: flex; }
.modal-content {
  background: white;
  border-radius: var(--radius);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.modal-large { max-width: 640px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #f0ebe5;
}
.modal-header h2 { font-size: 1.1rem; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
}
.modal-body { padding: 20px; }

/* ===== FILTER TABS ===== */
.filter-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-tab {
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid #e0dbd5;
  transition: all 0.2s;
}
.filter-tab:hover { background: #f0ebe5; text-decoration: none; }
.filter-tab.active { background: var(--accent-primary); color: white; border-color: var(--accent-primary); }

/* ===== VITALS ===== */
.vitals-grid-mini { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 12px; }
.vital-item {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  background: #f9f6f2;
  border-radius: 8px;
}
.vital-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.vital-value { font-size: 1.25rem; font-weight: 600; }
.vital-danger { background: rgba(214,48,49,0.08); }
.vital-danger .vital-value { color: var(--status-critical); }

/* ===== CEA ===== */
.cea-latest {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 16px;
}
.cea-value { font-size: 2.5rem; font-weight: 700; color: var(--accent-primary); font-family: var(--font-heading); }
.cea-unit { color: var(--text-muted); font-size: 1rem; }
.cea-date { color: var(--text-muted); font-size: 0.85rem; margin-left: auto; }

/* ===== CHEMO ===== */
.chemo-countdown { text-align: center; padding: 16px 0; }
.countdown-number { display: block; font-size: 2rem; font-weight: 700; color: var(--accent-primary); font-family: var(--font-heading); }
.countdown-label { display: block; color: var(--text-secondary); margin-top: 4px; }
.countdown-date { display: block; color: var(--text-muted); font-size: 0.85rem; margin-top: 2px; }

.cycle-timeline { display: flex; flex-direction: column; gap: 16px; }
.cycle-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-left: 4px solid var(--cycle-scheduled);
  overflow: hidden;
}
.cycle-completed { border-left-color: var(--cycle-completed); }
.cycle-in_progress { border-left-color: var(--cycle-active); }
.cycle-delayed { border-left-color: var(--cycle-delayed); }
.cycle-header { padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #f0ebe5; }
.cycle-number { font-family: var(--font-heading); font-weight: 600; font-size: 1.1rem; }
.cycle-body { padding: 16px 20px; }
.cycle-detail { margin-bottom: 6px; font-size: 0.9rem; }
.cycle-day-counter { margin-top: 12px; padding: 8px; background: rgba(9,132,227,0.08); border-radius: 8px; text-align: center; color: var(--status-info); font-weight: 600; }
.cycle-actions { padding: 12px 20px; border-top: 1px solid #f0ebe5; }

/* ===== SYMPTOMS ===== */
.symptom-sliders { display: grid; gap: 16px; margin-bottom: 20px; }
.slider-group label { display: flex; align-items: center; gap: 8px; font-weight: 500; margin-bottom: 4px; }
.slider-value { font-weight: 700; color: var(--accent-primary); }

.symptom-calendar { display: flex; flex-direction: column; gap: 12px; }
.symptom-day {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: #faf8f5;
  border-radius: 8px;
  flex-wrap: wrap;
}
.symptom-day-date { font-weight: 600; min-width: 100px; font-size: 0.9rem; }
.symptom-bars { display: flex; gap: 8px; flex: 1; min-width: 200px; }
.symptom-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  height: 20px;
  background: #ede9e3;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.bar-label { font-size: 0.65rem; font-weight: 700; color: var(--text-muted); z-index: 1; padding-left: 4px; }
.bar-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; transition: width 0.3s; }

/* ===== MEDICATIONS ===== */
.med-list { display: flex; flex-direction: column; gap: 12px; }
.med-card.med-inactive { opacity: 0.6; }
.med-card.med-chemo { border-left: 4px solid var(--status-info); }
.med-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; flex-wrap: wrap; gap: 8px; }

/* ===== APPOINTMENTS ===== */
.appt-card { display: flex; gap: 20px; align-items: flex-start; }
.appt-date-big { font-family: var(--font-heading); font-size: 1.1rem; font-weight: 600; }
.appt-time { color: var(--text-muted); font-size: 0.85rem; }
.appt-item { padding: 8px 0; border-bottom: 1px solid #f5f0eb; }
.appt-item:last-child { border-bottom: none; }
.appt-date { font-size: 0.85rem; color: var(--text-muted); }
.appt-detail { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ===== PROVIDERS ===== */
.provider-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

/* ===== IMAGING ===== */
.imaging-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }
.img-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; flex-wrap: wrap; gap: 8px; }
.img-section { margin-top: 12px; }
.img-section p { margin-top: 4px; font-size: 0.9rem; }

/* ===== NOTES ===== */
.notes-list { display: flex; flex-direction: column; gap: 12px; }
.note-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; flex-wrap: wrap; gap: 8px; }
.note-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.note-content { white-space: pre-wrap; font-size: 0.95rem; line-height: 1.7; }
.note-title { font-size: 1rem; margin-bottom: 4px; }
.note-preview { font-size: 0.9rem; color: var(--text-secondary); }

/* ===== UPDATES ===== */
.update-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; flex-wrap: wrap; gap: 8px; }
.update-actions { display: flex; align-items: center; gap: 8px; }

/* ===== TIMELINE ===== */
.timeline { position: relative; padding-left: 40px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 18px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #e0dbd5;
}
.timeline-month {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent-primary);
  margin: 24px 0 12px -40px;
  padding-left: 40px;
}
.timeline-event {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  position: relative;
}
.timeline-icon {
  position: absolute;
  left: -31px;
  width: 28px;
  height: 28px;
  background: white;
  border: 2px solid #e0dbd5;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}
.timeline-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  flex: 1;
}
.timeline-date { font-size: 0.8rem; color: var(--text-muted); }
.timeline-title { font-weight: 600; }
.timeline-detail { font-size: 0.85rem; margin-top: 2px; }

/* ===== UTILITIES ===== */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-danger { color: var(--status-critical); }
.text-warning { color: var(--status-warning); }
.text-sm { font-size: 0.85rem; }
.empty-state { color: var(--text-muted); text-align: center; padding: 20px; font-style: italic; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .portal-nav {
    transform: translateX(-100%);
    width: 280px;
    box-shadow: var(--shadow-md);
  }
  .portal-nav.open { transform: translateX(0); }
  .nav-toggle { display: block; }
  .portal-main { margin-left: 0; padding: 16px; }

  .dashboard-grid { grid-template-columns: 1fr; }
  .card-wide { grid-column: span 1; }
  .form-row { flex-direction: column; }
  .hero-title { font-size: 2rem; }
  .hero { padding: 48px 20px; }
  .cea-value { font-size: 2rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .appt-card { flex-direction: column; gap: 8px; }
  .imaging-grid { grid-template-columns: 1fr; }

  .filter-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .filter-tab { white-space: nowrap; }
}

@media (max-width: 375px) {
  .portal-main { padding: 12px; }
  .card-body { padding: 14px; }
  .vitals-grid-mini { grid-template-columns: 1fr; }
}

/* ===== PRINT ===== */
@media print {
  .portal-nav, .nav-toggle, .btn, .modal, .filter-tabs, .quick-actions { display: none !important; }
  .portal-main { margin-left: 0; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  .alert { border: 1px solid currentColor; }
  body { background: white; }
}
