/* MamaGuard Doctor Frontend — Clinical Design System
   Palette: Deep Mauve authority + warm cream surfaces + clinical clarity */

:root {
  --brand:        #4A2545;
  --brand-mid:    #6B3460;
  --brand-light:  rgba(74, 37, 69, 0.10);
  --brand-tint:   rgba(74, 37, 69, 0.06);
  --brand-border: rgba(74, 37, 69, 0.20);

  --bg:           #F8F5F1;
  --bg-alt:       #F3EFE9;
  --surface:      #FFFFFF;
  --surface-alt:  #FDFCFA;
  --divider:      #E2D9CE;
  --text-1:       #1A1118;
  --text-2:       #5A4F57;
  --text-3:       #8F8289;

  --risk-green:   #1E8E4E;
  --risk-green-bg:#E8F7EE;
  --risk-yellow:  #B87E00;
  --risk-yellow-bg:#FFF5D6;
  --risk-orange:  #CC5500;
  --risk-orange-bg:#FFF0E4;
  --risk-red:     #B81520;
  --risk-red-bg:  #FFEBEC;

  --radius-sm:    6px;
  --radius-md:    12px;
  --radius-lg:    16px;
  --radius-xl:    20px;

  --shadow-sm:    0 1px 4px rgba(0,0,0,0.06);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.10);

  --sidebar-w:    220px;
  --font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-mono:    'SF Mono', 'Monaco', 'Cascadia Code', Consolas, monospace;
}

/* ─── Reset ─────────────────────────────────────────────────────────────────── */

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-1);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }
table { border-collapse: collapse; width: 100%; }

/* ─── Login Page ─────────────────────────────────────────────────────────────── */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #2D1530 0%, #4A2545 50%, #6B3460 100%);
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 24px 16px;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.logo-icon {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-light);
  border-radius: var(--radius-md);
}
.logo-icon.small { width: 36px; height: 36px; border-radius: var(--radius-sm); }

.logo-text { display: flex; flex-direction: column; }
.logo-name { font-size: 18px; font-weight: 700; color: var(--brand); letter-spacing: -0.3px; }
.logo-sub  { font-size: 12px; color: var(--text-3); margin-top: 1px; }

.login-title {
  font-size: 24px; font-weight: 700;
  color: var(--text-1); letter-spacing: -0.5px;
  margin-bottom: 8px;
}
.login-desc {
  font-size: 14px; color: var(--text-2);
  margin-bottom: 28px; line-height: 1.55;
}

.login-form { display: flex; flex-direction: column; gap: 20px; }

.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 13px; font-weight: 600;
  color: var(--text-1); letter-spacing: 0.1px;
}
.field-input {
  width: 100%; padding: 12px 14px;
  font-size: 15px; color: var(--text-1);
  background: var(--bg); border: 1.5px solid var(--divider);
  border-radius: var(--radius-md);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.field-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}
.code-input {
  font-family: var(--font-mono);
  font-size: 22px; letter-spacing: 4px;
  text-align: center; text-transform: uppercase;
}
.field-hint { font-size: 12px; color: var(--text-3); }

.login-footer {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--divider);
  font-size: 13px; color: var(--text-2); line-height: 1.6;
}

/* ─── Buttons ─────────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px;
  font-size: 14px; font-weight: 600;
  border-radius: var(--radius-md);
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--brand);
  color: #fff;
}
.btn-primary:hover { background: var(--brand-mid); }

.btn-secondary {
  background: var(--bg-alt);
  color: var(--brand); border: 1.5px solid var(--brand-border);
}
.btn-secondary:hover { background: var(--brand-tint); }

.btn-full { width: 100%; justify-content: center; }

.btn-icon { padding: 9px 14px; }

/* ─── Alerts ──────────────────────────────────────────────────────────────────── */

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px; line-height: 1.5;
}
.alert-error  { background: var(--risk-red-bg);    color: var(--risk-red);    border-left: 3px solid var(--risk-red); }
.alert-warn   { background: var(--risk-orange-bg); color: var(--risk-orange); border-left: 3px solid var(--risk-orange); }
.alert-success{ background: var(--risk-green-bg);  color: var(--risk-green);  border-left: 3px solid var(--risk-green); }

