/* ==========================================================================
   HealthAI - Modern Healthcare + AI Design System
   ========================================================================== */

:root {
  /* Primary & Medical Color Palette */
  --primary-50: #f0f9ff;
  --primary-100: #e0f2fe;
  --primary-200: #bae6fd;
  --primary-300: #7dd3fc;
  --primary-400: #38bdf8;
  --primary-500: #0ea5e9;
  --primary-600: #0284c7; /* Main Medical Blue */
  --primary-700: #0369a1;
  --primary-800: #075985;
  --primary-900: #0c4a6e;

  /* Teal / Healthcare Accents */
  --teal-50: #f0fdfa;
  --teal-100: #ccfbf1;
  --teal-500: #14b8a6;
  --teal-600: #0d9488;
  --teal-700: #0f766e;

  /* Status Colors */
  --status-online: #10b981;
  --status-online-glow: rgba(16, 185, 129, 0.35);
  --warning-50: #fffbeb;
  --warning-100: #fef3c7;
  --warning-600: #d97706;
  --warning-700: #b45309;
  --danger-50: #fef2f2;
  --danger-100: #fee2e2;
  --danger-500: #ef4444;
  --danger-600: #dc2626;

  /* Neutral Slate Grayscale */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  /* Surface & Chat Colors */
  --bg-app: #f4f8fb;
  --bg-surface: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.88);
  --border-subtle: #e2e8f0;
  --border-hover: #cbd5e1;

  /* User Message Gradient */
  --user-bubble-bg: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
  --user-bubble-text: #ffffff;
  --bot-bubble-bg: #ffffff;
  --bot-bubble-border: #e2e8f0;
  --bot-bubble-text: #1e293b;

  /* Typography */
  --font-heading: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;

  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.08), 0 1px 2px -1px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.06);
  --shadow-glow: 0 0 20px rgba(2, 132, 199, 0.18);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Reset & Base Styles
   ========================================================================== */

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

html, body {
  height: 100%;
  width: 100%;
  background-color: var(--bg-app);
  color: var(--slate-800);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

/* App Master Layout */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 1100px;
  margin: 0 auto;
  background-color: var(--bg-surface);
  box-shadow: var(--shadow-xl);
  position: relative;
}

@media (min-width: 1101px) {
  body {
    padding: 12px 24px;
    background: radial-gradient(circle at 10% 20%, rgba(224, 242, 254, 0.7) 0%, rgba(240, 253, 250, 0.5) 40%, rgba(244, 248, 251, 1) 100%);
  }

  .app-container {
    height: calc(100vh - 24px);
    height: calc(100dvh - 24px);
    border-radius: var(--radius-xl);
    border: 1px solid rgba(226, 232, 240, 0.8);
    overflow: hidden;
  }
}

/* ==========================================================================
   Header Section
   ========================================================================== */

.app-header {
  flex-shrink: 0;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px 20px;
  z-index: 20;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon-wrapper {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-600), var(--teal-600));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
  flex-shrink: 0;
}

.brand-icon {
  width: 24px;
  height: 24px;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--slate-900);
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 0.78rem;
  color: var(--slate-500);
  font-weight: 500;
}

/* Status Badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background-color: var(--teal-50);
  border: 1px solid var(--teal-100);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.status-dot {
  width: 7px;
  height: 7px;
  background-color: var(--status-online);
  border-radius: 50%;
  position: relative;
}

.status-dot::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background-color: var(--status-online);
  border-radius: 50%;
  opacity: 0.5;
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(2.2); opacity: 0; }
  100% { transform: scale(1); opacity: 0; }
}

.status-text {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--teal-700);
  letter-spacing: 0.01em;
}

/* Header Buttons */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  color: var(--slate-700);
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-header svg {
  width: 16px;
  height: 16px;
  color: var(--slate-500);
  transition: color var(--transition-fast);
}

