/* ============================================================
   ElderHub — Global Stylesheet
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Afacad:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

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

:root {
  --bg:        #07090f;
  --surface:   #0d1117;
  --card:      #111823;
  --border:    #1c2d45;
  --accent:    #00b8d4;
  --accent-dim:#003d4d;
  --green:     #00c853;
  --amber:     #ffab00;
  --red:       #ff1744;
  --purple:    #9c27b0;
  --text:      #dce8f5;
  --muted:     #4a637a;
  --white:     #ffffff;
  --sidebar-w: 220px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Afacad', sans-serif;
  min-height: 100vh;
}

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

/* ── Layout ──────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-logo {
  padding: 24px 18px 18px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo h1 {
  font-family: 'Afacad', sans-serif;
  font-size: 22px;
  color: var(--accent);
}
.sidebar-logo span { font-size: 11px; color: var(--muted); }

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  text-decoration: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  transition: all .18s;
  position: relative;
}
.nav-link:hover { background: var(--accent-dim); color: var(--accent); }
.nav-link.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.nav-link .nav-icon { font-size: 15px; }
.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.sidebar-footer .user-name { font-size: 12px; color: var(--text); font-weight: 600; }
.sidebar-footer .user-role {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .6px;
  margin-bottom: 10px;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 28px 30px 40px;
  min-height: 100vh;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  animation: fadeIn .3s ease;
}
.card-danger { border-color: rgba(255,23,68,.4); background: rgba(255,23,68,.04); }
.card-success { border-color: rgba(0,200,83,.3); }

/* ── Page Header ─────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}
.page-header h2 {
  font-family: 'Afacad', sans-serif;
  font-size: 26px;
  color: var(--white);
}
.page-header p { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
}
.btn:hover { background: var(--accent); color: var(--bg); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-green { border-color: var(--green); background: rgba(0,200,83,.12); color: var(--green); }
.btn-green:hover { background: var(--green); color: var(--bg); }
.btn-amber { border-color: var(--amber); background: rgba(255,171,0,.12); color: var(--amber); }
.btn-amber:hover { background: var(--amber); color: var(--bg); }
.btn-red { border-color: var(--red); background: rgba(255,23,68,.12); color: var(--red); }
.btn-red:hover { background: var(--red); color: var(--white); }
.btn-muted { border-color: var(--border); background: transparent; color: var(--muted); }
.btn-muted:hover { background: var(--border); color: var(--text); }
.btn-danger { border-color: var(--red); background: var(--red); color: var(--white); }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
}
.badge-green  { background: rgba(0,200,83,.15);  color: var(--green);  border: 1px solid rgba(0,200,83,.3); }
.badge-amber  { background: rgba(255,171,0,.15); color: var(--amber);  border: 1px solid rgba(255,171,0,.3); }
.badge-red    { background: rgba(255,23,68,.15);  color: var(--red);    border: 1px solid rgba(255,23,68,.3); }
.badge-accent { background: rgba(0,184,212,.15); color: var(--accent); border: 1px solid rgba(0,184,212,.3); }
.badge-purple { background: rgba(156,39,176,.15);color: var(--purple); border: 1px solid rgba(156,39,176,.3); }
.badge-muted  { background: rgba(74,99,122,.15); color: var(--muted);  border: 1px solid rgba(74,99,122,.3); }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-label {
  font-size: 11px; color: var(--muted);
  font-weight: 600; text-transform: uppercase; letter-spacing: .6px;
}
.form-control {
  padding: 10px 14px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
  width: 100%;
}
.form-control:focus { border-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-grid .full { grid-column: 1 / -1; }

/* ── Stats Grid ──────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 22px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 18px; text-align: center; }
.stat-value { font-size: 32px; font-weight: 700; margin-bottom: 4px; }
.stat-label { font-size: 12px; color: var(--muted); }

/* ── Table ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 10px 14px; color: var(--muted); font-weight: 600; text-align: left; border-bottom: 1px solid var(--border); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
td { padding: 12px 14px; border-bottom: 1px solid rgba(28,45,69,.5); color: var(--text); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(0,184,212,.04); }

/* ── Vital Chips ─────────────────────────────────────────── */
.vitals-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-top: 14px; }
.vital-chip {
  background: var(--accent-dim);
  border: 1px solid rgba(0,184,212,.2);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
}
.vital-chip.warn { background: rgba(255,23,68,.12); border-color: rgba(255,23,68,.3); }
.vital-label { font-size: 10px; color: var(--muted); margin-bottom: 4px; }
.vital-value { font-size: 20px; font-weight: 700; color: var(--accent); }
.vital-chip.warn .vital-value { color: var(--red); }
.vital-unit { font-size: 10px; color: var(--muted); margin-left: 2px; }

