/**
 * Chatbot Popup Styles
 * Aurora-themed floating chat widget
 */

/* CSS Variables (inherit from parent or define fallbacks) */
.chatbot-toggle,
.chatbot-popup {
  --chatbot-bg: rgba(5, 8, 18, 0.95);
  --chatbot-glass: rgba(10, 15, 25, 0.85);
  --chatbot-line: rgba(255, 255, 255, 0.12);
  --chatbot-text: rgba(255, 255, 255, 0.95);
  --chatbot-muted: rgba(230, 235, 240, 0.75);
  --chatbot-accent: #2ED0C0;
  --chatbot-accent2: #34D399;
  --chatbot-radius: 20px;
  --chatbot-ease: cubic-bezier(.2,.8,.2,1);
}

/* ========================================
   Toggle Button (Floating Action Button)
   ======================================== */
.chatbot-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid rgba(100, 200, 180, 0.3);
  background: linear-gradient(135deg, rgba(46,208,192,0.25), rgba(52,211,153,0.20), rgba(100,216,203,0.15));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow:
    0 0 24px rgba(46, 208, 192, 0.25),
    0 8px 32px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 200ms var(--chatbot-ease), box-shadow 200ms var(--chatbot-ease);
  -webkit-tap-highlight-color: transparent;
}

.chatbot-toggle:hover {
  transform: scale(1.08);
  box-shadow:
    0 0 32px rgba(46, 208, 192, 0.35),
    0 12px 40px rgba(0, 0, 0, 0.5);
}

.chatbot-toggle:active {
  transform: scale(0.96);
}

.chatbot-toggle svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: var(--chatbot-text);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Pulse animation for toggle */
.chatbot-toggle::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(46,208,192,0.2), transparent 70%);
  animation: chatbot-pulse 2.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes chatbot-pulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(1.15); }
}

/* Hide toggle when popup is open */
.chatbot-toggle.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

/* ========================================
   Popup Container
   ======================================== */
.chatbot-popup {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1001;
  width: 380px;
  height: 680px;
  max-height: calc(100vh - 48px);
  max-width: calc(100vw - 48px);
  background: var(--chatbot-bg);
  border: 1px solid var(--chatbot-line);
  border-radius: var(--chatbot-radius);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow:
    0 0 40px rgba(46, 208, 192, 0.15),
    0 24px 80px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.95);
  transition: opacity 280ms var(--chatbot-ease), transform 280ms var(--chatbot-ease);
}

.chatbot-popup.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* Aurora glow overlay */
.chatbot-popup::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background:
    radial-gradient(400px 150px at 10% 0%, rgba(46,208,192,0.12), transparent 60%),
    radial-gradient(350px 120px at 90% 5%, rgba(52,211,153,0.10), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ========================================
   Header
   ======================================== */
.chatbot-header {
  position: relative;
  z-index: 2;
  display: block;
  padding: 14px 16px 14px 180px;
  background: rgba(10, 15, 25, 0.8);
  border-bottom: 1px solid var(--chatbot-line);
  min-height: 170px;
}

.chatbot-intro {
  font-size: 12px;
  line-height: 1.45;
  color: var(--chatbot-muted);
  max-height: 142px;
  overflow: hidden;
}

.chatbot-close {
  float: right;
  margin: 0 0 8px 10px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--chatbot-muted);
  font-size: 20px;
  line-height: 32px;
  text-align: center;
  cursor: pointer;
  transition: background 160ms var(--chatbot-ease), color 160ms var(--chatbot-ease);
}

.chatbot-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--chatbot-text);
}

/* ========================================
   Body Container (Avatar + Messages)
   ======================================== */
.chatbot-body {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ========================================
   Messages Area
   ======================================== */
.chatbot-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Scrollbar styling */
.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;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ========================================
   Avatar Canvas (CosmicDustRevealer)
   ======================================== */
.chatbot-avatar {
  position: absolute;
  top: 0;
  left: 0;
  width: 170px;
  height: 170px;
  border-radius: 20px 0 8px 0;
  overflow: hidden;
  background: rgba(5, 8, 18, 0.9);
  border: none;
  border-right: 2px solid rgba(100, 200, 180, 0.3);
  border-bottom: 2px solid rgba(100, 200, 180, 0.3);
  box-shadow: 4px 4px 20px rgba(0, 0, 0, 0.4);
  z-index: 3;
}

.chatbot-avatar canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Hide avatar container until revealed */
.chatbot-avatar.is-hidden {
  display: none;
}

/* ========================================
   Message Bubbles
   ======================================== */
.chatbot-bubble {
  max-width: 85%;
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  animation: chatbot-fadeIn 320ms var(--chatbot-ease);
  word-wrap: break-word;
}

.chatbot-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(46,208,192,0.22), rgba(52,211,153,0.18));
  border: 1px solid rgba(100, 200, 180, 0.25);
  color: var(--chatbot-text);
  border-bottom-right-radius: 6px;
}

.chatbot-bubble.bot {
  align-self: flex-start;
  background: var(--chatbot-glass);
  border: 1px solid var(--chatbot-line);
  color: var(--chatbot-muted);
  border-bottom-left-radius: 6px;
}

@keyframes chatbot-fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================================
   Typing Indicator
   ======================================== */
.chatbot-bubble.typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
}

.chatbot-bubble.typing .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--chatbot-accent);
  animation: chatbot-blink 1.4s ease-in-out infinite;
}

.chatbot-bubble.typing .dot:nth-child(2) {
  animation-delay: 0.2s;
}

.chatbot-bubble.typing .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes chatbot-blink {
  0%, 60%, 100% {
    opacity: 0.3;
    transform: scale(0.85);
  }
  30% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ========================================
   Input Area
   ======================================== */
.chatbot-input-area {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  background: rgba(10, 15, 25, 0.8);
  border-top: 1px solid var(--chatbot-line);
}

.chatbot-input-area input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--chatbot-line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--chatbot-text);
  font-size: 14px;
  outline: none;
  transition: border-color 160ms var(--chatbot-ease), background 160ms var(--chatbot-ease);
}

.chatbot-input-area input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.chatbot-input-area input:focus {
  border-color: rgba(46, 208, 192, 0.4);
  background: rgba(255, 255, 255, 0.06);
}

.chatbot-input-area button {
  padding: 12px 18px;
  border: 1px solid rgba(100, 200, 180, 0.3);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(46,208,192,0.25), rgba(52,211,153,0.20));
  color: var(--chatbot-text);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform 160ms var(--chatbot-ease), filter 160ms var(--chatbot-ease);
  -webkit-tap-highlight-color: transparent;
}

.chatbot-input-area button:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
}

.chatbot-input-area button:active {
  transform: translateY(0);
}

.chatbot-input-area button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ========================================
   Responsive (Mobile)
   ======================================== */
@media (max-width: 480px) {
  .chatbot-toggle {
    bottom: 16px;
    right: 16px;
    width: 52px;
    height: 52px;
  }

  .chatbot-popup {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    max-width: 100vw;
    border-radius: 0;
  }

  .chatbot-avatar {
    width: 140px;
    height: 140px;
  }

  .chatbot-header {
    min-height: 140px;
    padding: 0 16px 0 150px;
  }
}

/* ========================================
   Reduced Motion
   ======================================== */
@media (prefers-reduced-motion: reduce) {
  .chatbot-toggle,
  .chatbot-popup,
  .chatbot-bubble {
    transition: none;
    animation: none;
  }

  .chatbot-toggle::before {
    animation: none;
  }

  .chatbot-bubble.typing .dot {
    animation: none;
    opacity: 0.6;
  }
}