.btn-header:hover {
  background: var(--slate-100);
  border-color: var(--slate-300);
  color: var(--slate-900);
}

.btn-header:hover svg {
  color: var(--primary-600);
}

.btn-primary-soft {
  background: var(--primary-50);
  border-color: var(--primary-200);
  color: var(--primary-700);
}

.btn-primary-soft svg {
  color: var(--primary-600);
}

.btn-primary-soft:hover {
  background: var(--primary-100);
  border-color: var(--primary-300);
  color: var(--primary-800);
}

/* ==========================================================================
   Chat Workspace & Welcome Screen
   ========================================================================== */

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at 50% 0%, rgba(240, 249, 255, 0.7) 0%, transparent 60%);
}

/* Welcome Hero Screen */
.welcome-screen {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.4s ease-out;
}

.welcome-screen.hidden {
  display: none !important;
}

.welcome-card {
  max-width: 680px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin: auto;
}

.welcome-avatar-wrapper {
  position: relative;
  margin-bottom: 16px;
}

.welcome-avatar-glow {
  position: absolute;
  top: -6px;
  left: -6px;
  right: -6px;
  bottom: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(2, 132, 199, 0.4) 0%, rgba(20, 184, 166, 0.1) 70%);
  filter: blur(10px);
  animation: pulse-avatar 3s infinite alternate ease-in-out;
}

@keyframes pulse-avatar {
  0% { transform: scale(0.95); opacity: 0.6; }
  100% { transform: scale(1.15); opacity: 1; }
}

.welcome-avatar {
  position: relative;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary-600), var(--teal-600));
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: var(--shadow-md);
}

.welcome-avatar svg {
  width: 32px;
  height: 32px;
}

.welcome-title {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--slate-900);
  margin-bottom: 4px;
}

.welcome-tagline {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--primary-700);
  margin-bottom: 12px;
}

.welcome-desc {
  font-size: 0.92rem;
  color: var(--slate-600);
  max-width: 580px;
  line-height: 1.6;
  margin-bottom: 24px;
}

.highlight-note {
  display: block;
  font-weight: 600;
  color: var(--slate-700);
  margin-top: 4px;
}

/* Quick Prompts */
.quick-prompts-container {
  width: 100%;
  margin-bottom: 20px;
}

.quick-prompts-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate-400);
  margin-bottom: 12px;
}

.quick-prompts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  text-align: left;
}

.quick-prompt-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--slate-700);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-xs);
}

.prompt-icon {
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
}

.prompt-text {
  flex: 1;
}

.quick-prompt-card:hover {
  background: var(--primary-50);
  border-color: var(--primary-300);
  color: var(--primary-800);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

/* Emergency Alert Box in Hero */
.emergency-alert-box {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--danger-50);
  border: 1px solid var(--danger-100);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  text-align: left;
}

.alert-icon {
  font-size: 1.25rem;
  line-height: 1.2;
}

.alert-content strong {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--danger-600);
  margin-bottom: 2px;
}

.alert-content p {
  font-size: 0.8rem;
  color: var(--slate-600);
  line-height: 1.4;
}

/* ==========================================================================
   Chat Messages List
   ========================================================================== */

.chat-messages-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.chat-messages-wrapper.hidden {
  display: none !important;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

/* Scrollbar Customization */
.chat-messages::-webkit-scrollbar,
.welcome-screen::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track,
.welcome-screen::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb,
.welcome-screen::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
  background: var(--slate-300);
  border-radius: var(--radius-full);
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.welcome-screen::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--slate-400);
}

/* Individual Message Row */
.message-row {
  display: flex;
  gap: 12px;
  width: 100%;
  animation: messageSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.message-row.user-row {
  flex-direction: row-reverse;
}

/* Message Avatar */
.message-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}

.bot-avatar {
  background: linear-gradient(135deg, var(--primary-600), var(--teal-600));
  color: #ffffff;
}

