/*=============== PREMIUM CHATBOT DESIGN ===============*/

/* Chatbot Container with Glassmorphism */
#chatbot {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  background: linear-gradient(145deg,
    rgba(255, 255, 255, 0.08) 0%,
    rgba(255, 255, 255, 0.03) 100%);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  padding: 0;
  border-radius: 24px;
  max-width: 380px;
  width: 380px;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  display: flex;
  flex-direction: column;
  gap: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  height: 550px;
  max-height: 80vh;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

#chatbot.open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: all;
}

#chatbot.closed {
  opacity: 0;
  transform: scale(0.9) translateY(20px);
  pointer-events: none;
}

/* Chatbot Header */
#chatbot::before {
  content: '💬 Chat with Lashvin AI';
  display: block;
  background: linear-gradient(135deg,
    var(--first-color) 0%,
    var(--accent-color) 100%);
  color: #fff;
  padding: 1.2rem 1.5rem;
  font-weight: 600;
  font-size: 1.05rem;
  border-radius: 24px 24px 0 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  position: relative;
  z-index: 2;
  letter-spacing: 0.3px;
}

/* Chat Messages Area */
#chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1.2rem 1.5rem;
  background: transparent;
  scroll-behavior: smooth;
  position: relative;
}

/* Custom Scrollbar */
#chat-messages::-webkit-scrollbar {
  width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
}

#chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  transition: background 0.2s;
}

#chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* For Firefox */
#chat-messages {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) rgba(255, 255, 255, 0.03);
}

/* Message Bubbles */
#chat-messages > div {
  margin: 0.8rem 0;
  padding: 1rem 1.2rem;
  border-radius: 18px;
  max-width: 80%;
  word-wrap: break-word;
  position: relative;
  animation: messageSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  line-height: 1.5;
  font-size: 0.95rem;
}

/* User Messages */
#chat-messages > div[style*="marginLeft"] {
  background: linear-gradient(135deg,
    var(--first-color) 0%,
    var(--accent-color) 100%);
  color: #fff;
  margin-left: auto !important;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(var(--first-hue), var(--sat), var(--lig), 0.3);
}

/* Bot Messages */
#chat-messages > div[style*="marginRight"] {
  background: linear-gradient(135deg,
    rgba(255, 255, 255, 0.1) 0%,
    rgba(255, 255, 255, 0.05) 100%);
  color: rgba(255, 255, 255, 0.95);
  margin-right: auto !important;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Typing Indicator */
#chat-messages > div:last-child[style*="color: rgb(170, 170, 170)"] {
  animation: pulse 1.5s ease-in-out infinite;
}

/* Input Container */
#chatbot > div[style*="display:flex"] {
  padding: 1rem 1.5rem;
  background: linear-gradient(180deg,
    rgba(255, 255, 255, 0.02) 0%,
    rgba(255, 255, 255, 0.05) 100%);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0 0 24px 24px;
  gap: 0.75rem !important;
  align-items: center !important;
}

/* Input Field */
#chat-input {
  flex: 1;
  padding: 0.85rem 1.2rem !important;
  border-radius: 16px !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  background: rgba(255, 255, 255, 0.05) !important;
  color: #fff !important;
  font-size: 0.95rem !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  width: auto !important;
  margin: 0 !important;
}

#chat-input:focus {
  outline: none !important;
  border-color: var(--first-color) !important;
  background: rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 0 0 3px rgba(var(--first-hue), var(--sat), var(--lig), 0.15) !important;
}

#chat-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

/* Send Button */
#chat-send {
  padding: 0.85rem 1.5rem !important;
  border-radius: 16px !important;
  border: none !important;
  background: linear-gradient(135deg,
    var(--first-color) 0%,
    var(--accent-color) 100%) !important;
  color: #fff !important;
  cursor: pointer !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  font-weight: 600 !important;
  font-size: 0.95rem !important;
  box-shadow: 0 4px 12px rgba(var(--first-hue), var(--sat), var(--lig), 0.3) !important;
  margin: 0 !important;
  min-width: 80px;
}

#chat-send:hover:not(:disabled) {
  transform: translateY(-2px) !important;
  box-shadow: 0 6px 20px rgba(var(--first-hue), var(--sat), var(--lig), 0.4) !important;
}

#chat-send:active:not(:disabled) {
  transform: translateY(0) !important;
}

#chat-send:disabled {
  background: linear-gradient(135deg,
    rgba(255, 255, 255, 0.1) 0%,
    rgba(255, 255, 255, 0.05) 100%) !important;
  cursor: not-allowed !important;
  box-shadow: none !important;
  opacity: 0.5 !important;
}

/* Floating Chat Bubble - Enhanced */
.floating-chat-bubble {
  position: fixed;
  background: linear-gradient(135deg,
    var(--first-color) 0%,
    var(--accent-color) 100%);
  color: #fff;
  padding: 0.85rem 1.5rem;
  border-radius: 24px;
  box-shadow:
    0 8px 24px rgba(var(--first-hue), var(--sat), var(--lig), 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.1);
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  z-index: 10001;
  cursor: default;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  animation: float-bounce-premium 1.2s cubic-bezier(.4, 2, .6, 1) 1;
  letter-spacing: 0.3px;
}

.floating-chat-bubble::after {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  border-width: 8px;
  border-style: solid;
  border-color: transparent var(--first-color) transparent transparent;
  filter: drop-shadow(-2px 0 4px rgba(0, 0, 0, 0.1));
}

/* Animations */
@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

@keyframes float-bounce-premium {
  0% {
    opacity: 0;
    transform: translateY(-30px) scale(0.9);
  }
  60% {
    opacity: 1;
    transform: translateY(5px) scale(1.05);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Mobile Responsive */
@media (max-width: 768px) {
  #chatbot {
    right: 12px;
    left: 12px;
    bottom: 12px;
    max-width: none;
    width: auto;
    height: 70vh;
    border-radius: 20px;
  }

  #chatbot::before {
    padding: 1rem 1.2rem;
    font-size: 1rem;
    border-radius: 20px 20px 0 0;
  }

  #chat-messages {
    padding: 1rem;
  }

  #chatbot > div[style*="display:flex"] {
    padding: 0.85rem 1rem;
    border-radius: 0 0 20px 20px;
  }

  #chat-input {
    padding: 0.75rem 1rem !important;
    font-size: 0.9rem !important;
  }

  #chat-send {
    padding: 0.75rem 1.2rem !important;
    font-size: 0.9rem !important;
    min-width: 70px;
  }

  #chat-messages > div {
    padding: 0.85rem 1rem;
    font-size: 0.9rem;
  }

  .floating-chat-bubble {
    font-size: 0.9rem;
    padding: 0.7rem 1.2rem;
    border-radius: 20px;
  }

  .floating-chat-bubble::after {
    left: 50%;
    top: -14px;
    transform: translateX(-50%);
    border-width: 8px;
    border-color: transparent transparent var(--first-color) transparent;
  }
}

/* Desktop: Larger chatbot */
@media (min-width: 1024px) {
  #chatbot {
    width: 420px;
    height: 600px;
  }
}

/* Smooth entrance animation */
@media (prefers-reduced-motion: no-preference) {
  #chatbot.open {
    animation: chatbotEntrance 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }
}

@keyframes chatbotEntrance {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(40px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
