/* ═══════════════════════════════════════════════════════════════
   chatbot.css — Clinical Clarity Design System
   Matches Surekha Hospital Landing Page Theme
   Palette: Healing Deep Blue (#00478d) · Trust Teal (#006a6a) · Clean Slate (#f8f9fa)
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── CSS Variables ──────────────────────────────────────────────── */
:root {
  --primary:            #00478d;
  --primary-container:  #005eb8;
  --primary-hover:      #003870;
  --on-primary:         #ffffff;
  
  --secondary:          #006a6a;
  --secondary-container:#8cf3f3;
  --on-secondary-c:     #007070;
  
  --error:              #ba1a1a;
  --on-error:           #ffffff;

  --bg-body:            #f8f9fa;
  --bg-surface:         #ffffff;
  --bg-card:            #ffffff;
  --bg-card-subtle:     #f3f4f5;
  --border-light:       #e2e8f0;
  --border-focus:       #00478d;

  --text-primary:       #191c1d;
  --text-secondary:     #424752;
  --text-muted:         #727783;

  --user-bubble:        linear-gradient(135deg, #00478d 0%, #005eb8 100%);
  --agent-bubble:       #f8f9fa;
  --agent-border:       #e2e8f0;

  --radius-sm:          6px;
  --radius-md:          10px;
  --radius-lg:          14px;
  --radius-xl:          18px;
  --radius-full:        9999px;

  --shadow-sm:          0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-card:        0 4px 16px rgba(0, 0, 0, 0.04);
  --shadow-lg:          0 10px 30px rgba(0, 0, 0, 0.07);

  --font-main:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:          'JetBrains Mono', 'Fira Code', monospace;
  --transition:         all 0.2s ease-in-out;
}

/* ── Dark Theme Overrides ──────────────────────────────────────── */
body.dark-theme {
  --bg-body:            #0b1120;
  --bg-surface:         #0f172a;
  --bg-card:            #1e293b;
  --bg-card-subtle:     #172236;
  --border-light:       #334155;
  --border-focus:       #38bdf8;

  --text-primary:       #f8fafc;
  --text-secondary:     #cbd5e1;
  --text-muted:         #94a3b8;

  --user-bubble:        linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  --agent-bubble:       #1e293b;
  --agent-border:       #334155;
}

/* ── Reset & Base ───────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-main);
  background-color: var(--bg-body);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Material Symbols & Icons ───────────────────────────────────── */
.material-symbols-outlined, .material-icons {
  font-family: 'Material Symbols Outlined', 'Material Icons', sans-serif !important;
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'liga';
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.material-symbols-outlined.fill-icon {
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* ── TopAppBar Matching Landing Page ────────────────────────────── */
.hospital-top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  width: 100%;
  height: 70px;
}

.top-nav-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.top-nav-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--primary);
  font-weight: 700;
  font-size: 1.25rem;
  transition: var(--transition);
}
.top-nav-brand:hover {
  opacity: 0.85;
}

.top-brand-icon {
  font-size: 26px;
  color: var(--primary);
}

.top-brand-text {
  letter-spacing: -0.01em;
}

.top-nav-links {
  display: none;
  align-items: center;
  gap: 2rem;
}
@media (min-width: 768px) {
  .top-nav-links {
    display: flex;
  }
}

.nav-link {
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
  padding: 0.25rem 0;
}
.nav-link:hover {
  color: var(--primary);
}
.nav-link.active {
  color: var(--primary);
  font-weight: 600;
  border-bottom: 2px solid var(--primary);
}

.btn-emergency {
  background-color: var(--error);
  color: var(--on-error);
  border: none;
  border-radius: var(--radius-full);
  padding: 0.5rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: var(--transition);
}
.btn-emergency:hover {
  background-color: #93000a;
  transform: translateY(-1px);
}

/* ── Main Chat Shell ────────────────────────────────────────────── */
.chat-shell {
  max-width: 1280px;
  margin: 0 auto;
  height: calc(100vh - 70px);
  display: flex;
  gap: 1.25rem;
  padding: 1.25rem 1.5rem;
}

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
  width: 290px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  overflow-y: auto;
}

.sidebar-brand {
  display: none; /* Replaced by global TopAppBar */
}

