/* Chatbot Container */
.chatbot-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 1031; /* slightly above navbar (z-fixed:1030) when closed */
  font-family: var(--font-primary);
}

/* Raise only when chat is open */
body.chatbot-open .chatbot-container { z-index: 10000; }

/* Chatbot Toggle Button */
.chatbot-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--gradient-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
}

.chatbot-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.chatbot-toggle i {
  color: var(--color-white);
  font-size: 1.5rem;
}

.chatbot-toggle.active {
  background: var(--color-primary);
}

/* Chatbot Window */
.chatbot-window {
  display: none; /* Hidden by default to avoid any invisible overlay */
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 350px;
  height: 500px;
  background: var(--color-white);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.9);
  transition: all 0.3s ease;
  border: 1px solid var(--color-gray-200);
  /* Critical: do not capture clicks when hidden */
  pointer-events: none;
}

.chatbot-window.active {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Chatbot Header */
.chatbot-header {
  background: var(--gradient-primary);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--color-white);
}

.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

/* Ensure custom avatar image renders circular and contained */
.chatbot-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.chatbot-title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin: 0;
}

.chatbot-subtitle {
  font-size: var(--text-sm);
  opacity: 0.9;
  margin: 0;
}

.chatbot-close {
  background: none;
  border: none;
  color: var(--color-white);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: background-color 0.3s ease;
}

.chatbot-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Chatbot Messages */
.chatbot-messages {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--color-gray-50);
}

.chatbot-message {
  display: flex;
  gap: 0.75rem;
  animation: messageSlideIn 0.3s ease;
}

.chatbot-message.user {
  flex-direction: row-reverse;
}

.chatbot-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.chatbot-message.bot .chatbot-message-avatar {
  background: transparent;
  color: inherit;
}

.chatbot-message.user .chatbot-message-avatar {
  background: transparent;
  color: inherit;
}

.chatbot-message-content {
  max-width: 70%;
  padding: 0.75rem 1rem;
  border-radius: 18px;
  font-size: var(--text-sm);
  line-height: 1.4;
}

.chatbot-message.bot .chatbot-message-content {
  background: var(--color-white);
  color: var(--color-gray-700);
  border: 1px solid var(--color-gray-200);
  border-bottom-left-radius: 4px;
}

.chatbot-message.user .chatbot-message-content {
  background: var(--color-primary);
  color: var(--color-white);
  border-bottom-right-radius: 4px;
}

/* Chatbot Input */
.chatbot-input-container {
  padding: 1rem;
  background: var(--color-white);
  border-top: 1px solid var(--color-gray-200);
}

.chatbot-input-form {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.chatbot-input {
  flex: 1;
  border: 1px solid var(--color-gray-300);
  border-radius: 20px;
  padding: 0.75rem 1rem;
  font-size: var(--text-sm);
  font-family: var(--font-primary);
  resize: none;
  max-height: 100px;
  min-height: 44px;
}

.chatbot-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.chatbot-send {
  background: var(--gradient-primary);
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-white);
}

/* Quick Replies */
.chatbot-quick-replies {
  padding: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  max-height: 120px;
  overflow-y: auto;
}

.chatbot-quick-reply {
  background: var(--color-white);
  border: 1px solid var(--color-gray-300);
  border-radius: 16px;
  padding: 0.4rem 0.8rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.3s ease;
  color: var(--color-gray-700);
  margin: 0.2rem;
  display: inline-block;
  white-space: nowrap;
  max-width: 120px;
  text-overflow: ellipsis;
  overflow: hidden;
}

.chatbot-quick-reply:hover {
  background: var(--color-primary);
  color: var(--color-white);
  border-color: var(--color-primary);
}

/* Help Button */
.chatbot-help-button {
  background: var(--color-gray-100);
  border: 1px solid var(--color-gray-300);
  border-radius: 20px;
  padding: 0.5rem 1rem;
  font-size: var(--text-xs);
  cursor: pointer;
  transition: all 0.3s ease;
  color: var(--color-gray-600);
  margin: 0.25rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.chatbot-help-button:hover {
  background: var(--color-primary);
  color: var(--color-white);
  border-color: var(--color-primary);
  transform: translateY(-1px);
}

/* Animations */
@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .chatbot-container {
    bottom: 1rem;
    right: 1rem;
  }
  
  .chatbot-window {
    width: calc(100vw - 2rem);
    height: 60vh;
    right: 0;
    bottom: 80px;
  }
}

@media (max-width: 480px) {
  .chatbot-window {
    width: calc(100vw - 1rem);
    height: 70vh;
    bottom: 70px;
  }
} 

/* Interaction safety: prevent the floating container from blocking clicks outside the widget */
.chatbot-container { pointer-events: none; }
.chatbot-toggle, .chatbot-toggle *, .chatbot-window, .chatbot-window * { pointer-events: auto; }

/* When the mobile menu is open, hide chatbot to avoid overlap with navigation */
body.mobile-menu-open .chatbot-container { display: none; }