.bot-avatar svg {
  width: 20px;
  height: 20px;
}

.user-avatar {
  background: var(--slate-700);
  color: #ffffff;
}

.user-avatar svg {
  width: 18px;
  height: 18px;
}

/* Message Container */
.message-container {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}

.user-row .message-container {
  align-items: flex-end;
}

.bot-row .message-container {
  align-items: flex-start;
}

/* Message Meta */
.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  padding: 0 4px;
}

.sender-name {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--slate-700);
}

.message-time {
  font-size: 0.72rem;
  color: var(--slate-400);
}

/* Message Bubbles */
.message-bubble {
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 0.93rem;
  line-height: 1.6;
  position: relative;
  word-break: break-word;
}

/* User Bubble */
.user-bubble {
  background: var(--user-bubble-bg);
  color: var(--user-bubble-text);
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.22);
}

.user-bubble p {
  white-space: pre-wrap;
}

/* Bot Bubble */
.bot-bubble {
  background: var(--bot-bubble-bg);
  color: var(--bot-bubble-text);
  border: 1px solid var(--bot-bubble-border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

/* Formatted Content inside Bot Bubble */
.bot-bubble h2, 
.bot-bubble h3, 
.bot-bubble h4 {
  font-family: var(--font-heading);
  color: var(--slate-900);
  margin-top: 14px;
  margin-bottom: 6px;
  font-weight: 700;
}

.bot-bubble h2:first-child, 
.bot-bubble h3:first-child, 
.bot-bubble h4:first-child {
  margin-top: 0;
}

.bot-bubble h3 { font-size: 1.05rem; color: var(--primary-800); }
.bot-bubble h4 { font-size: 0.95rem; }

.bot-bubble p {
  margin-bottom: 10px;
}

.bot-bubble p:last-child {
  margin-bottom: 0;
}

.bot-bubble strong {
  color: var(--slate-900);
  font-weight: 600;
}

.bot-bubble ul, 
.bot-bubble ol {
  margin: 8px 0 12px 20px;
}

.bot-bubble li {
  margin-bottom: 5px;
  padding-left: 2px;
}

.bot-bubble li::marker {
  color: var(--primary-600);
}

/* Medical Styled Callout Boxes (Generated by Parser) */
.medical-callout {
  margin: 12px 0;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border-left: 4px solid var(--primary-600);
  background: var(--slate-50);
}

.medical-callout.callout-causes {
  background: #f0f9ff;
  border-left-color: var(--primary-600);
}

.medical-callout.callout-actions {
  background: #f0fdfa;
  border-left-color: var(--teal-600);
}

.medical-callout.callout-doctor {
  background: #fffbeb;
  border-left-color: var(--warning-600);
}

.medical-callout.callout-emergency {
  background: #fef2f2;
  border-left-color: var(--danger-500);
}

.medical-callout.callout-note {
  background: #f8fafc;
  border-left-color: var(--slate-400);
  font-size: 0.85rem;
  color: var(--slate-600);
}

.callout-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 6px;
}

.callout-causes .callout-title { color: var(--primary-800); }
.callout-actions .callout-title { color: var(--teal-700); }
.callout-doctor .callout-title { color: var(--warning-700); }
.callout-emergency .callout-title { color: var(--danger-600); }
.callout-note .callout-title { color: var(--slate-700); }

/* Message Actions Bar (Copy button, etc.) */
.message-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  opacity: 0.85;
}

.btn-msg-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  font-size: 0.72rem;
  color: var(--slate-500);
  cursor: pointer;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.btn-msg-action svg {
  width: 13px;
  height: 13px;
}

.btn-msg-action:hover {
  background: var(--slate-100);
  color: var(--primary-700);
}

/* ==========================================================================
   Typing Indicator
   ========================================================================== */

.typing-indicator-container {
  display: flex;
  gap: 12px;
  padding: 0 24px 16px 24px;
  animation: fadeIn 0.2s ease-out;
}

