/**
 * AI Assistant Page Styles
 * Emergency Healthcare AI Platform
 */

body { padding-top: var(--navbar-height); }
.section-pad { padding: var(--space-16) 0; }

.page-header {
  background: linear-gradient(135deg, rgba(106,76,147,0.08), rgba(69,123,157,0.05));
  padding: var(--space-12) 0 var(--space-8);
  border-bottom: 1px solid var(--border-color);
  text-align: center;
}
.page-header .eyebrow { color: #6a4c93; font-size: var(--text-sm); font-weight: var(--font-semibold); letter-spacing: 0.1em; text-transform: uppercase; display: block; margin-bottom: var(--space-3); }
.page-header h1 { font-size: var(--text-4xl); margin-bottom: var(--space-3); }
.page-header p  { color: var(--text-muted); font-size: var(--text-lg); max-width: 560px; margin-inline: auto; }

/* ── Checker Layout ── */
.checker-section { background: var(--bg-body); }
.checker-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
  align-items: start;
}

/* ── Input Panel ── */
.input-panel {
  background: var(--bg-surface);
  border-radius: var(--border-radius-xl);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.method-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface-2);
}
.method-tab {
  flex: 1;
  padding: var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}
.method-tab:hover { color: var(--text-primary); background: var(--bg-surface); }
.method-tab.active { color: #6a4c93; border-bottom-color: #6a4c93; background: var(--bg-surface); }

.method-pane { display: none; padding: var(--space-6); }
.method-pane.active { display: block; }

.symptom-textarea {
  width: 100%;
  min-height: 140px;
  padding: var(--space-4);
  background: var(--bg-surface-2);
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-primary);
  resize: vertical;
  outline: none;
  transition: var(--transition-fast);
  margin-bottom: var(--space-4);
}
.symptom-textarea:focus { border-color: #6a4c93; box-shadow: 0 0 0 3px rgba(106,76,147,0.12); }
.symptom-textarea::placeholder { color: var(--text-muted); }

.symptom-tags { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-5); }
.symptom-tag {
  padding: var(--space-1) var(--space-3);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  user-select: none;
}
.symptom-tag:hover, .symptom-tag.selected {
  background: rgba(106,76,147,0.12);
  border-color: #6a4c93;
  color: #6a4c93;
}

/* ── Voice Pane ── */
.voice-pane { text-align: center; padding: var(--space-8) var(--space-6); }
.voice-btn {
  width: 100px; height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6a4c93, #4a2c73);
  color: var(--color-white);
  border: none;
  font-size: 2rem;
  cursor: pointer;
  margin: 0 auto var(--space-5);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(106,76,147,0.3);
  transition: var(--transition-spring);
}
.voice-btn:hover { transform: scale(1.06); }
.voice-btn.recording { animation: pulse 1.5s ease-out infinite; background: var(--color-primary); }
.voice-status { font-size: var(--text-sm); color: var(--text-muted); margin-bottom: var(--space-4); }
.voice-transcript {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: var(--space-4);
  min-height: 80px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-align: left;
}

/* ── Image Pane ── */
.upload-area {
  border: 2px dashed var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: var(--space-10);
  text-align: center;
  cursor: pointer;
  transition: var(--transition-fast);
  margin-bottom: var(--space-4);
}
.upload-area:hover, .upload-area.dragover { border-color: #6a4c93; background: rgba(106,76,147,0.04); }
.upload-area i { font-size: 2.5rem; color: var(--text-muted); margin-bottom: var(--space-3); display: block; }
.upload-area p { font-size: var(--text-sm); color: var(--text-muted); }
.upload-area input[type="file"] { display: none; }
.image-preview { display: none; position: relative; margin-bottom: var(--space-4); }
.image-preview img { width: 100%; border-radius: var(--border-radius-lg); max-height: 200px; object-fit: cover; }
.image-preview .remove-btn { position: absolute; top: var(--space-2); right: var(--space-2); }

/* ── Results Panel ── */
.results-panel {
  background: var(--bg-surface);
  border-radius: var(--border-radius-xl);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  min-height: 500px;
  display: flex;
  flex-direction: column;
}

.results-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.ai-avatar-sm {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6a4c93, #4a2c73);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-white);
  font-size: var(--text-sm);
  flex-shrink: 0;
}
.results-header h3 { font-size: var(--text-base); color: var(--text-primary); }
.results-header .online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-accent); margin-left: auto; box-shadow: 0 0 0 3px var(--color-accent-alpha); }

.results-body { flex: 1; padding: var(--space-6); overflow-y: auto; }

.welcome-state { text-align: center; padding: var(--space-10) var(--space-4); }
.welcome-state .welcome-icon { font-size: 3rem; color: #6a4c93; opacity: 0.3; margin-bottom: var(--space-4); }
.welcome-state h4 { font-size: var(--text-lg); margin-bottom: var(--space-3); }
.welcome-state p  { font-size: var(--text-sm); color: var(--text-muted); }

.loading-state { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-6); }
.loading-dots { display: flex; gap: var(--space-2); }
.loading-dots span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #6a4c93;
  animation: bounce 1.2s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%,80%,100% { transform: scale(0.6); opacity: 0.4; } 40% { transform: scale(1); opacity: 1; } }

