/* ═══════════════════════════════════════════════════════════════
   CHATBOT INTERFACE
   ═══════════════════════════════════════════════════════════════ */

/* Chatbot Container */
.chatbot-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 10000;
  font-family: 'DM Sans', sans-serif;
}

/* Chat Window */
.chat-window {
  position: absolute;
  bottom: 90px;
  left: 0;
  width: 340px;
  max-height: 500px;
  background: linear-gradient(145deg, var(--card), var(--surface));
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.5),
    0 0 60px rgba(255, 46, 63, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: chatWindowAppear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-window.active {
  display: flex;
}

@keyframes chatWindowAppear {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Chat Header */
.chat-header {
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-avatar {
  font-size: 32px;
  animation: avatarBounce 2s ease-in-out infinite;
}

@keyframes avatarBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.chat-header-text h3 {
  color: white;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
}

.chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.9);
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #00e5a0;
  border-radius: 50%;
  animation: statusPulse 2s ease-in-out infinite;
}

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

.chat-close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: white;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  min-height: 200px;
  max-height: 350px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(0, 0, 0, 0.2);
}

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

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

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

.chat-message {
  display: flex;
  gap: 10px;
  animation: messageSlideIn 0.4s ease;
}

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

.message-avatar {
  font-size: 24px;
  flex-shrink: 0;
}

.message-content {
  background: rgba(255, 46, 63, 0.1);
  border: 1px solid rgba(255, 46, 63, 0.2);
  padding: 10px 14px;
  border-radius: 12px;
  border-top-left-radius: 4px;
  max-width: 240px;
}

.message-text {
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}

.message-time {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

/* Chat Options */
.chat-options {
  padding: 12px 16px 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
  margin-right: 4px;
}

.chat-options::-webkit-scrollbar {
  width: 6px;
}

.chat-options::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

.chat-options::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 3px;
}

.chat-options::-webkit-scrollbar-thumb:hover {
  background: var(--accent2);
}

.chat-option-btn {
  background: rgba(255, 46, 63, 0.1);
  border: 1px solid rgba(255, 46, 63, 0.3);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
  font-family: 'DM Sans', sans-serif;
  line-height: 1.5;
  min-height: 44px;
  display: flex;
  align-items: center;
  white-space: normal;
  word-wrap: break-word;
}

.chat-option-btn:hover {
  background: rgba(255, 46, 63, 0.2);
  border-color: var(--accent);
  transform: translateX(4px);
}

.chat-option-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 10px;
  padding: 0;
  animation: messageSlideIn 0.4s ease;
}

.typing-indicator .message-content {
  padding: 14px 18px;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  animation: typingDot 1.4s ease-in-out infinite;
}

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

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

@keyframes typingDot {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Fun Popup */
.fun-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: linear-gradient(135deg, var(--card), var(--surface));
  border: 2px solid var(--accent);
  border-radius: 20px;
  padding: 30px;
  text-align: center;
  z-index: 9999;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.5),
    0 0 80px rgba(255, 46, 63, 0.3);
  max-width: 400px;
  opacity: 0;
  pointer-events: none;
}

.fun-popup.show {
  animation: popupAppear 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  pointer-events: auto;
}

@keyframes popupAppear {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5) rotate(-10deg);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
}

.popup-emoji {
  font-size: 64px;
  margin-bottom: 16px;
  display: inline-block;
  animation: emojiSpin 0.8s ease;
}

@keyframes emojiSpin {
  0% { transform: rotate(0deg) scale(0.5); }
  50% { transform: rotate(180deg) scale(1.2); }
  100% { transform: rotate(360deg) scale(1); }
}

.popup-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 28px;
  color: var(--accent);
  margin-bottom: 12px;
  letter-spacing: 2px;
}

.popup-message {
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.popup-close-btn {
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  border: none;
  color: white;
  padding: 12px 30px;
  border-radius: 25px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.popup-close-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 46, 63, 0.4);
}

/* Popup Overlay */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.popup-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .chatbot-container {
    bottom: 80px;
  }

  .chat-window {
    width: calc(100vw - 40px);
    max-height: 400px;
  }

  .robot-emoji {
    font-size: 56px;
  }

  .fun-popup {
    width: calc(100vw - 40px);
    padding: 24px;
  }

  .popup-emoji {
    font-size: 48px;
  }

  .popup-title {
    font-size: 24px;
  }
}

/* Low power optimizations */
.low-power .chat-window,
.low-power .fun-popup,
.low-power .chat-message {
  animation: none !important;
}