.typing-indicator-container.hidden {
  display: none !important;
}

.typing-bubble {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 4px;
  padding: 10px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.typing-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
}

.typing-name {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--slate-700);
}

.typing-status {
  color: var(--slate-400);
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 2px;
}

.typing-dots .dot {
  width: 7px;
  height: 7px;
  background-color: var(--primary-500);
  border-radius: 50%;
  animation: waveDot 1.4s infinite ease-in-out both;
}

.typing-dots .dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dots .dot:nth-child(2) { animation-delay: -0.16s; }
.typing-dots .dot:nth-child(3) { animation-delay: 0s; }

@keyframes waveDot {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1.15);
    opacity: 1;
    background-color: var(--teal-500);
  }
}

/* ==========================================================================
   Chat Input Section
   ========================================================================== */

.chat-input-section {
  flex-shrink: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: 12px 20px 14px 20px;
  z-index: 10;
}

.input-inner-wrapper {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-input-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--slate-50);
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 6px 8px 6px 14px;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-xs);
}

.chat-input-form:focus-within {
  background: #ffffff;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.12);
}

.textarea-container {
  flex: 1;
  display: flex;
  align-items: center;
  position: relative;
}

.chat-textarea {
  width: 100%;
  max-height: 150px;
  min-height: 24px;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 0.94rem;
  line-height: 1.5;
  color: var(--slate-800);
  resize: none;
  outline: none;
  padding: 6px 28px 6px 0;
}

.chat-textarea::placeholder {
  color: var(--slate-400);
}

.btn-clear {
  position: absolute;
  right: 4px;
  background: transparent;
  border: none;
  color: var(--slate-400);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 50%;
  transition: color var(--transition-fast);
}

.btn-clear svg {
  width: 18px;
  height: 18px;
}

.btn-clear:hover {
  color: var(--slate-600);
}

.btn-clear.hidden {
  display: none !important;
}

/* Send Button */
.btn-send {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: none;
  background: linear-gradient(135deg, var(--primary-600), var(--teal-600));
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25);
}

.btn-send .send-icon {
  width: 18px;
  height: 18px;
  transition: transform var(--transition-fast);
}

.btn-send:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-700), var(--teal-700));
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.35);
}

.btn-send:hover:not(:disabled) .send-icon {
  transform: scale(1.08) translate(1px, -1px);
}

.btn-send:active:not(:disabled) {
  transform: translateY(0);
}

.btn-send:disabled {
  background: var(--slate-200);
  color: var(--slate-400);
  box-shadow: none;
  cursor: not-allowed;
}

/* Disclaimer & Privacy Text */
.input-disclaimer-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
  padding: 0 6px;
}

.disclaimer-text {
  font-size: 0.73rem;
  color: var(--slate-500);
  line-height: 1.35;
}

.disclaimer-text strong {
  color: var(--slate-600);
}

.privacy-text {
  font-size: 0.71rem;
  color: var(--slate-400);
}

.privacy-text strong {
  color: var(--slate-500);
}

/* ==========================================================================
   Modals
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  animation: fadeIn 0.2s ease-out;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-xl);
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--slate-200);
  overflow: hidden;
  animation: modalScaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card.modal-sm {
  max-width: 420px;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--slate-100);
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-icon-badge {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: var(--primary-100);
  color: var(--primary-700);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-icon-badge svg {
  width: 18px;
  height: 18px;
}

.modal-icon-badge.key-badge {
  background: #fef3c7;
  color: #b45309;
}

.modal-icon-badge.warn-badge {
  background: #fee2e2;
  color: #dc2626;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--slate-900);
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--slate-400);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-close-modal svg {
  width: 18px;
  height: 18px;
}

.btn-close-modal:hover {
  background: var(--slate-100);
  color: var(--slate-700);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-size: 0.9rem;
  color: var(--slate-600);
  line-height: 1.55;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--slate-100);
  background: var(--slate-50);
}

/* About Modal Elements */
.about-hero {
  background: linear-gradient(135deg, var(--primary-50), var(--teal-50));
  border: 1px solid var(--primary-100);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
}

