/* ============================================
   KATHMANDU SERVICES - AI CHATBOT
   Floating Chat Widget - Lower Left
   ============================================ */

/* ---------- Chat Launcher Button ---------- */
.chatbot-launcher {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0F4C81 0%, #1E88E5 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 10px 30px rgba(15, 76, 129, 0.4);
  cursor: pointer;
  z-index: 997;
  transition: all 0.3s ease;
  border: none;
  outline: none;
  animation: launcherPulse 2s ease-in-out infinite;
}

.chatbot-launcher:hover {
  transform: scale(1.1);
  box-shadow: 0 15px 40px rgba(15, 76, 129, 0.5);
}

.chatbot-launcher::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0F4C81 0%, #00C853 100%);
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.chatbot-launcher:hover::before {
  opacity: 1;
  animation: ping 1.5s ease-out infinite;
}

@keyframes launcherPulse {
  0%, 100% { box-shadow: 0 10px 30px rgba(15, 76, 129, 0.4), 0 0 0 0 rgba(15, 76, 129, 0.5); }
  50% { box-shadow: 0 10px 30px rgba(15, 76, 129, 0.4), 0 0 0 12px rgba(15, 76, 129, 0); }
}

@keyframes ping {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.3); opacity: 0; }
}

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

.chatbot-launcher.active .icon-open {
  display: none;
}

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

/* Notification badge on launcher */
.chatbot-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: #00C853;
  color: white;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  animation: badgeBounce 2s ease-in-out infinite;
}

@keyframes badgeBounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* ---------- Chat Window ---------- */
.chatbot-window {
  position: fixed;
  bottom: 100px;
  left: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 560px;
  max-height: calc(100vh - 140px);
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  z-index: 998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.8) translateY(20px);
  transform-origin: bottom left;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

.dark-mode .chatbot-window {
  background: #1B2838;
  color: #E8ECF0;
}

/* ---------- Chat Header ---------- */
.chatbot-header {
  background: linear-gradient(135deg, #0F4C81 0%, #1E88E5 100%);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: white;
  position: relative;
}

.chatbot-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  position: relative;
  flex-shrink: 0;
}

.chatbot-avatar::after {
  content: '';
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  background: #00C853;
  border: 2px solid white;
  border-radius: 50%;
}

.chatbot-info h4 {
  font-size: 1rem;
  margin: 0 0 2px;
  color: white;
}

.chatbot-info p {
  font-size: 0.75rem;
  margin: 0;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chatbot-info p::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #00C853;
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

.chatbot-header-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.chatbot-header-actions button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.3s ease;
  border: none;
}

.chatbot-header-actions button:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ---------- Chat Messages ---------- */
.chatbot-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #F5F7FA;
  scroll-behavior: smooth;
}

.dark-mode .chatbot-messages {
  background: #0D1B2A;
}

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

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

.chatbot-messages::-webkit-scrollbar-thumb {
  background: #CBD5E0;
  border-radius: 3px;
}

.dark-mode .chatbot-messages::-webkit-scrollbar-thumb {
  background: #2D3F54;
}

/* ---------- Chat Messages ---------- */
.chat-message {
  display: flex;
  gap: 10px;
  animation: messageSlide 0.3s ease;
  max-width: 85%;
}

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

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

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

.chat-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.chat-message.bot .chat-message-avatar {
  background: linear-gradient(135deg, #0F4C81, #1E88E5);
  color: white;
}

.chat-message.user .chat-message-avatar {
  background: linear-gradient(135deg, #00C853, #69F0AE);
  color: white;
}

.chat-message-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.9375rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-message.bot .chat-message-bubble {
  background: white;
  color: #1A2B3C;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.dark-mode .chat-message.bot .chat-message-bubble {
  background: #243447;
  color: #E8ECF0;
}

.chat-message.user .chat-message-bubble {
  background: linear-gradient(135deg, #0F4C81, #1E88E5);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-message-time {
  font-size: 0.7rem;
  color: #6B7B8C;
  margin-top: 4px;
  padding: 0 4px;
}

.chat-message.user .chat-message-time {
  text-align: right;
}

/* ---------- Typing Indicator ---------- */
.chat-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: white;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.dark-mode .chat-typing {
  background: #243447;
}

.chat-typing-dot {
  width: 8px;
  height: 8px;
  background: #6B7B8C;
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.chat-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.chat-typing-dot: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; }
}

/* ---------- Quick Replies ---------- */
.chat-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  padding: 0 4px;
}

.chat-quick-reply {
  padding: 6px 14px;
  background: white;
  color: #0F4C81;
  border: 1.5px solid #0F4C81;
  border-radius: 20px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dark-mode .chat-quick-reply {
  background: #243447;
  color: #1E88E5;
  border-color: #1E88E5;
}

.chat-quick-reply:hover {
  background: #0F4C81;
  color: white;
  transform: translateY(-2px);
}

.dark-mode .chat-quick-reply:hover {
  background: #1E88E5;
  color: white;
}

/* ---------- Chat Input ---------- */
.chatbot-input-area {
  padding: 12px 16px;
  background: white;
  border-top: 1px solid #E4E9F0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dark-mode .chatbot-input-area {
  background: #1B2838;
  border-top-color: #2D3F54;
}

.chatbot-input {
  flex: 1;
  padding: 10px 16px;
  border: 1.5px solid #E4E9F0;
  border-radius: 24px;
  font-size: 0.9375rem;
  outline: none;
  transition: border-color 0.3s ease;
  background: #F5F7FA;
  color: #1A2B3C;
}

.dark-mode .chatbot-input {
  background: #0D1B2A;
  border-color: #2D3F54;
  color: #E8ECF0;
}

.chatbot-input:focus {
  border-color: #1E88E5;
}

.chatbot-input::placeholder {
  color: #6B7B8C;
}

.chatbot-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0F4C81, #1E88E5);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.chatbot-send:hover {
  transform: scale(1.1);
  box-shadow: 0 5px 15px rgba(15, 76, 129, 0.4);
}

.chatbot-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ---------- Suggested Services in Chat ---------- */
.chat-suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.chat-suggestion-card {
  padding: 10px;
  background: white;
  border: 1.5px solid #E4E9F0;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.dark-mode .chat-suggestion-card {
  background: #243447;
  border-color: #2D3F54;
}

.chat-suggestion-card:hover {
  border-color: #1E88E5;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(30, 136, 229, 0.2);
}

.chat-suggestion-card i {
  font-size: 1.5rem;
  color: #0F4C81;
  margin-bottom: 4px;
}

.dark-mode .chat-suggestion-card i {
  color: #1E88E5;
}

.chat-suggestion-card span {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
}

/* ---------- Responsive ---------- */
@media (max-width: 575px) {
  .chatbot-window {
    width: calc(100vw - 32px);
    height: calc(100vh - 140px);
    bottom: 90px;
    left: 16px;
  }
  
  .chatbot-launcher {
    bottom: 16px;
    left: 16px;
    width: 56px;
    height: 56px;
    font-size: 1.25rem;
  }
  
  .chat-suggestions {
    grid-template-columns: 1fr;
  }
}

/* Floating call/whatsapp repositioning when chatbot is on left */
@media (min-width: 768px) {
  .floating-buttons {
    left: auto;
    right: 24px;
    bottom: 100px;
  }
  
  .back-to-top {
    bottom: 100px;
    right: 24px;
  }
}