/* ─── App Layout ─────────────────────────────────────────────────────────────── */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--brand);
  display: flex; flex-direction: column;
  padding: 0;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 10;
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}
.sidebar-title {
  font-size: 16px; font-weight: 700; color: #fff; letter-spacing: -0.3px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex; flex-direction: column; gap: 4px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; color: rgba(255,255,255,0.70);
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover  { background: rgba(255,255,255,0.10); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.15); color: #fff; }

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.10);
}

.btn-logout {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; width: 100%;
  border-radius: var(--radius-sm);
  font-size: 14px; color: rgba(255,255,255,0.60);
  transition: background 0.15s, color 0.15s;
}
.btn-logout:hover { background: rgba(255,255,255,0.10); color: #fff; }

/* ─── Main Content ────────────────────────────────────────────────────────────── */

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 32px 36px;
  max-width: 1100px;
}

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 28px; gap: 16px;
}
.page-title   { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; color: var(--text-1); }
.page-subtitle{ font-size: 14px; color: var(--text-3); margin-top: 4px; }

/* ─── Patient Grid ────────────────────────────────────────────────────────────── */

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

.patient-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1.5px solid var(--divider);
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.1s;
  text-decoration: none; color: inherit;
}
.patient-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--brand-border);
  transform: translateY(-1px);
}

.patient-card-header {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 14px;
}

.patient-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-mid) 100%);
  color: #fff; font-size: 18px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.patient-avatar-lg {
  width: 56px; height: 56px; font-size: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-mid) 100%);
  color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.patient-name { font-size: 15px; font-weight: 600; color: var(--text-1); }
.patient-ssw  { font-size: 13px; color: var(--text-3); margin-top: 2px; }

.risk-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-left: auto;
}

.patient-card-body { display: flex; flex-direction: column; gap: 8px; }
.patient-stat { display: flex; justify-content: space-between; font-size: 13px; }
.stat-label { color: var(--text-3); }
.stat-value { font-weight: 500; color: var(--text-1); }

.risk-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 99px;
  font-size: 12px; font-weight: 600;
}

/* ─── Risk Colors ─────────────────────────────────────────────────────────────── */

.risk-green  { color: var(--risk-green);  background: var(--risk-green-bg); }
.risk-yellow { color: var(--risk-yellow); background: var(--risk-yellow-bg); }
.risk-orange { color: var(--risk-orange); background: var(--risk-orange-bg); }
.risk-red    { color: var(--risk-red);    background: var(--risk-red-bg); }

.dot-green  { background: var(--risk-green); }
.dot-yellow { background: var(--risk-yellow); }
.dot-orange { background: var(--risk-orange); }
.dot-red    { background: var(--risk-red); }

/* ─── Patient Detail Header ───────────────────────────────────────────────────── */

.patient-header {
  margin-bottom: 28px;
}
.patient-info-header {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 20px;
}
.patient-meta {
  font-size: 13px; color: var(--text-3);
  display: flex; gap: 12px; margin-top: 4px;
}
.risk-badge-lg {
  margin-left: auto;
  font-size: 14px; font-weight: 600;
  padding: 6px 14px; border-radius: 99px;
}

.range-filter {
  display: flex; gap: 8px;
}
.range-btn {
  padding: 7px 14px;
  font-size: 13px; font-weight: 500;
  border-radius: var(--radius-sm);
  color: var(--text-2); background: var(--surface);
  border: 1.5px solid var(--divider);
  transition: all 0.15s;
}
.range-btn:hover  { border-color: var(--brand-border); color: var(--brand); }
.range-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ─── Vital Cards ─────────────────────────────────────────────────────────────── */

.vitals-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