/* ── Avatar ──────────────────────────────────────────────── */
.avatar {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  width: 520px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  animation: fadeIn .2s ease;
}
.modal-header {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 20px;
}
.modal-header h3 {
  font-family: 'Afacad', sans-serif;
  font-size: 20px; color: var(--white);
}
.modal-close {
  background: none; border: none;
  color: var(--muted); font-size: 22px;
  cursor: pointer; line-height: 1;
}
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }

/* ── Alert banner ────────────────────────────────────────── */
.alert-banner {
  padding: 10px 16px;
  border-radius: 9px;
  margin-bottom: 14px;
  font-size: 13px;
}
.alert-banner.success { background: rgba(0,200,83,.12); color: var(--green); border: 1px solid rgba(0,200,83,.3); }
.alert-banner.error   { background: rgba(255,23,68,.12); color: var(--red);   border: 1px solid rgba(255,23,68,.3); }

/* ── Patient list ────────────────────────────────────────── */
.patient-list { display: flex; flex-direction: column; gap: 10px; }
.patient-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: border-color .18s;
  text-decoration: none;
  display: block;
  color: inherit;
}
.patient-item:hover, .patient-item.active { border-color: var(--accent); background: var(--accent-dim); }
.patient-row { display: flex; gap: 12px; align-items: center; }

/* ── SOS pulse ───────────────────────────────────────────── */
.sos-btn {
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--red);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
  animation: pulseRing 2s infinite;
}

/* ── AI chat ─────────────────────────────────────────────── */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 200px); }
.chat-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding-right: 4px; }
.chat-msg { display: flex; gap: 10px; align-items: flex-start; animation: fadeIn .25s ease; }
.chat-msg.user { flex-direction: row-reverse; }
.chat-avatar {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.chat-bubble {
  max-width: 72%; padding: 11px 15px; border-radius: 12px;
  font-size: 13px; line-height: 1.65; white-space: pre-wrap;
  border: 1px solid var(--border);
  background: var(--card); color: var(--text);
  border-top-left-radius: 4px;
}
.chat-msg.user .chat-bubble {
  background: var(--accent-dim);
  border-color: rgba(0,184,212,.3);
  border-top-left-radius: 12px;
  border-top-right-radius: 4px;
}
.chat-input-row { display: flex; gap: 10px; margin-top: 14px; }
.chat-input {
  flex: 1; padding: 12px 16px; border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card); color: var(--text);
  font-size: 13px; font-family: inherit; outline: none;
}
.typing-dots { display: flex; gap: 5px; padding: 4px 0; }
.typing-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  animation: blink 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }

/* ── Login ───────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-box { width: 380px; animation: fadeIn .4s ease; }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo h1 { font-family: 'Afacad', sans-serif; font-size: 38px; color: var(--accent); }
.login-logo p { color: var(--muted); font-size: 14px; margin-top: 6px; }
.login-footer { text-align: center; margin-top: 18px; color: var(--muted); font-size: 12px; }

/* ── Utility ─────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.gap-14 { gap: 14px; }
.gap-20 { gap: 20px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.text-muted { color: var(--muted); }
.text-white { color: var(--white); }
.text-accent { color: var(--accent); }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.text-amber { color: var(--amber); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-bold { font-weight: 700; }
.font-semi { font-weight: 600; }
.serif { font-family: 'Afacad', sans-serif; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.w-full { width: 100%; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin .7s linear infinite;
  margin: 60px auto;
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
@keyframes spin   { to{transform:rotate(360deg)} }
@keyframes blink  { 0%,100%{opacity:1} 50%{opacity:.3} }
@keyframes pulseRing { 0%,100%{box-shadow:0 0 0 0 rgba(255,23,68,.5)} 50%{box-shadow:0 0 0 14px rgba(255,23,68,0)} }
