
:root {
  --chatbot-primary: #0a1e2e;
  --chatbot-primary-light: #173753;
  --chatbot-secondary: #6c8ebf;
  --chatbot-accent: #9cbe7e;
  --chatbot-bg: #f2f1ec;
  --chatbot-white: #ffffff;
  --chatbot-text: #0a1e2e;
  --chatbot-text-light: #666666;
  --chatbot-shadow: rgba(0, 0, 0, 0.2);
  --chatbot-shadow-strong: rgba(0, 0, 0, 0.3);
}

/* ============================================
   Chat Toggle Button (Floating)
   ============================================ */
.chatbot-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-light) 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px var(--chatbot-shadow-strong);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chatbot-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 25px var(--chatbot-shadow-strong);
}

.chatbot-toggle svg {
  width: 28px;
  height: 28px;
  fill: var(--chatbot-white);
  transition: transform 0.3s ease;
}

.chatbot-toggle.active svg {
  transform: rotate(90deg);
}

/* Pulse animation for the toggle button */
.chatbot-toggle::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--chatbot-secondary);
  opacity: 0;
  animation: chatbot-pulse 2s ease-out infinite;
}

@keyframes chatbot-pulse {
  0% {
    transform: scale(1);
    opacity: 0.4;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* ============================================
   Chat Window Container
   ============================================ */
.chatbot-container {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 520px;
  max-height: calc(100vh - 140px);
  background: var(--chatbot-white);
  border-radius: 16px;
  box-shadow: 0 10px 40px var(--chatbot-shadow-strong);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
}

.chatbot-container.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ============================================
   Chat Header
   ============================================ */
.chatbot-header {
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-light) 100%);
  color: var(--chatbot-white);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.chatbot-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--chatbot-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  font-family: 'Poppins', sans-serif;
}

.chatbot-header-info {
  flex: 1;
}

.chatbot-header-title {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 16px;
  margin: 0;
}

.chatbot-header-status {
  font-family: 'Poppins', sans-serif;
  font-size: 12px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.chatbot-header-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--chatbot-accent);
}

.chatbot-close {
  background: none;
  border: none;
  color: var(--chatbot-white);
  cursor: pointer;
  padding: 4px;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.chatbot-close:hover {
  opacity: 1;
}

.chatbot-close svg {
  width: 20px;
  height: 20px;
}

/* ============================================
   Chat Messages Area
   ============================================ */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: var(--chatbot-bg);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Custom scrollbar */
.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

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

.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--chatbot-secondary);
  border-radius: 3px;
}

/* ============================================
   Message Bubbles
   ============================================ */
.chatbot-message {
  display: flex;
  gap: 10px;
  max-width: 85%;
  animation: chatbot-message-appear 0.3s ease-out;
}

@keyframes chatbot-message-appear {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chatbot-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chatbot-message.bot {
  align-self: flex-start;
}

.chatbot-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Poppins', sans-serif;
}

.chatbot-message.bot .chatbot-message-avatar {
  background: var(--chatbot-secondary);
  color: var(--chatbot-white);
}

.chatbot-message.user .chatbot-message-avatar {
  background: var(--chatbot-primary);
  color: var(--chatbot-white);
}

.chatbot-message-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-family: 'Poppins', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.chatbot-message.bot .chatbot-message-bubble {
  background: var(--chatbot-white);
  color: var(--chatbot-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px var(--chatbot-shadow);
}

.chatbot-message.user .chatbot-message-bubble {
  background: var(--chatbot-primary);
  color: var(--chatbot-white);
  border-bottom-right-radius: 4px;
}

/* ============================================
   Typing Indicator
   ============================================ */
.chatbot-typing {
  display: flex;
  gap: 10px;
  max-width: 85%;
  align-self: flex-start;
}

.chatbot-typing-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--chatbot-secondary);
  color: var(--chatbot-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Poppins', sans-serif;
}

.chatbot-typing-indicator {
  background: var(--chatbot-white);
  padding: 14px 18px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px var(--chatbot-shadow);
  display: flex;
  gap: 5px;
  align-items: center;
}

.chatbot-typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--chatbot-secondary);
  border-radius: 50%;
  animation: chatbot-typing-bounce 1.4s ease-in-out infinite;
}

.chatbot-typing-indicator span:nth-child(1) {
  animation-delay: 0s;
}

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

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

@keyframes chatbot-typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* ============================================
   Chat Input Area
   ============================================ */
.chatbot-input-area {
  padding: 16px;
  background: var(--chatbot-white);
  border-top: 1px solid #e8e8e8;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-shrink: 0;
  box-sizing: border-box;
  width: 100%;
  overflow: hidden;
}

.chatbot-input {
  flex: 1;
  min-width: 0;
  border: 2px solid #e8e8e8;
  border-radius: 24px;
  padding: 12px 18px;
  font-family: 'Poppins', sans-serif;
  font-size: 14px;
  resize: none;
  outline: none;
  max-height: 100px;
  line-height: 1.4;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.chatbot-input:focus {
  border-color: var(--chatbot-secondary);
}

.chatbot-input::placeholder {
  color: var(--chatbot-text-light);
}

.chatbot-send {
  width: 44px;
  min-width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--chatbot-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, transform 0.2s;
  flex-shrink: 0;
  box-sizing: border-box;
}

.chatbot-send:hover {
  background: var(--chatbot-primary-light);
  transform: scale(1.05);
}

.chatbot-send:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

.chatbot-send svg {
  width: 20px;
  height: 20px;
  fill: var(--chatbot-white);
}

/* ============================================
   Mobile Responsive Styles (Phones)
   ============================================ */
@media (max-width: 480px) {
  .chatbot-container {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    /* Handle mobile keyboard viewport */
    height: 100dvh;
    max-height: 100dvh;
    /* Prevent any transform/zoom issues */
    transform: none !important;
  }

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

  /* Hide the toggle button when chat is open on mobile */
  .chatbot-toggle.active {
    display: none;
  }

  .chatbot-header {
    padding: 16px;
    flex-shrink: 0;
  }

  .chatbot-messages {
    padding: 16px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }

  .chatbot-input-area {
    padding: 12px;
    flex-shrink: 0;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
  }

  .chatbot-input {
    min-width: 0;
    flex: 1;
    box-sizing: border-box;
    /* IMPORTANT: 16px prevents iOS auto-zoom on input focus */
    font-size: 16px !important;
    /* Prevent zoom on touch */
    touch-action: manipulation;
  }

  .chatbot-send {
    flex-shrink: 0;
    width: 44px;
    min-width: 44px;
    /* Prevent zoom on touch */
    touch-action: manipulation;
  }

  .chatbot-message-bubble {
    /* Ensure readable size without zoom */
    font-size: 15px;
  }
}

/* Extra small screens (small phones) */
@media (max-width: 360px) {
  .chatbot-input-area {
    padding: 10px;
    gap: 8px;
  }

  .chatbot-input {
    padding: 10px 14px;
    /* Keep at 16px to prevent iOS zoom */
    font-size: 16px !important;
  }

  .chatbot-send {
    width: 40px;
    min-width: 40px;
    height: 40px;
  }
}

