/* =========================================================
   CHATBOT STYLES - Draggable AI Assistant
   ========================================================= */

/* Floating Chat Button */
.chatbot-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0071e3, #5e5ce6);
  border: none;
  cursor: grab;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0, 113, 227, 0.4), 0 0 0 0 rgba(0, 113, 227, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
  touch-action: none;
}

.chatbot-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0, 113, 227, 0.5);
}

.chatbot-toggle:active {
  cursor: grabbing;
  transform: scale(1.02);
}

.chatbot-toggle.dragging {
  cursor: grabbing;
  transform: scale(1.05);
  box-shadow: 0 8px 32px rgba(0, 113, 227, 0.6);
}

.chatbot-toggle svg {
  width: 28px;
  height: 28px;
  fill: white;
  pointer-events: none;
}

/* Pulse animation when closed */
.chatbot-toggle:not(.active)::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  animation: chatPulse 2s ease-in-out infinite;
}

@keyframes chatPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 113, 227, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(0, 113, 227, 0); }
}

/* Chat Window */
.chatbot-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  height: 520px;
  max-height: calc(100vh - 140px);
  background: linear-gradient(180deg, rgba(20, 20, 25, 0.98) 0%, rgba(15, 15, 18, 0.98) 100%);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  z-index: 9997;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* Chat Header */
.chatbot-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(0, 113, 227, 0.15), rgba(94, 92, 230, 0.15));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbot-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0071e3, #5e5ce6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.chatbot-info {
  flex: 1;
}

.chatbot-name {
  font-weight: 600;
  font-size: 1rem;
  color: #f5f5f7;
  margin-bottom: 2px;
}

.chatbot-status {
  font-size: 0.75rem;
  color: #86868b;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chatbot-status::before {
  content: '';
  width: 8px;
  height: 8px;
  background: #30d158;
  border-radius: 50%;
  animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.chatbot-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #86868b;
  font-size: 18px;
  transition: all 0.2s ease;
}

.chatbot-close:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #f5f5f7;
}

/* Chat Messages */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

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

.chatbot-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

/* Message Bubbles */
.chat-message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.9rem;
  line-height: 1.5;
  animation: messageSlide 0.3s ease-out;
}

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

.chat-message.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.08);
  color: #f5f5f7;
  border-bottom-left-radius: 6px;
}

.chat-message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #0071e3, #5e5ce6);
  color: white;
  border-bottom-right-radius: 6px;
}

.chat-message.typing {
  display: flex;
  gap: 4px;
  padding: 16px 20px;
}

.chat-message.typing span {
  width: 8px;
  height: 8px;
  background: #86868b;
  border-radius: 50%;
  animation: typingDot 1.4s ease-in-out infinite;
}

.chat-message.typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-message.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-8px); }
}

/* Quick Actions */
.chatbot-quick-actions {
  padding: 8px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.quick-action {
  padding: 6px 12px;
  background: rgba(0, 113, 227, 0.15);
  border: 1px solid rgba(0, 113, 227, 0.25);
  border-radius: 16px;
  color: #64b5ff;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.quick-action:hover {
  background: rgba(0, 113, 227, 0.25);
  transform: translateY(-1px);
}

/* Chat Input */
.chatbot-input-area {
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chatbot-input {
  flex: 1;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  color: #f5f5f7;
  font-size: 0.9rem;
  font-family: inherit;
  resize: none;
  max-height: 100px;
  transition: all 0.2s ease;
}

.chatbot-input::placeholder {
  color: #86868b;
}

.chatbot-input:focus {
  outline: none;
  border-color: rgba(0, 113, 227, 0.5);
  background: rgba(255, 255, 255, 0.08);
}

.chatbot-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0071e3, #5e5ce6);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chatbot-send:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(0, 113, 227, 0.4);
}

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

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

/* Responsive */
@media (max-width: 480px) {
  .chatbot-window {
    width: calc(100vw - 32px);
    height: 65vh;
    max-height: 500px;
    min-height: 350px;
    right: 16px;
    left: 16px;
    bottom: 85px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  }
  
  .chatbot-toggle {
    width: 54px;
    height: 54px;
    bottom: 16px;
    right: 16px;
  }
  
  /* More visible close button on mobile */
  .chatbot-close {
    width: 36px;
    height: 36px;
    font-size: 20px;
    background: rgba(255, 59, 48, 0.15);
    color: #ff3b30;
    font-weight: bold;
  }
  
  .chatbot-close:hover,
  .chatbot-close:active {
    background: rgba(255, 59, 48, 0.3);
    color: #ff3b30;
  }
  
  .chatbot-header {
    padding: 14px 16px;
  }
  
  .chatbot-avatar {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
  
  .chatbot-name {
    font-size: 0.9rem;
  }
  
  .chatbot-status {
    font-size: 0.7rem;
  }
  
  .chatbot-messages {
    padding: 12px;
    gap: 10px;
  }
  
  .chat-message {
    max-width: 90%;
    font-size: 0.85rem;
    padding: 10px 14px;
  }
  
  .chatbot-quick-actions {
    padding: 6px 12px;
    gap: 6px;
  }
  
  .quick-action {
    padding: 5px 10px;
    font-size: 0.7rem;
  }
  
  .chatbot-input-area {
    padding: 10px 12px;
    gap: 8px;
  }
  
  .chatbot-input {
    padding: 10px 14px;
    font-size: 0.85rem;
  }
  
  .chatbot-send {
    width: 38px;
    height: 38px;
  }
  
  .chatbot-send svg {
    width: 18px;
    height: 18px;
  }
}

/* Mobile backdrop for tap-to-close */
.chatbot-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 9996;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.chatbot-backdrop.visible {
  opacity: 1;
  visibility: visible;
}

@media (max-width: 480px) {
  .chatbot-backdrop {
    display: block;
  }
}

/* Light Theme */
.light .chatbot-window {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(245, 245, 247, 0.98) 100%);
  border-color: rgba(0, 0, 0, 0.08);
}

.light .chatbot-header {
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

.light .chatbot-name {
  color: #1d1d1f;
}

.light .chat-message.bot {
  background: rgba(0, 0, 0, 0.05);
  color: #1d1d1f;
}

.light .chatbot-input {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: #1d1d1f;
}

.light .chatbot-input-area {
  border-top-color: rgba(0, 0, 0, 0.06);
}

.light .chatbot-close {
  background: rgba(0, 0, 0, 0.05);
}

.light .chatbot-close:hover {
  background: rgba(0, 0, 0, 0.1);
}
