/* HospiceNote — Clinical Documentation Platform */
/* Design: Dark clinical — focused, professional, not sterile */

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

:root {
  --bg: #0f1117;
  --bg-surface: #161b27;
  --bg-card: #1c2232;
  --bg-hover: #222a3a;
  --border: #2a3347;
  --border-light: #1e2840;
  --text: #e8edf5;
  --text-muted: #6b7a99;
  --text-dim: #4a5568;
  --accent: #4f9cf9;
  --accent-dim: rgba(79,156,249,0.12);
  --green: #34d399;
  --green-dim: rgba(52,211,153,0.12);
  --amber: #fbbf24;
  --amber-dim: rgba(251,191,36,0.12);
  --red: #f87171;
  --red-dim: rgba(248,113,113,0.12);
  --purple: #a78bfa;
  --purple-dim: rgba(167,139,250,0.12);
  --teal: #2dd4bf;
  --sidebar-w: 220px;
  --radius: 8px;
  --radius-sm: 5px;
  font-family: 'Satoshi', system-ui, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Login ── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 30% 20%, rgba(79,156,249,0.08) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 80%, rgba(167,139,250,0.06) 0%, transparent 60%),
              var(--bg);
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo-icon {
  font-size: 32px;
  display: block;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 20px rgba(79,156,249,0.5));
}

.logo-icon-sm { font-size: 16px; }

.login-logo h1 {
  font-family: 'Instrument Serif', serif;
  font-size: 26px;
  color: var(--text);
  letter-spacing: -0.3px;
}

.login-logo p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

.demo-hint {
  margin-top: 20px;
  padding: 12px;
  background: var(--accent-dim);
  border: 1px solid rgba(79,156,249,0.2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

.demo-hint a { color: var(--accent); }

/* ── Layout ── */
#app { display: flex; height: 100vh; overflow: hidden; }
#main-app { display: flex; width: 100%; height: 100vh; }

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
}

.sidebar-header {
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-title {
  font-family: 'Instrument Serif', serif;
  font-size: 17px;
  color: var(--text);
  letter-spacing: -0.2px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s;
  position: relative;
}

.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-icon { font-size: 11px; opacity: 0.7; }

.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid var(--border);
}

.user-chip {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Content Area ── */
#content-area {
  flex: 1;
  overflow-y: auto;
  height: 100vh;
  background: var(--bg);
}

.view { padding: 28px 32px; }
.view.hidden { display: none; }
.view.active { display: block; }

.view-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.view-header h2 {
  font-family: 'Instrument Serif', serif;
  font-size: 22px;
  color: var(--text);
  font-weight: 400;
  flex: 1;
}

.subtitle { color: var(--text-muted); font-size: 12px; margin-left: 4px; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.date-label { color: var(--text-muted); font-size: 13px; }

/* ── Buttons ── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.88; }
.btn-primary.full-width { width: 100%; padding: 11px; font-size: 14px; margin-top: 8px; }

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-sign {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(52,211,153,0.3);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-sign:hover { background: var(--green); color: #000; }

.btn-ghost-sm {
  background: transparent;
  color: var(--text-dim);
  border: none;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  width: 100%;
}
.btn-ghost-sm:hover { color: var(--text-muted); }

.btn-back {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.btn-back:hover { color: var(--text); }

.ai-icon { color: var(--purple); }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.card-sm {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

/* ── Dashboard ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-card .stat-val {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 4px;
}
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); }
.stat-card.critical { border-color: rgba(248,113,113,0.4); background: rgba(248,113,113,0.04); }
.stat-card.critical .stat-val { color: var(--red); }
.stat-card.warning { border-color: rgba(251,191,36,0.3); background: rgba(251,191,36,0.04); }
.stat-card.warning .stat-val { color: var(--amber); }
.stat-card.ok { border-color: rgba(52,211,153,0.3); background: rgba(52,211,153,0.04); }
.stat-card.ok .stat-val { color: var(--green); }

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }

.dash-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.dash-panel-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.dash-panel-header h3 { font-size: 13.5px; font-weight: 600; color: var(--text); }
.dash-panel-body { padding: 8px 0; }

/* ── Alert Items ── */
.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.12s;
  cursor: pointer;
}
.alert-item:hover { background: var(--bg-hover); }
.alert-item:last-child { border-bottom: none; }
.alert-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
.alert-dot.critical { background: var(--red); box-shadow: 0 0 6px var(--red); }
.alert-dot.warning { background: var(--amber); }
.alert-dot.info { background: var(--accent); }
.alert-msg { font-size: 13px; color: var(--text); line-height: 1.4; }
.alert-patient { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.alert-ack-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Census Table ── */
.census-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.census-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}
.census-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}
.census-table tr:last-child td { border-bottom: none; }
.census-table tr:hover td { background: var(--bg-hover); cursor: pointer; }
.patient-name { font-weight: 600; color: var(--text); }
.patient-diag { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

/* ── Cert Expiry Badges ── */
.cert-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}
.cert-badge.critical { background: var(--red-dim); color: var(--red); border: 1px solid rgba(248,113,113,0.3); }
.cert-badge.warning { background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(251,191,36,0.3); }
.cert-badge.ok { background: var(--green-dim); color: var(--green); border: 1px solid rgba(52,211,153,0.25); }
.cert-badge.overdue { background: var(--red-dim); color: var(--red); border: 1px solid rgba(248,113,113,0.5); animation: pulse 2s infinite; }

@keyframes pulse {
  0%,100% { opacity: 1; } 50% { opacity: 0.6; }
}

