/* BrainSAIT Doctor Agent — Floating chat widget styles */
:root {
  --bs-primary: #0284c7;
  --bs-primary-dark: #0369a1;
  --bs-primary-light: #e0f2fe;
  --bs-secondary: #0a3d3b;
  --bs-gold: #c9a86a;
  --bs-white: #ffffff;
  --bs-gray: #f8fafc;
  --bs-text: #1e293b;
  --bs-text-light: #64748b;
  --bs-success: #22c55e;
  --bs-error: #ef4444;
  --bs-radius: 16px;
  --bs-shadow: 0 10px 40px rgba(0,0,0,0.15);
}

#brain-sait-agent {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  font-family: 'IBM Plex Sans Arabic', 'Segoe UI', system-ui, sans-serif;
}

[dir="rtl"] #brain-sait-agent {
  right: auto;
  left: 24px;
}

/* Toggle button */
.bs-agent-toggle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bs-primary), var(--bs-primary-dark));
  color: white;
  border: none;
  cursor: pointer;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--bs-shadow);
  transition: all 0.3s ease;
  z-index: 99999;
}

.bs-agent-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 48px rgba(2,132,199,0.4);
}

/* Chat window */
.bs-agent-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-height: 600px;
  background: white;
  border-radius: var(--bs-radius);
  box-shadow: var(--bs-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: bsSlideUp 0.3s ease;
  z-index: 99998;
}

[dir="rtl"] .bs-agent-window {
  right: auto;
  left: 24px;
}

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

/* Header */
.bs-agent-header {
  background: linear-gradient(135deg, var(--bs-secondary), #0d4f4d);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.bs-agent-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bs-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.bs-agent-header-info h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}

.bs-agent-header-info p {
  font-size: 11px;
  opacity: 0.8;
  margin: 2px 0 0;
}

.bs-agent-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bs-success);
  margin-left: auto;
  animation: bsPulse 2s infinite;
}

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

/* Messages */
.bs-agent-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 300px;
  max-height: 400px;
}

.message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
}

.bs-user {
  align-self: flex-end;
  background: var(--bs-primary);
  color: white;
  border-bottom-right-radius: 4px;
}

[dir="rtl"] .bs-user {
  align-self: flex-start;
  border-bottom-right-radius: 16px;
  border-bottom-left-radius: 4px;
}

.bs-assistant {
  align-self: flex-start;
  background: var(--bs-gray);
  color: var(--bs-text);
  border-bottom-left-radius: 4px;
}

[dir="rtl"] .bs-assistant {
  align-self: flex-end;
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 4px;
}

/* Type-specific styles */
.bs-type-icd10 {
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  border: 1px solid #bbf7d0;
}

.bs-type-nphies {
  background: linear-gradient(135deg, #fef9c3, #fef3c7);
  border: 1px solid #fde047;
}

.bs-type-nlm {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border: 1px solid #93c5fd;
}

/* Typing indicator */
.bs-typing-dots {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.bs-typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  animation: bsBounce 1.4s infinite ease-in-out;
}

.bs-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.bs-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bsBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Quick actions */
.bs-agent-quick-actions {
  padding: 8px 16px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  border-top: 1px solid #e2e8f0;
}

.bs-quick-btn {
  flex-shrink: 0;
  padding: 6px 12px;
  border: 1px solid #e2e8f0;
  background: white;
  border-radius: 20px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.bs-quick-btn:hover {
  background: var(--bs-primary-light);
  border-color: var(--bs-primary);
  color: var(--bs-primary);
}

/* Input area */
.bs-agent-input {
  padding: 12px 16px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 8px;
  background: white;
}

.bs-agent-input input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 24px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.bs-agent-input input:focus {
  border-color: var(--bs-primary);
}

.bs-agent-input button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bs-primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.bs-agent-input button:hover {
  background: var(--bs-primary-dark);
}

.bs-agent-input button:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

/* Scrollbar */
.bs-agent-messages::-webkit-scrollbar {
  width: 4px;
}

.bs-agent-messages::-webkit-scrollbar-track {
  background: transparent;
}

.bs-agent-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

/* Mobile */
@media (max-width: 480px) {
  .bs-agent-window {
    width: calc(100vw - 32px);
    max-height: calc(100vh - 140px);
    bottom: 90px;
    right: 16px;
  }

  [dir="rtl"] .bs-agent-window {
    right: auto;
    left: 16px;
  }

  .bs-agent-toggle {
    bottom: 16px;
    right: 16px;
  }

  [dir="rtl"] .bs-agent-toggle {
    left: 16px;
  }
}