.severity-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--border-radius-lg);
  margin-bottom: var(--space-5);
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
}
.severity-banner.high     { background: var(--color-primary-alpha); color: var(--color-primary); }
.severity-banner.moderate { background: rgba(244,162,97,0.15); color: #c47a2a; }
.severity-banner.low      { background: var(--color-accent-alpha); color: var(--color-accent-dark); }

.condition-item {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}
.condition-item-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-2); }
.condition-item-name { font-weight: var(--font-semibold); font-size: var(--text-sm); color: var(--text-primary); }
.condition-item p { font-size: var(--text-xs); color: var(--text-muted); }

.advice-box {
  background: rgba(69,123,157,0.06);
  border: 1px solid var(--color-secondary-alpha);
  border-radius: var(--border-radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
}
.advice-box h5 { font-size: var(--text-sm); color: var(--color-secondary); margin-bottom: var(--space-2); }
.advice-box p  { font-size: var(--text-sm); color: var(--text-secondary); }

.disclaimer {
  background: var(--bg-surface-2);
  border-radius: var(--border-radius);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  color: var(--text-muted);
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
  margin-top: var(--space-4);
}
.disclaimer i { color: var(--color-warning); flex-shrink: 0; margin-top: 2px; }

/* ── First Aid Section ── */
.first-aid-section { background: var(--bg-surface); }
.aid-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-6); }
.aid-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-base);
}
.aid-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); }
.aid-card-img { position: relative; aspect-ratio: 16/9; overflow: hidden; }
.aid-card-img img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.aid-card:hover .aid-card-img img { transform: scale(1.05); }
.aid-badge {
  position: absolute;
  top: var(--space-3); left: var(--space-3);
  background: var(--color-primary);
  color: var(--color-white);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--border-radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  display: flex; align-items: center; gap: var(--space-1);
}
.aid-card-body { padding: var(--space-5); }
.aid-card-body h3 { font-size: var(--text-lg); margin-bottom: var(--space-4); }
.aid-steps { display: flex; flex-direction: column; gap: var(--space-3); margin-bottom: var(--space-5); }
.aid-step { display: flex; gap: var(--space-3); align-items: flex-start; }
.aid-step-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--color-primary-alpha);
  color: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  flex-shrink: 0;
}
.aid-step p { font-size: var(--text-sm); color: var(--text-secondary); }

