/* ===== CHATBOX AI ASSISTANT STYLES ===== */

/* Nút mở/đóng chatbox - icon tròn góc dưới phải màn hình */
.chatbox-toggle {
  position: fixed;
  bottom: 25px;
  right: 25px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #4502c7, #6f42c1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(69, 2, 199, 0.4);
  z-index: 9999;
  transition: all 0.3s ease;
  border: none;
}

.chatbox-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 25px rgba(69, 2, 199, 0.5);
}

.chatbox-toggle i {
  color: white;
  font-size: 28px;
  transition: all 0.3s ease;
}

/* Hiển thị icon X khi chatbox mở */
.chatbox-toggle.active i.fa-message {
  display: none;
}

.chatbox-toggle i.fa-xmark {
  display: none;
}

.chatbox-toggle.active i.fa-xmark {
  display: block;
}

/* Cửa sổ chatbox */
.chatbox-container {
  position: fixed;
  bottom: 100px; /* Đặt ngay trên nút chatbot */
  right: 25px;
  width: 380px;
  max-height: 600px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  display: none;
  flex-direction: column;
  z-index: 9998;
  overflow: hidden;
  animation: slideUp 0.3s ease;
}

.chatbox-container.active {
  display: flex;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Header chatbox */
.chatbox-header {
  background: linear-gradient(135deg, #4502c7, #6f42c1);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbox-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #4502c7;
  flex-shrink: 0;
}

.chatbox-header-info {
  flex: 1;
}

.chatbox-header-info h4 {
  color: white;
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 3px 0;
}

.chatbox-header-info p {
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  margin: 0;
}

/* Nội dung chat */
.chatbox-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  max-height: 400px;
  background: #f8f9fa;
}

.chatbox-body::-webkit-scrollbar {
  width: 6px;
}

.chatbox-body::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.chatbox-body::-webkit-scrollbar-thumb {
  background: #4502c7;
  border-radius: 3px;
}

.chatbox-body::-webkit-scrollbar-thumb:hover {
  background: #3602a0;
}

/* ===== FIX: Tin nhắn không bị đẩy xa avatar ===== */
.chat-message {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  animation: fadeIn 0.3s ease;
  align-items: flex-start; /* Căn từ trên xuống */
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-message.user {
  flex-direction: row-reverse;
}

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #4502c7;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 4px; /* Căn với dòng đầu tiên */
}

.chat-message.user .chat-avatar {
  background: #e91e63;
}

/* Wrapper cho bubble + time */
.chat-message > div:last-child {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: calc(100% - 42px); /* Trừ avatar + gap */
}

/* Bubble tự động co giãn */
.chat-bubble {
  width: fit-content;
  max-width: 100%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.chat-message.bot .chat-bubble {
  background: white;
  color: #2d3748;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.chat-message.user .chat-bubble {
  background: #4502c7;
  color: white;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

.chat-time {
  font-size: 11px;
  color: #6c757d;
  margin-top: 4px;
  display: block;
  align-self: flex-start;
}

.chat-message.user .chat-time {
  align-self: flex-end;
}

/* Typing indicator - hiệu ứng đang gõ */
.typing-indicator {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: white;
  border-radius: 16px;
  width: fit-content;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  margin-bottom: 16px;
}

.typing-indicator.active {
  display: flex;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4502c7;
  animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Tour suggestions - gợi ý tour */
.chat-tour-suggestions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.chat-tour-card {
  background: white;
  border-radius: 10px;
  padding: 12px;
  border: 1px solid #e9ecef;
  transition: all 0.3s ease;
  text-decoration: none;
  color: inherit;
  display: block;
}

.chat-tour-card:hover {
  border-color: #4502c7;
  box-shadow: 0 4px 12px rgba(69, 2, 199, 0.15);
  transform: translateY(-2px);
}

.chat-tour-card h5 {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
  margin: 0 0 6px 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.chat-tour-card p {
  font-size: 13px;
  color: #4502c7;
  font-weight: 600;
  margin: 0;
}

/* Footer chatbox - input gửi tin nhắn */
.chatbox-footer {
  padding: 16px;
  background: white;
  border-top: 1px solid #e9ecef;
}

.chatbox-input-wrapper {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chatbox-input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  transition: all 0.3s ease;
  font-family: inherit;
}

.chatbox-input:focus {
  border-color: #4502c7;
  box-shadow: 0 0 0 3px rgba(69, 2, 199, 0.1);
}

.chatbox-input::placeholder {
  color: #a0aec0;
}

.chatbox-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #4502c7;
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.chatbox-send-btn:hover:not(:disabled) {
  background: #3602a0;
  transform: scale(1.05);
}

.chatbox-send-btn:disabled {
  background: #cbd5e0;
  cursor: not-allowed;
  opacity: 0.6;
}

.chatbox-send-btn i {
  font-size: 16px;
}

/* Responsive - Mobile */
@media (max-width: 576px) {
  .chatbox-container {
    width: calc(100vw - 30px);
    right: 15px;
    bottom: 90px;
    max-height: 70vh;
  }

  .chatbox-toggle {
    bottom: 20px;
    right: 20px;
    width: 55px;
    height: 55px;
  }

  .chatbox-toggle i {
    font-size: 24px;
  }

  .chatbox-body {
    max-height: 50vh;
  }

  .chat-message > div:last-child {
    max-width: calc(100% - 37px);
  }
}

@media (max-width: 400px) {
  .chatbox-container {
    width: calc(100vw - 20px);
    right: 10px;
  }

  .chatbox-header {
    padding: 14px 16px;
  }

  .chatbox-body {
    padding: 15px;
  }
}