/* ==============================================
   Chatbot de Asistencia al Paciente
   ============================================== */

.chatbot-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 58px;
  height: 58px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  cursor: pointer;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(8, 145, 178, 0.4);
  z-index: 999;
  transition: all var(--transition);
}

.chatbot-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 25px rgba(8, 145, 178, 0.5);
}

.chatbot-toggle .close-icon {
  display: none;
}

.chatbot-toggle.active .chat-icon {
  display: none;
}

.chatbot-toggle.active .close-icon {
  display: block;
}

.chatbot-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

/* Chatbot Window */
.chatbot-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-height: 520px;
  background: var(--card);
  border-radius: var(--radius-xl);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  z-index: 998;
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  animation: chatbotSlideIn 0.3s ease;
}

.chatbot-window.active {
  display: flex;
}

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

/* Chat Header */
.chatbot-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.chatbot-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.chatbot-header-info h4 {
  color: white;
  font-size: var(--text-sm);
}

.chatbot-header-info span {
  font-size: var(--text-xs);
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chatbot-header-info .online-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: #4ADE80;
  display: inline-block;
}

/* Chat Messages */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-height: 300px;
  max-height: 320px;
  background: var(--bg);
}

.chat-message {
  max-width: 85%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  line-height: 1.5;
  animation: messageIn 0.3s ease;
}

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

.chat-message.bot {
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-left-radius: var(--radius-sm);
}

.chat-message.user {
  background: var(--primary);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: var(--radius-sm);
}

.chat-message .time {
  display: block;
  font-size: 0.65rem;
  opacity: 0.6;
  margin-top: var(--space-1);
}

/* Quick Replies */
.chat-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-1) 0;
  align-self: flex-start;
}

.quick-reply {
  padding: var(--space-2) var(--space-3);
  background: var(--card);
  border: 1px solid var(--primary-light);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  color: var(--primary);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-body);
}

.quick-reply:hover {
  background: var(--primary);
  color: white;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: var(--space-3) var(--space-4);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: var(--radius-sm);
  align-self: flex-start;
  max-width: 70px;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--fg-muted);
  animation: typingBounce 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Chat Input */
.chatbot-input {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  background: var(--card);
}

.chatbot-input input {
  flex: 1;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--fg);
  background: var(--bg);
  transition: border-color var(--transition);
}

.chatbot-input input:focus {
  outline: none;
  border-color: var(--primary);
}

.chatbot-input button {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

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

/* Responsive */
@media (max-width: 480px) {
  .chatbot-window {
    width: calc(100vw - 32px);
    right: 16px;
    bottom: 90px;
    max-height: 70vh;
  }

  .chatbot-toggle {
    bottom: 16px;
    right: 16px;
  }
}