/* ── Guide Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-base);
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal-box {
  background: var(--bg-surface);
  border-radius: var(--border-radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(16px);
  transition: var(--transition-base);
}
.modal-overlay.open .modal-box { transform: scale(1) translateY(0); }
.modal-header {
  padding: var(--space-6);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--bg-surface);
  z-index: 1;
}
.modal-header h2 { font-size: var(--text-xl); }
.modal-close { width: 36px; height: 36px; border-radius: 50%; background: var(--bg-surface-2); border: 1px solid var(--border-color); display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-muted); transition: var(--transition-fast); }
.modal-close:hover { background: var(--color-primary-alpha); color: var(--color-primary); }
.modal-body { padding: var(--space-6); }
.modal-video { aspect-ratio: 16/9; border-radius: var(--border-radius-lg); overflow: hidden; margin-bottom: var(--space-6); background: var(--bg-surface-2); }
.modal-video iframe { width: 100%; height: 100%; border: none; }
.modal-steps ol { padding-left: var(--space-5); display: flex; flex-direction: column; gap: var(--space-3); }
.modal-steps li { font-size: var(--text-sm); color: var(--text-secondary); line-height: var(--leading-relaxed); }
.modal-note { background: rgba(244,162,97,0.1); border: 1px solid rgba(244,162,97,0.3); border-radius: var(--border-radius-lg); padding: var(--space-4); margin-top: var(--space-5); font-size: var(--text-sm); color: var(--text-secondary); }

/* ── Conditions ── */
.conditions-section { background: var(--bg-body); }
.condition-tabs { display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: center; margin-bottom: var(--space-8); }
.condition-tab {
  padding: var(--space-2) var(--space-5);
  border-radius: var(--border-radius-full);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-muted);
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  transition: var(--transition-fast);
}
.condition-tab:hover { color: var(--text-primary); border-color: var(--border-color-dark); }
.condition-tab.active { color: #6a4c93; background: rgba(106,76,147,0.1); border-color: #6a4c93; }
.conditions-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }
.condition-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: var(--space-5);
  cursor: pointer;
  transition: var(--transition-base);
  text-align: center;
}
.condition-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: #6a4c93; }
.condition-card i { font-size: 1.75rem; color: #6a4c93; margin-bottom: var(--space-3); display: block; }
.condition-card h4 { font-size: var(--text-sm); font-weight: var(--font-semibold); margin-bottom: var(--space-2); }
.condition-card p  { font-size: var(--text-xs); color: var(--text-muted); }

/* ── Responsive ── */
@media (max-width: 1024px) { .checker-layout { grid-template-columns: 1fr; } }
@media (max-width: 768px)  { .aid-grid { grid-template-columns: 1fr; } .conditions-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px)  { .conditions-grid { grid-template-columns: repeat(2, 1fr); } }

/* ══════════════════════════════════════════
   AI CHATBOT PANEL
══════════════════════════════════════════ */

.chatbot-panel {
  background: var(--bg-surface);
  border-radius: var(--border-radius-xl);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  height: 600px;
  overflow: hidden;
  position: sticky;
  top: calc(var(--navbar-height) + 1rem);
}

/* ── Chat Header ── */
.chat-header {
  padding: var(--space-4) var(--space-5);
  background: linear-gradient(135deg, #6a4c93, #4a2c73);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}
.chat-header .ai-avatar-sm {
  background: rgba(255,255,255,0.2);
  width: 40px; height: 40px;
  font-size: 1.1rem;
}
.chat-header-info h3 { color: #fff; font-size: var(--text-base); margin: 0; }
.chat-status {
  font-size: var(--text-xs);
  color: rgba(255,255,255,0.75);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.chat-status .online-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #06d6a0;
  box-shadow: 0 0 0 2px rgba(6,214,160,0.3);
  display: inline-block;
  margin: 0;
}
.chat-clear-btn {
  margin-left: auto;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-sm);
  transition: var(--transition-fast);
  flex-shrink: 0;
}
.chat-clear-btn:hover { background: rgba(255,255,255,0.28); }

/* ── Messages Area ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

/* ── Message Bubbles ── */
.chat-msg {
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
  animation: msgIn 0.25s ease both;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

.chat-msg .msg-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
}
.chat-msg.bot  .msg-avatar { background: linear-gradient(135deg,#6a4c93,#4a2c73); color:#fff; }
.chat-msg.user .msg-avatar { background: linear-gradient(135deg,#e63946,#c1121f); color:#fff; }

.msg-bubble {
  max-width: 78%;
  padding: var(--space-3) var(--space-4);
  border-radius: 18px;
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  position: relative;
}
.chat-msg.bot  .msg-bubble {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
  color: var(--text-primary);
}
.chat-msg.user .msg-bubble {
  background: linear-gradient(135deg,#6a4c93,#4a2c73);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-bubble .msg-time {
  display: block;
  font-size: 10px;
  opacity: 0.55;
  margin-top: var(--space-1);
  text-align: right;
}

/* Severity chips inside bot messages */
.msg-severity {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-3);
  border-radius: var(--border-radius-full);
  font-size: 11px;
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-2);
}
.msg-severity.high     { background: var(--color-primary-alpha); color: var(--color-primary); }
.msg-severity.moderate { background: rgba(244,162,97,0.15); color: #c47a2a; }
.msg-severity.low      { background: var(--color-accent-alpha); color: var(--color-accent-dark); }

.msg-bubble ul { padding-left: 1.2rem; margin: var(--space-2) 0; }
.msg-bubble ul li { margin-bottom: var(--space-1); font-size: var(--text-xs); }
.msg-bubble .msg-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-3); }
.msg-bubble .msg-actions a {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--border-radius-full);
  background: rgba(106,76,147,0.12);
  color: #6a4c93;
  text-decoration: none;
  font-weight: var(--font-semibold);
  transition: var(--transition-fast);
}
.msg-bubble .msg-actions a:hover { background: #6a4c93; color: #fff; }

/* ── Typing Indicator ── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.typing-dots {
  display: flex;
  gap: 4px;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
}
.typing-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #6a4c93;
  opacity: 0.4;
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%,60%,100% { transform: translateY(0); opacity: 0.4; }
  30%          { transform: translateY(-6px); opacity: 1; }
}

/* ── Quick Replies ── */
.chat-quick-replies {
  padding: var(--space-3) var(--space-4);
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface-2);
  flex-shrink: 0;
}
.quick-reply {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--border-radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  font-size: 11px;
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}
.quick-reply:hover {
  background: rgba(106,76,147,0.1);
  border-color: #6a4c93;
  color: #6a4c93;
}

/* ── Input Bar ── */
.chat-input-bar {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-surface);
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius-full);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-surface-2);
  outline: none;
  transition: var(--transition-fast);
}
.chat-input:focus { border-color: #6a4c93; box-shadow: 0 0 0 3px rgba(106,76,147,0.12); }
.chat-input::placeholder { color: var(--text-muted); }

.chat-send-btn, .chat-voice-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-sm);
  transition: var(--transition-spring);
  flex-shrink: 0;
}
.chat-send-btn {
  background: linear-gradient(135deg,#6a4c93,#4a2c73);
  color: #fff;
  box-shadow: 0 4px 12px rgba(106,76,147,0.35);
}
.chat-send-btn:hover { transform: scale(1.1); box-shadow: 0 6px 18px rgba(106,76,147,0.45); }
.chat-voice-btn { background: var(--bg-surface-2); color: var(--text-muted); border: 1.5px solid var(--border-color); }
.chat-voice-btn:hover { color: #6a4c93; border-color: #6a4c93; }
.chat-voice-btn.recording { background: var(--color-primary); color: #fff; border-color: var(--color-primary); animation: pulse 1.5s ease-out infinite; }