/* Status Card */
.status-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}
.status-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}
.status-row:last-child {
  margin-bottom: 0;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #16a34a;
  flex-shrink: 0;
}
.status-dot.checking {
  background: #ea580c;
  animation: pulse-dot 1s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

/* Session Info Card */
.session-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}
.session-card h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 0.75rem;
}
.session-info-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  margin-bottom: 0.4rem;
  color: var(--text-secondary);
}
.session-info-row span:last-child {
  color: var(--primary);
  font-weight: 600;
  font-family: var(--font-mono);
}

.btn-clear {
  width: 100%;
  margin-top: 0.85rem;
  padding: 0.6rem 1rem;
  background-color: #fee2e2;
  border: 1px solid #fecaca;
  color: var(--error);
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
}
.btn-clear:hover {
  background-color: #fecaca;
}

/* Quick Tips Card */
.tips-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.tips-card h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 0.35rem;
}
.tip-chip {
  display: block;
  background-color: var(--bg-body);
  border: 1px solid var(--border-light);
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}
.tip-chip:hover {
  background-color: #e0f2fe;
  border-color: #bae6fd;
  transform: translateX(2px);
}

/* ── Main Chat Panel ────────────────────────────────────────────── */
.chat-main {
  flex: 1;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Chat Header */
.chat-header {
  padding: 1rem 1.5rem;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-header-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.agent-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #00478d 0%, #005eb8 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  box-shadow: 0 4px 10px rgba(0, 71, 141, 0.2);
}
.agent-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.agent-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background-color: #dcfce7;
  color: #15803d;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-full);
}
.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #16a34a;
}

/* ── Messages Area ──────────────────────────────────────────────── */
.messages-area {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  background-color: var(--bg-body);
}

.welcome-banner {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  max-width: 600px;
  margin: 2rem auto;
}
.welcome-icon {
  font-size: 2.2rem;
  margin-bottom: 0.5rem;
  display: inline-block;
}
.welcome-banner h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.5rem;
}
.welcome-banner p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Chat Message Bubbles */
.message-row {
  display: flex;
  gap: 0.75rem;
  max-width: 80%;
  animation: fadeIn 0.25s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.message-row.bot {
  align-self: flex-start;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.message-row.user .msg-avatar {
  background-color: var(--primary);
  color: #ffffff;
}
.message-row.bot .msg-avatar {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--primary);
}

.msg-bubble {
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-lg);
  font-size: 0.92rem;
  line-height: 1.55;
  box-shadow: var(--shadow-sm);
}
.message-row.user .msg-bubble {
  background: var(--user-bubble);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}
.message-row.bot .msg-bubble {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.msg-bubble p {
  margin-bottom: 0.6rem;
}
.msg-bubble p:last-child {
  margin-bottom: 0;
}
.msg-bubble strong {
  font-weight: 600;
  color: inherit;
}
.msg-bubble ul, .msg-bubble ol {
  margin-left: 1.25rem;
  margin-bottom: 0.6rem;
}
.msg-bubble li {
  margin-bottom: 0.25rem;
}

.msg-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  display: flex;
  gap: 0.5rem;
}
.message-row.user .msg-meta {
  justify-content: flex-end;
  color: rgba(255, 255, 255, 0.7);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 0.6rem 0.9rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: fit-content;
}
.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Stats Footer */
.stats-footer {
  padding: 0.45rem 1.5rem;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ── Input Area ─────────────────────────────────────────────────── */
.chat-input-area {
  padding: 0.85rem 1.25rem 1rem;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-light);
}
.input-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background-color: var(--bg-body);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-full);
  padding: 0.35rem 0.6rem 0.35rem 1.25rem;
  transition: var(--transition);
}
.input-row:focus-within {
  border-color: var(--primary);
  background-color: var(--bg-surface);
  box-shadow: 0 0 0 3px rgba(0, 71, 141, 0.1);
}

#chat-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-main);
  font-size: 0.92rem;
  color: var(--text-primary);
  outline: none;
  resize: none;
  line-height: 1.4;
  max-height: 100px;
  padding: 0.35rem 0;
}
#chat-input::placeholder {
  color: var(--text-muted);
}

.btn-send {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background-color: var(--primary);
  color: var(--on-primary);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}
.btn-send:hover {
  background-color: var(--primary-container);
  transform: scale(1.05);
}

.input-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.4rem;
}

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .chat-shell {
    flex-direction: column;
    padding: 0.75rem;
    height: calc(100vh - 70px);
  }
  .sidebar {
    display: none; /* Collapsed on mobile for clean focus */
  }
  .chat-main {
    height: 100%;
  }
}