.setting-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}
.setting-badge.home { background: var(--accent-dim); color: var(--accent); }
.setting-badge.facility { background: var(--purple-dim); color: var(--purple); }

.wound-flag { color: var(--amber); font-size: 12px; }
.infection-flag { color: var(--red); font-size: 12px; }

/* ── Patient Detail ── */
.patient-detail-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
}
@media (max-width: 860px) { .patient-detail-grid { grid-template-columns: 1fr; } }

.patient-sidebar { display: flex; flex-direction: column; gap: 14px; }
.patient-main { display: flex; flex-direction: column; gap: 16px; }

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text-muted); font-size: 12px; }
.info-val { color: var(--text); font-weight: 500; text-align: right; max-width: 160px; word-break: break-word; }

.score-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.score-chip {
  padding: 4px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-muted);
}
.score-chip strong { color: var(--text); }

/* ── Note Templates ── */
.note-template {
  max-width: 860px;
}

.template-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}
.template-section-header {
  padding: 12px 18px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.template-section-header h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.template-section-header .section-num {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--border);
  padding: 2px 7px;
  border-radius: 10px;
}
.template-section-body { padding: 16px 18px; }

.form-row { display: flex; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.form-row .field-group { flex: 1; min-width: 160px; }

.field-group { margin-bottom: 12px; }
.field-group label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 5px; font-weight: 500; }

input[type="text"], input[type="email"], input[type="password"],
input[type="date"], input[type="number"], select, textarea {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
select option { background: var(--bg-card); }
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

/* ── AI Draft Panel ── */
.ai-draft-panel {
  background: linear-gradient(135deg, rgba(167,139,250,0.06) 0%, rgba(79,156,249,0.04) 100%);
  border: 1px solid rgba(167,139,250,0.25);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.ai-draft-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.ai-draft-header h4 { font-size: 13px; color: var(--purple); font-weight: 600; }
.ai-draft-header .ai-badge {
  font-size: 10px;
  background: var(--purple-dim);
  color: var(--purple);
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid rgba(167,139,250,0.3);
}

.ai-section { margin-bottom: 14px; }
.ai-section h5 { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.ai-text { font-size: 13px; color: var(--text); line-height: 1.6; }
.ai-bullet { font-size: 13px; color: var(--text); padding: 3px 0; padding-left: 16px; position: relative; line-height: 1.5; }
.ai-bullet::before { content: '•'; position: absolute; left: 4px; color: var(--purple); }

.ai-loading { text-align: center; padding: 32px; color: var(--text-muted); }
.ai-spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Voice Input ── */
.voice-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: all 0.15s;
}
.voice-btn:hover { border-color: var(--red); color: var(--red); }
.voice-btn.recording { border-color: var(--red); color: var(--red); animation: pulse 1.2s infinite; }
.voice-icon { font-size: 16px; }

/* ── Compliance Table ── */
.compliance-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.compliance-table th {
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.compliance-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  vertical-align: middle;
}
.compliance-table tr:last-child td { border-bottom: none; }

.check-icon { color: var(--green); font-size: 14px; }
.x-icon { color: var(--red); font-size: 14px; }
.pending-icon { color: var(--amber); font-size: 14px; }

/* ── Wound Timeline ── */
.wound-timeline { display: flex; flex-direction: column; gap: 8px; }
.wound-entry {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 14px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border-left: 3px solid;
}
.wound-entry.I { border-color: var(--amber); }
.wound-entry.II { border-color: #f97316; }
.wound-entry.III { border-color: var(--red); }
.wound-entry.IV { border-color: #7f1d1d; }
.wound-entry.healed { border-color: var(--green); }
.wound-date { font-size: 11px; color: var(--text-muted); white-space: nowrap; min-width: 80px; margin-top: 1px; }
.wound-info h5 { font-size: 13px; color: var(--text); font-weight: 600; }
.wound-info p { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Notes List ── */
.notes-list { display: flex; flex-direction: column; gap: 8px; }
.note-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.note-item:hover { border-color: var(--accent); }
.note-type-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.note-type-badge.physician_recert { background: var(--accent-dim); color: var(--accent); }
.note-type-badge.np_face_to_face { background: var(--purple-dim); color: var(--purple); }
.note-type-badge.rn_admission { background: var(--green-dim); color: var(--green); }
.note-type-badge.rn_visit { background: rgba(45,212,191,0.12); color: var(--teal); }
.note-type-badge.comm_log { background: rgba(251,191,36,0.1); color: var(--amber); }
.note-status { font-size: 11px; font-weight: 600; }
.note-status.signed { color: var(--green); }
.note-status.draft { color: var(--amber); }
.note-info { flex: 1; }
.note-info strong { font-size: 13.5px; color: var(--text); }
.note-info span { font-size: 12px; color: var(--text-muted); display: block; margin-top: 2px; }

/* ── Filters ── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-bar select { width: auto; padding: 6px 10px; font-size: 12.5px; }
.toggle-filter {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  transition: all 0.15s;
}
.toggle-filter:hover { border-color: var(--accent); color: var(--text); }
.toggle-filter input { cursor: pointer; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: min(560px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal-title { font-family: 'Instrument Serif', serif; font-size: 20px; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── Utilities ── */
.hidden { display: none !important; }
.badge {
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
  margin-left: auto;
}
.empty-state { text-align: center; padding: 40px; color: var(--text-muted); font-size: 14px; }
.error-msg { color: var(--red); font-size: 13px; margin-top: 8px; padding: 8px; background: var(--red-dim); border-radius: 4px; }
.section-title { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 11px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  margin: 2px;
}
