/* Health AI Standalone Chat Styles */
:root {
  --bg-app: #F4F7F9;
  --bg-surface: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-bubble-user: #0284C7;
  --bg-bubble-user-text: #FFFFFF;
  --border-light: rgba(15, 23, 42, 0.08);
  --border-focus: #0284C7;
  
  --text-main: #0F172A;
  --text-muted: #475569;
  --text-dim: #94A3B8;

  --accent-blue: #0284C7;
  --accent-blue-hover: #0369A1;
  --accent-teal: #0D9488;
  --accent-emerald: #059669;
  --accent-rose: #E11D48;
  --accent-amber: #D97706;

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 20px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 20px 40px -15px rgba(15, 23, 42, 0.08), 0 0 0 1px rgba(255, 255, 255, 0.9);
  --shadow-float: 0 12px 32px -4px rgba(2, 132, 199, 0.12), 0 4px 12px rgba(0, 0, 0, 0.04);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 64px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.logo-icon-wrap {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #E0F2FE 0%, #BAE6FD 100%);
  border: 1.5px solid #7DD3FC;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-blue);
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.15);
}

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

.logo-main {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lang-switch {
  display: flex;
  background: rgba(15, 23, 42, 0.05);
  border-radius: 100px;
  padding: 3px;
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.lang-btn {
  border: none;
  background: transparent;
  padding: 5px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.lang-btn.active {
  background: #FFFFFF;
  color: var(--text-main);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.btn-new-chat {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border-light);
  background: #FFFFFF;
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-new-chat:hover {
  color: var(--text-main);
  border-color: rgba(15, 23, 42, 0.2);
  background: #F8FAFC;
}

/* Chat Main Viewport */
.chat-viewport {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 150px;
  display: flex;
  flex-direction: column;
}

.chat-stream {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Message Styles */
.message {
  display: flex;
  gap: 14px;
  animation: fadeIn 0.25s ease-out;
}

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

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.assistant-msg .msg-avatar {
  background: #E0F2FE;
  color: #0284C7;
  border: 1px solid #BAE6FD;
}

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

.user-msg .msg-avatar {
  background: #F1F5F9;
  color: #475569;
  border: 1px solid #E2E8F0;
}

.msg-body {
  max-width: 820px;
  border-radius: 20px;
  padding: 22px 26px;
  font-size: 15px;
  line-height: 1.65;
  box-shadow: var(--shadow-sm);
}

.assistant-msg .msg-body {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  border-top-left-radius: 6px;
}

.user-msg .msg-body {
  background: var(--bg-bubble-user);
  color: var(--bg-bubble-user-text);
  border-top-right-radius: 6px;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.25);
}

/* Welcome Card */
.welcome-card {
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  border-radius: 20px;
  padding: 30px 34px;
  box-shadow: var(--shadow-md);
  margin-bottom: 10px;
}

.welcome-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.welcome-desc {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 16px;
}

.welcome-badge-rule {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #FEF3C7;
  color: #92400E;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 20px;
  border: 1px solid #FDE68A;
}

.welcome-methods {
  background: #F8FAFC;
  border-radius: 14px;
  padding: 16px 20px;
  border: 1px solid #F1F5F9;
  margin-bottom: 24px;
}

.welcome-methods h4 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.welcome-methods ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.welcome-methods li {
  font-size: 14px;
  color: var(--text-muted);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.welcome-methods li strong {
  color: var(--text-main);
}

/* Quick Chips */
.quick-chips-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

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

.chip-btn {
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 12px 16px;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.chip-btn:hover {
  border-color: var(--accent-blue);
  background: #F0F9FF;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.08);
}

.chip-icon {
  font-size: 16px;
  flex-shrink: 0;
}

/* Markdown typography inside assistant messages */
.msg-body h1, .msg-body h2, .msg-body h3, .msg-body h4 {
  color: var(--text-main);
  font-family: var(--font-display);
  margin-top: 18px;
  margin-bottom: 8px;
}

.msg-body h2 { font-size: 19px; border-bottom: 1px solid #F1F5F9; padding-bottom: 6px; }
.msg-body h3 { font-size: 16px; }
.msg-body p { margin-bottom: 12px; }
.msg-body p:last-child { margin-bottom: 0; }

.msg-body ul, .msg-body ol {
  margin-left: 20px;
  margin-bottom: 12px;
}

.msg-body li {
  margin-bottom: 6px;
}

.msg-body strong {
  color: #0F172A;
  font-weight: 600;
}

.msg-body blockquote {
  border-left: 3px solid var(--accent-blue);
  background: #F0F9FF;
  padding: 10px 16px;
  border-radius: 0 8px 8px 0;
  margin: 14px 0;
  color: #0369A1;
  font-size: 14px;
}

.msg-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 13px;
}

.msg-body th, .msg-body td {
  padding: 10px 12px;
  border: 1px solid #E2E8F0;
  text-align: left;
}

.msg-body th {
  background: #F8FAFC;
  font-weight: 600;
}

/* Sources collapsible drawer in message */
.sources-drawer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed #E2E8F0;
}

.sources-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  user-select: none;
  list-style: none;
  transition: all 0.2s ease;
}

.sources-header::-webkit-details-marker {
  display: none;
}

.sources-header:hover {
  background: #F1F5F9;
  color: var(--accent-blue);
  border-color: #CBD5E1;
}

.sources-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sources-header-left i {
  color: var(--accent-blue);
  font-size: 12px;
}

.toggle-chevron {
  font-size: 11px;
  color: var(--text-dim);
  transition: transform 0.2s ease;
}

.sources-drawer[open] .toggle-chevron {
  transform: rotate(180deg);
  color: var(--accent-blue);
}

.source-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding: 2px;
}

.source-badge {
  background: #F1F5F9;
  color: #334155;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid #E2E8F0;
  display: inline-flex;
  align-items: center;
}

/* Floating Input Dock */
.input-dock {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 40px);
  max-width: 960px;
  z-index: 40;
}

/* File Attachment Preview Bar */
.file-preview-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #FFFFFF;
  border: 1px solid #BAE6FD;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.12);
  border-radius: 100px;
  padding: 6px 14px;
  margin-bottom: 8px;
  animation: fadeIn 0.2s ease;
}

.file-preview-pill i {
  color: var(--accent-blue);
  font-size: 14px;
}

.file-name-txt {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-remove-attachment {
  border: none;
  background: #F1F5F9;
  color: var(--text-muted);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.btn-remove-attachment:hover {
  background: #E2E8F0;
  color: var(--text-main);
}

/* Input Box */
.input-box {
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  border-radius: 28px;
  padding: 8px 12px 8px 16px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  box-shadow: var(--shadow-float);
  transition: all 0.2s ease;
}

.input-box:focus-within {
  border-color: var(--accent-blue);
  box-shadow: 0 16px 36px -4px rgba(2, 132, 199, 0.2), 0 0 0 2px rgba(2, 132, 199, 0.15);
}

.btn-icon-input {
  border: none;
  background: transparent;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  font-size: 16px;
}

.btn-icon-input:hover {
  background: #F1F5F9;
  color: var(--text-main);
}

.btn-voice.recording {
  background: #FEE2E2;
  color: #DC2626;
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

#chatInput {
  flex: 1;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-main);
  resize: none;
  max-height: 160px;
  padding: 7px 0;
  background: transparent;
}

#chatInput::placeholder {
  color: var(--text-dim);
}

.btn-send {
  border: none;
  background: var(--accent-blue);
  color: #FFFFFF;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  font-size: 15px;
}

.btn-send:hover {
  background: var(--accent-blue-hover);
  transform: translateY(-1px);
}

.btn-send:disabled {
  background: #CBD5E1;
  cursor: not-allowed;
  transform: none;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--accent-blue);
  border-radius: 50%;
  animation: typingBounce 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Responsive */
@media (max-width: 768px) {
  .app-header { padding: 0 16px; height: 56px; }
  .chat-viewport { padding: 16px 12px 140px; }
  .welcome-card { padding: 20px; }
  .msg-body { padding: 16px 18px; }
  .quick-chips-grid { grid-template-columns: 1fr; }
  .input-dock { width: calc(100% - 24px); bottom: 14px; }
}