.about-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--primary-600);
  color: #ffffff;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  margin-bottom: 8px;
}

.about-intro {
  font-size: 0.92rem;
  color: var(--slate-800);
}

.about-section h3 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--slate-900);
  margin-bottom: 6px;
}

.about-list {
  margin-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.about-list strong {
  color: var(--slate-800);
}

.emergency-box-mini {
  background: var(--danger-50);
  border: 1px solid var(--danger-100);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.emergency-box-mini h3 {
  color: var(--danger-600);
  margin-bottom: 8px;
}

.emergency-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.emergency-item {
  background: #ffffff;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--danger-100);
  display: flex;
  flex-direction: column;
}

.emergency-num {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--danger-600);
}

.emergency-desc {
  font-size: 0.72rem;
  color: var(--slate-600);
}

/* API Key Modal Elements */
.api-status-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
}

.api-status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--slate-400);
}

.api-status-indicator.configured {
  background: var(--status-online);
  box-shadow: 0 0 8px var(--status-online);
}

.api-status-indicator.missing {
  background: var(--danger-500);
}

.api-status-text {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--slate-700);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--slate-700);
}

.input-password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.form-control {
  width: 100%;
  padding: 9px 40px 9px 12px;
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-md);
  font-family: monospace;
  font-size: 0.88rem;
  color: var(--slate-800);
  outline: none;
  transition: all var(--transition-fast);
}

.form-control:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.12);
}

.btn-toggle-pwd {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 4px;
}

.form-helper {
  font-size: 0.74rem;
  color: var(--slate-500);
}

.api-guide-box {
  background: #f8fafc;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.api-guide-box h4 {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--slate-800);
  margin-bottom: 6px;
}

.api-guide-box ol {
  margin-left: 18px;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.api-guide-box a {
  color: var(--primary-600);
  font-weight: 600;
  text-decoration: none;
}

.api-guide-box a:hover {
  text-decoration: underline;
}

/* Button Variants */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
}

.btn-primary {
  background: var(--primary-600);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25);
}

.btn-primary:hover {
  background: var(--primary-700);
}

.btn-secondary {
  background: var(--slate-200);
  color: var(--slate-700);
}

.btn-secondary:hover {
  background: var(--slate-300);
  color: var(--slate-900);
}

.btn-danger {
  background: var(--danger-600);
  color: #ffffff;
}

.btn-danger:hover {
  background: #b91c1c;
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  background: var(--slate-900);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-size: 0.83rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastPop 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  pointer-events: auto;
}

.toast.toast-success {
  background: #065f46;
}

.toast.toast-error {
  background: #991b1b;
}

@keyframes toastPop {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ==========================================================================
   Animations & Responsive Breakpoints
   ========================================================================== */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .app-header {
    padding: 10px 14px;
  }

  .brand-title {
    font-size: 1.1rem;
  }

  .brand-subtitle {
    display: none;
  }

  .btn-header .btn-text {
    display: none;
  }

  .btn-header {
    padding: 7px;
  }

  .chat-messages {
    padding: 14px 12px;
    gap: 16px;
  }

  .message-container {
    max-width: 90%;
  }

  .welcome-screen {
    padding: 16px 12px;
  }

  .welcome-title {
    font-size: 1.45rem;
  }

  .welcome-tagline {
    font-size: 0.95rem;
  }

  .quick-prompts-grid {
    grid-template-columns: 1fr;
  }

  .chat-input-section {
    padding: 10px 12px 10px 12px;
  }

  .disclaimer-text {
    font-size: 0.68rem;
  }

  .privacy-text {
    display: none;
  }

  .emergency-grid {
    grid-template-columns: 1fr;
  }
}
