/* Ultra-Premium Glassmorphic Chatbot Widget Design System - Customized for BuildYour.quest */

:root {
  /* Adapted BuildYour.quest Color & UI Token System */
  --chat-primary: var(--color-primary, #6B4EFF);
  --chat-primary-hover: var(--color-primary-light, #8B6FFF);
  --chat-accent: var(--color-secondary, #3B82F6);
  --chat-bg: rgba(26, 29, 46, 0.95);  /* Deep dark background matching --color-dark #1A1D2E */
  --chat-glass-bg: rgba(42, 45, 62, 0.7); /* Translucent dark matching --color-dark-alt #2A2D3E */
  --chat-glass-border: rgba(255, 255, 255, 0.08);
  --chat-text-main: var(--color-white, #FFFFFF);
  --chat-text-muted: var(--color-gray-light, #9CA3AF);
  --chat-user-bubble: var(--color-primary-dark, #4B2EDF);
  --chat-ai-bubble: rgba(42, 45, 62, 0.5);
  --chat-font: var(--font-body, 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif);
  --chat-shadow: var(--shadow-xl, 0 20px 40px rgba(0, 0, 0, 0.4));
  --chat-radius-large: var(--radius-2xl, 24px);
  --chat-radius-small: var(--radius-xl, 16px);
}

/* Floating Action Button (FAB) */
.chat-widget-fab {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-hover));
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 30px rgba(107, 78, 255, 0.4);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 99999;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.chat-widget-fab:hover {
  transform: scale(1.08) rotate(5deg);
  box-shadow: 0 12px 35px rgba(107, 78, 255, 0.6);
}

.chat-widget-fab:active {
  transform: scale(0.95);
}

.chat-widget-fab svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: var(--chat-text-main);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.4s ease;
}

.chat-widget-fab.open svg {
  transform: rotate(90deg);
}

/* Ripple effect on FAB */
.chat-widget-fab::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 50%;
  border: 2px solid var(--chat-primary);
  opacity: 0;
  animation: pulse-ripple 2.5s infinite;
}

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

/* Chat Main Window */
.chat-widget-window {
  position: fixed;
  bottom: 110px;
  right: 30px;
  width: 400px;
  height: 600px;
  border-radius: var(--chat-radius-large);
  background: var(--chat-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--chat-glass-border);
  box-shadow: var(--chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99998;
  font-family: var(--chat-font);
  color: var(--chat-text-main);
  transform: translateY(30px) scale(0.9);
  opacity: 0;
  pointer-events: none;
  transition: all 0.45s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.chat-widget-window.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* Chat Header */
.chat-widget-header {
  padding: 20px 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, transparent 100%);
  border-bottom: 1px solid var(--chat-glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-widget-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-widget-avatar-container {
  position: relative;
  width: 44px;
  height: 44px;
}

.chat-widget-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 18px;
}

.chat-widget-status-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--chat-accent);
  border: 2px solid #0f172a;
}

.chat-widget-info {
  display: flex;
  flex-direction: column;
}

.chat-widget-title {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.2px;
}

.chat-widget-subtitle {
  font-size: 12px;
  color: var(--chat-text-muted);
}

.chat-widget-close {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--chat-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.chat-widget-close:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--chat-text-main);
}

/* Chat Messages Container */
.chat-widget-messages {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

/* Custom Scrollbar */
.chat-widget-messages::-webkit-scrollbar {
  width: 6px;
}
.chat-widget-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-widget-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}
.chat-widget-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Message Bubbles */
.chat-message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 82%;
  animation: message-fade-in 0.3s cubic-bezier(0.215, 0.610, 0.355, 1) forwards;
}

@keyframes message-fade-in {
  0% { transform: translateY(12px) scale(0.96); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

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

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

.chat-message-bubble {
  padding: 12px 18px;
  line-height: 1.5;
  font-size: 14.5px;
}

.chat-message.user .chat-message-bubble {
  background-color: var(--chat-user-bubble);
  border: 1px solid rgba(107, 78, 255, 0.2);
  border-radius: var(--chat-radius-small) var(--chat-radius-small) 4px var(--chat-radius-small);
  color: var(--chat-text-main);
}

.chat-message.ai .chat-message-bubble {
  background: var(--chat-ai-bubble);
  border: 1px solid var(--chat-glass-border);
  border-radius: var(--chat-radius-small) var(--chat-radius-small) var(--chat-radius-small) 4px;
  color: var(--chat-text-main);
}

/* Bold lists and code inside messages */
.chat-message-bubble p {
  margin: 0 0 8px 0;
}
.chat-message-bubble p:last-child {
  margin-bottom: 0;
}
.chat-message-bubble ul, .chat-message-bubble ol {
  margin: 4px 0;
  padding-left: 20px;
}
.chat-message-bubble li {
  margin-bottom: 4px;
}

/* Dynamic Lead Capture Card / Forms */
.lead-capture-card {
  background: linear-gradient(135deg, rgba(107, 78, 255, 0.15) 0%, rgba(30, 41, 59, 0.5) 100%);
  border: 1px solid rgba(107, 78, 255, 0.3);
  border-radius: var(--chat-radius-small);
  padding: 16px;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: lead-card-intro 0.4s ease forwards;
}

@keyframes lead-card-intro {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.lead-capture-card h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #c7d2fe;
}

.lead-input {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--chat-glass-border);
  border-radius: 8px;
  padding: 10px 12px;
  color: white;
  font-family: var(--chat-font);
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease;
}

.lead-input:focus {
  border-color: var(--chat-primary);
  box-shadow: 0 0 0 2px rgba(107, 78, 255, 0.25);
}

.lead-input.textarea {
  resize: none;
  height: 60px;
}

.lead-submit-btn {
  background: var(--chat-primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
}

.lead-submit-btn:hover {
  background: var(--chat-primary-hover);
}

/* Typing Indicator Animation */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-radius: 12px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background-color: var(--chat-text-muted);
  border-radius: 50%;
  animation: bounce-dot 1.4s infinite ease-in-out both;
}

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

@keyframes bounce-dot {
  0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}

/* Chat Input Footer */
.chat-widget-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--chat-glass-border);
  background: rgba(15, 23, 42, 0.4);
}

.chat-widget-input-container {
  display: flex;
  align-items: center;
  background: var(--chat-glass-bg);
  border: 1px solid var(--chat-glass-border);
  border-radius: 30px;
  padding: 6px 6px 6px 16px;
  transition: all 0.3s ease;
}

.chat-widget-input-container:focus-within {
  border-color: rgba(107, 78, 255, 0.5);
  box-shadow: 0 0 15px rgba(107, 78, 255, 0.15);
}

.chat-widget-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--chat-text-main);
  font-family: var(--chat-font);
  font-size: 14.5px;
  padding: 6px 0;
}

.chat-widget-input::placeholder {
  color: var(--chat-text-muted);
  opacity: 0.8;
}

.chat-widget-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--chat-primary);
  border: none;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.25s ease;
}

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

.chat-widget-send svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: white;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Mobile Responsive Adjustments */
@media (max-width: 480px) {
  .chat-widget-window {
    width: 100% !important;
    height: 100% !important;
    bottom: 0 !important;
    right: 0 !important;
    border-radius: 0 !important;
  }
  .chat-widget-fab {
    bottom: 20px;
    right: 20px;
  }
}
