/* ============================================================
   CarePoint — Split-Screen Healthcare Navigation UI
   ============================================================ */

:root {
  --bg: #0f1117;
  --surface: #1a1b23;
  --surface-2: #22232d;
  --border: #2d2e3a;
  --text: #e4e4e7;
  --text-muted: #71717a;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
  --info: #06b6d4;
  --purple: #a855f7;
  --radius: 8px;
  --radius-lg: 12px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---- Top Bar ---- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 48px;
  flex-shrink: 0;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.logo { font-size: 18px; font-weight: 700; color: var(--primary); }
.tagline { font-size: 12px; color: var(--text-muted); }

.badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-mock { background: var(--warning); color: #000; }
.badge-live { background: var(--success); color: #000; animation: pulse 2s infinite; }

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

.demo-controls { display: flex; gap: 6px; align-items: center; }

.select-sm {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 8px;
  border-radius: var(--radius);
  font-size: 12px;
}

.btn {
  padding: 6px 14px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--text);
  transition: background 0.15s;
}
.btn:hover { background: var(--border); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ---- Split Screen ---- */

.split-screen {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-chat {
  flex: 1;
  border-right: 1px solid var(--border);
  min-width: 0;
}

.panel-dashboard {
  width: 400px;
  flex-shrink: 0;
  background: var(--surface);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.panel-header h2 { font-size: 14px; font-weight: 600; }

/* ---- Chat ---- */

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-welcome {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.welcome-icon {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 24px;
  font-weight: 700;
}
.chat-welcome h3 { color: var(--text); margin-bottom: 8px; }

.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.5;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.bubble-patient {
  background: var(--primary);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.bubble-carepoint {
  background: var(--surface-2);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
}

.bubble-system {
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  align-self: center;
  padding: 4px 12px;
}

.bubble-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.facility-card-inline {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}
.facility-card-inline .fc-name { font-weight: 600; color: var(--success); }
.facility-card-inline .fc-detail { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

/* ---- Chat Input ---- */

.chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

#chat-form {
  display: flex;
  gap: 8px;
}

#chat-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
#chat-input:focus { border-color: var(--primary); }

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.typing-indicator span {
  width: 6px; height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingDot 1.4s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

.patient-selector select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 8px;
  border-radius: var(--radius);
  font-size: 12px;
}

/* ---- Dashboard ---- */

.dashboard-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
}
.card h3 {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

/* Decision Card */
.card-decision { border-color: var(--primary); }

.decision-destination {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.confidence-meter {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  margin-bottom: 4px;
}
.confidence-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease, background 0.3s;
}
.confidence-label {
  font-size: 12px;
  color: var(--text-muted);
}

.decision-facility {
  margin-top: 8px;
  font-size: 13px;
}
.decision-reasoning {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}
.decision-alternatives {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Sentiment */
.sentiment-display {
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Facility Grid */
.facility-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.facility-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 12px;
}

.facility-name {
  flex: 1;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 8px;
}

.facility-load-bar {
  width: 60px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-right: 8px;
}
.facility-load-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.facility-wait {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 45px;
  text-align: right;
}

.load-low { background: var(--success); }
.load-med { background: var(--warning); }
.load-high { background: var(--danger); }

/* Session Feed */
.session-feed {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.session-item {
  padding: 6px 8px;
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.session-complaint {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 8px;
}
.session-dest {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}
.dest-er { background: var(--danger); color: #fff; }
.dest-urgent_care { background: var(--warning); color: #000; }
.dest-clinic { background: var(--success); color: #000; }
.dest-virtual { background: var(--info); color: #000; }
.dest-pharmacy { background: var(--purple); color: #fff; }
.dest-mental_health_crisis { background: #ec4899; color: #fff; }
.dest-self_care { background: var(--border); color: var(--text); }

/* Stats */
.stats-row {
  display: flex;
  gap: 12px;
}
.stat {
  flex: 1;
  text-align: center;
}
.stat-value {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}
.stat-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* ---- Animations ---- */

/* Decision card slide-in */
.card-enter {
  animation: cardSlideIn 0.4s ease-out;
}
@keyframes cardSlideIn {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Smooth load bar transitions */
.facility-load-fill {
  transition: width 0.6s ease-in-out, background-color 0.3s ease;
}

/* Reroute notification */
.reroute-notification {
  background: linear-gradient(135deg, #1e3a5f 0%, #0f2647 100%);
  border: 1px solid var(--primary);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 12px;
  animation: rerouteSlideIn 0.5s ease-out;
}
.reroute-header {
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
  font-size: 13px;
}
.reroute-body {
  font-size: 12px;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.5;
}
.reroute-actions {
  display: flex;
  gap: 8px;
}
@keyframes rerouteSlideIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}
.reroute-exit {
  animation: rerouteSlideOut 0.3s ease-in forwards;
}
@keyframes rerouteSlideOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(30px); }
}

/* ---- Utilities ---- */
.text-muted { color: var(--text-muted); }
.loading { color: var(--text-muted); font-size: 13px; text-align: center; padding: 20px; }

/* ---- Accessibility ---- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; top: -40px; left: 0; background: var(--primary); color: #fff; padding: 8px 16px; z-index: 200; font-size: 14px; text-decoration: none; border-radius: 0 0 8px 0; }
.skip-link:focus { top: 0; }

/* ---- Journey Comparison ---- */
.card-journey { border-color: var(--primary); }
.journey-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.journey-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; color: var(--text-muted); }
.journey-before .journey-label { color: var(--danger); }
.journey-after .journey-label { color: var(--success); }
.journey-step { font-size: 12px; padding: 4px 8px; margin: 3px 0; border-radius: 4px; background: var(--surface-2); }
.journey-step.bad { background: #ef444420; color: #fca5a5; }
.journey-step.good { background: #22c55e15; color: #86efac; }
.journey-time { font-size: 13px; font-weight: 700; margin-top: 8px; padding: 6px 8px; border-radius: 6px; text-align: center; }
.journey-before .journey-time { background: #ef444430; color: var(--danger); }
.journey-after .journey-time { background: #22c55e20; color: var(--success); }

/* ---- Impact Card ---- */
.card-impact { border-color: var(--success); background: #22c55e10; }
.card-impact h3 { color: var(--success); }
.impact-stat { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.impact-stat:last-child { border-bottom: none; }
.impact-stat-label { color: var(--text-muted); }
.impact-stat-value { font-weight: 700; color: var(--success); }
.impact-highlight { font-size: 22px; font-weight: 700; color: var(--success); text-align: center; padding: 12px 0; }

/* ---- Language Toggle ---- */
.lang-toggle {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 8px;
  border-radius: var(--radius);
  font-size: 11px;
  margin-left: 6px;
}

/* ---- Translated bubble ---- */
.bubble-translated {
  background: var(--surface-2);
  border: 1px solid #a855f7;
  color: var(--text);
  font-style: italic;
}
.bubble-lang-label { font-size: 10px; color: #a855f7; font-weight: 600; margin-bottom: 4px; }

/* ---- Call Transcription Modal ---- */
.call-modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: stretch; justify-content: center;
  padding: 40px 20px;
  animation: fadeIn 0.3s ease;
}
.call-modal-inner {
  display: flex; width: 100%; max-width: 1000px;
  background: var(--surface); border-radius: 12px;
  overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.call-col { display: flex; flex-direction: column; overflow: hidden; }
.call-transcript-col { flex: 1; border-right: 1px solid var(--border); }
.call-suggest-col { width: 340px; background: var(--surface-2); }
.call-col-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.call-col-header h3 { font-size: 14px; font-weight: 600; }

.transcript-lines {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.transcript-line {
  font-size: 13px; line-height: 1.5; padding: 6px 10px;
  border-radius: 8px; animation: fadeIn 0.2s ease;
}
.tl-patient { background: #3b82f620; border-left: 3px solid var(--primary); }
.tl-attendant { background: #22c55e15; border-left: 3px solid var(--success); }
.tl-system { background: transparent; color: var(--text-muted); font-size: 12px; font-style: italic; text-align: center; }
.tl-interim { color: var(--text-muted); font-style: italic; }
.tl-speaker { font-weight: 700; font-size: 11px; text-transform: uppercase; color: var(--text-muted); margin-right: 6px; }

.transcript-controls {
  padding: 10px 12px; border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}

.recording-status {
  font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 10px;
}
.rs-recording { color: #ef4444; background: #ef444420; }
.rs-demo { color: var(--primary); background: #3b82f620; }
.rs-stopped { color: var(--text-muted); }
.rs-error { color: #eab308; background: #eab30820; }

/* ---- Quick Response Buttons ---- */
.quick-responses { display: flex; flex-wrap: wrap; gap: 4px; }
.quick-btn {
  padding: 4px 10px; font-size: 11px; font-weight: 500;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 14px; color: var(--text-muted); cursor: pointer;
  transition: all 0.15s;
}
.quick-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- AI Suggestions Panel ---- */
.suggestions-panel {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.suggest-card {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 10px; border-radius: 8px;
  background: var(--surface); font-size: 12px; line-height: 1.5;
  animation: fadeIn 0.3s ease;
}
.suggest-icon { flex-shrink: 0; font-size: 14px; margin-top: 1px; }
.suggest-text { flex: 1; }
.suggest-ask { border-left-color: var(--primary) !important; }
.suggest-info { border-left-color: var(--info) !important; }
.suggest-route { padding: 8px 10px; font-size: 12px; color: var(--success); font-weight: 600; background: #22c55e10; border-radius: 8px; text-align: center; }
.suggest-escalate { border-left-color: var(--danger) !important; background: #ef444410; }
.suggest-alert {
  padding: 8px 12px; background: var(--danger); color: #fff;
  border-radius: 8px; font-size: 12px; font-weight: 700;
  text-align: center; animation: pulse 1s infinite;
}
.suggest-empty { text-align: center; color: var(--text-muted); font-size: 12px; padding: 30px 10px; }

@media (max-width: 768px) {
  .split-screen { flex-direction: column; }
  .panel-dashboard { width: 100%; height: 50vh; border-top: 1px solid var(--border); }
  .panel-chat { border-right: none; }
}
