/* ========== CHATBOT WIDGET ========== */
.chatbot-widget {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 1000;
  font-family: 'Inter', sans-serif;
}

.chatbot-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: all var(--transition-base);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1001;
}

.chatbot-toggle i {
  font-size: 1.75rem;
  color: white;
  transition: all var(--transition-base);
}

.chatbot-toggle .fa-times {
  display: none;
}

.chatbot-toggle.active .fa-robot {
  display: none;
}

.chatbot-toggle.active .fa-times {
  display: inline-block;
}

.chatbot-toggle:hover {
  transform: scale(1.1);
  background: var(--primary-dark);
}

.chatbot-container {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 380px;
  height: 550px;
  background: var(--bg-primary);
  border-radius: var(--border-radius-xl);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all var(--transition-base);
  border: 1px solid var(--border-light);
}

.chatbot-container.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Chatbot Header */
.chatbot-header {
  background: var(--primary);
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.chatbot-avatar {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatbot-avatar i {
  font-size: 1.5rem;
  color: white;
}

.chatbot-header-text h3 {
  color: white;
  font-size: 1rem;
  margin: 0 0 0.125rem 0;
}

.chatbot-header-text p {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.75rem;
  margin: 0;
}

.chatbot-minimize {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.chatbot-minimize:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.chatbot-minimize i {
  color: white;
  font-size: 0.875rem;
}

/* Messages Area */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--bg-secondary);
}

.message {
  display: flex;
  gap: 0.75rem;
  animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.message-avatar i {
  font-size: 1rem;
  color: var(--primary);
}

.user-message .message-avatar {
  background: var(--primary);
}

.user-message .message-avatar i {
  color: white;
}

.message-content {
  flex: 1;
  background: var(--bg-primary);
  padding: 0.75rem 1rem;
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-sm);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-primary);
}

.user-message .message-content {
  background: var(--primary);
  color: white;
}

.message-content p {
  margin: 0 0 0.5rem 0;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content ul {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.message-content li {
  margin: 0.25rem 0;
}

.message-content a {
  color: var(--primary);
  text-decoration: underline;
}

.user-message .message-content a {
  color: white;
}

.message-content strong {
  font-weight: 700;
}

/* Typing Indicator */
.chatbot-typing {
  display: none;
  padding: 0.5rem 1rem;
  gap: 0.25rem;
  background: var(--bg-tertiary);
  border-radius: var(--border-radius-md);
  width: fit-content;
  margin-bottom: 0.5rem;
}

.chatbot-typing.active {
  display: flex;
}

.chatbot-typing span {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.chatbot-typing span:nth-child(1) {
  animation-delay: -0.32s;
}

.chatbot-typing span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typingBounce {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Input Area */
.chatbot-input-area {
  border-top: 1px solid var(--border-light);
  padding: 1rem;
  background: var(--bg-primary);
}

.input-wrapper {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.input-wrapper textarea {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-md);
  font-family: inherit;
  font-size: 0.875rem;
  resize: none;
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.input-wrapper textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius-md);
  background: var(--primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.send-btn:hover {
  background: var(--primary-dark);
  transform: scale(1.05);
}

.send-btn i {
  color: white;
  font-size: 1rem;
}

.chatbot-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  font-size: 0.625rem;
  color: var(--text-muted);
}

/* Error Message */
.error-message .message-content {
  background: #fee;
  color: #c33;
  border-left: 3px solid #c33;
}

[data-theme="dark"] .error-message .message-content {
  background: #3a1a1a;
  color: #ff8a8a;
}

/* Responsive */
@media (max-width: 768px) {
  .chatbot-container {
    width: calc(100vw - 2rem);
    right: 1rem;
    bottom: 70px;
    height: 500px;
  }
  
  .chatbot-widget {
    bottom: 1rem;
    right: 1rem;
  }
  
  .chatbot-toggle {
    width: 50px;
    height: 50px;
  }
  
  .chatbot-toggle i {
    font-size: 1.5rem;
  }
}

/* Scrollbar styling */
.chatbot-messages::-webkit-scrollbar {
  width: 4px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 4px;
}