.vital-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  border: 1.5px solid var(--divider);
  min-width: 0;
}
.vital-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.vital-label       { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vital-badge       { font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 99px; flex-shrink: 0; margin-left: 4px; }
.vital-value       { font-size: 22px; font-weight: 700; color: var(--text-1); letter-spacing: -0.5px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vital-sub         { font-size: 11px; color: var(--text-3); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vital-trend       { font-size: 11px; margin-top: 4px; font-weight: 500; }

/* ─── Chart Sections ──────────────────────────────────────────────────────────── */

.chart-section { margin-bottom: 28px; }
.section-header { margin-bottom: 12px; }
.section-title { font-size: 17px; font-weight: 700; color: var(--text-1); }
.section-hint  { font-size: 12px; color: var(--text-3); margin-top: 3px; }

.chart-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1.5px solid var(--divider);
}

/* ─── Urine Table ─────────────────────────────────────────────────────────────── */

.table-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1.5px solid var(--divider);
}

.urine-table th {
  background: var(--bg-alt);
  font-size: 12px; font-weight: 600;
  color: var(--text-3); text-transform: uppercase; letter-spacing: 0.4px;
  padding: 10px 14px; text-align: left;
  border-bottom: 1.5px solid var(--divider);
}
.urine-table td {
  padding: 10px 14px; font-size: 13px; color: var(--text-1);
  border-bottom: 1px solid var(--divider);
}
.urine-table tr:last-child td { border-bottom: none; }
.urine-table tr:hover td { background: var(--bg); }

.col-protein { font-weight: 700; color: var(--text-1) !important; }

.table-empty {
  text-align: center; color: var(--text-3);
  padding: 32px !important;
}

.cell-risk { font-weight: 600; padding: 2px 6px; border-radius: 4px; }

/* ─── Wellbeing List ──────────────────────────────────────────────────────────── */

.wellbeing-list { display: flex; flex-direction: column; gap: 10px; }

.wellbeing-entry {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  border: 1.5px solid var(--divider);
  box-shadow: var(--shadow-sm);
}
.wellbeing-entry.risk-orange { border-left: 3px solid var(--risk-orange); }
.wellbeing-entry.risk-red    { border-left: 3px solid var(--risk-red); }
.wellbeing-entry.risk-yellow { border-left: 3px solid var(--risk-yellow); }

.we-header { display: flex; justify-content: space-between; margin-bottom: 8px; align-items: center; }
.we-date   { font-size: 12px; color: var(--text-3); }
.we-chips  { display: flex; flex-wrap: wrap; gap: 6px; }
.we-chip {
  font-size: 12px; padding: 3px 8px;
  background: var(--bg-alt); border-radius: 99px; color: var(--text-2);
}
.we-chip.emergency { background: var(--risk-orange-bg); color: var(--risk-orange); font-weight: 600; }
.we-notes  { font-size: 13px; color: var(--text-2); margin-top: 8px; font-style: italic; }

/* ─── States ─────────────────────────────────────────────────────────────────── */

.loading-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 80px 0; color: var(--text-3);
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--divider);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center; padding: 80px 0; color: var(--text-3);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 18px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }
.empty-state p  { font-size: 14px; }
.empty-hint     { font-size: 14px; color: var(--text-3); padding: 20px; text-align: center; }

/* ─── Utils ──────────────────────────────────────────────────────────────────── */

.hidden { display: none !important; }

/* ─── Chart Toggles ──────────────────────────────────────────────────────────── */

.chart-toggles {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 14px;
}

.toggle-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  font-size: 12px; font-weight: 600;
  border-radius: 99px;
  border: 1.5px solid var(--divider);
  background: var(--surface); color: var(--text-2);
  cursor: pointer; transition: all 0.15s;
}
.toggle-btn::before {
  content: '';
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--c, #888);
  opacity: 0.3;
  transition: opacity 0.15s;
}
.toggle-btn.active {
  border-color: var(--c, #888);
  color: var(--text-1);
}
.toggle-btn.active::before { opacity: 1; }
.toggle-btn:hover { border-color: var(--c, #888); }

/* ─── Chart Toggles ──────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 20px 16px; }
  .vitals-row { grid-template-columns: repeat(3, 1fr); }
  .range-filter { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .vitals-row { grid-template-columns: repeat(2, 1fr); }
  .login-card { padding: 28px 20px; }
}
