/* ========================================
   CLUE AI CHAT WIDGET
   All styles scoped to #clue-ai-wrapper
   Inherits --primary-color from client.css
   ======================================== */

/* --- Floating Bubble --- */
#clue-ai-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: var(--primary-color, #3477ad);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#clue-ai-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}

#clue-ai-bubble.clue-ai-left {
  right: auto;
  left: 24px;
}

/* Pulse animation on first load */
@keyframes clue-ai-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2); }
  50% { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2), 0 0 0 8px rgba(52, 119, 173, 0.2); }
}

#clue-ai-bubble.clue-ai-pulse {
  animation: clue-ai-pulse 2s ease-in-out 3;
}

/* Hide bubble when panel is open on mobile */
#clue-ai-bubble.clue-ai-hidden {
  display: none;
}

/* --- Chat Panel --- */
#clue-ai-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-height: calc(100vh - 120px);
  border-radius: 16px;
  background: white;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(16px) scale(0.95);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
}

/* Force all descendants non-interactive when panel is closed.
   Needed because the video player sets pointer-events:auto and
   visibility:visible on its overlays, which would otherwise
   override the parent's hidden state and swallow clicks. */
#clue-ai-panel:not(.active) * {
  pointer-events: none !important;
  visibility: hidden !important;
}

#clue-ai-panel.clue-ai-left {
  right: auto;
  left: 24px;
}

#clue-ai-panel.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* --- Header --- */
.clue-ai-header {
  background-color: var(--primary-color, #3477ad);
  color: white;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.clue-ai-header-title {
  font-weight: 600;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.clue-ai-header-close {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 1.25rem;
  padding: 4px;
  opacity: 0.8;
  transition: opacity 0.15s;
}

.clue-ai-header-close:hover {
  opacity: 1;
}

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

/* --- User Message Bubble --- */
.clue-ai-msg-user {
  align-self: flex-end;
  background-color: var(--primary-color, #3477ad);
  color: white;
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  max-width: 85%;
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
}

/* --- Assistant Message Bubble --- */
.clue-ai-msg-assistant {
  align-self: flex-start;
  background-color: #f1f3f5;
  color: #212529;
  padding: 12px 14px;
  border-radius: 16px 16px 16px 4px;
  max-width: 90%;
  font-size: 0.9rem;
  line-height: 1.6;
  word-wrap: break-word;
}

.clue-ai-msg-assistant p {
  margin: 0 0 8px 0;
}

.clue-ai-msg-assistant p:last-child {
  margin-bottom: 0;
}

.clue-ai-msg-assistant strong {
  font-weight: 600;
}

.clue-ai-msg-assistant ul {
  margin: 4px 0 8px 0;
  padding-left: 18px;
}

.clue-ai-msg-assistant li {
  margin-bottom: 2px;
}

/* --- AI Disclaimer --- */
.clue-ai-disclaimer {
  text-align: center;
  font-size: 0.7rem;
  color: #adb5bd;
  padding: 2px 0 4px;
}

/* --- Video Card inside chat --- */
.clue-ai-video-card {
  margin: 8px 0;
  border-radius: 8px;
  overflow: hidden;
}

.clue-ai-video-card video {
  width: 100%;
  border-radius: 6px;
}

/* --- CTA Buttons --- */
.clue-ai-cta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.clue-ai-cta a {
  display: block;
  font-size: 0.85rem;
  padding: 8px 14px;
  border-radius: 8px;
  text-align: center;
  text-decoration: none;
  font-weight: 500;
  transition: background-color 0.15s, color 0.15s;
}

.clue-ai-cta-primary {
  background-color: var(--primary-color, #3477ad);
  color: white !important;
  border: 1px solid var(--primary-color, #3477ad);
}

.clue-ai-cta-primary:hover {
  background-color: var(--primary-color-dark, #2a5f8a);
  border-color: var(--primary-color-dark, #2a5f8a);
}

.clue-ai-cta-secondary {
  background-color: white;
  color: var(--primary-color, #3477ad) !important;
  border: 1px solid var(--primary-color, #3477ad);
}

.clue-ai-cta-secondary:hover {
  background-color: #f1f3f5;
}

/* --- Related Pages --- */
.clue-ai-related {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.clue-ai-related-label {
  font-size: 0.8rem;
  color: #6c757d;
  font-weight: 500;
}

.clue-ai-related-link {
  font-size: 0.8rem;
  background-color: #e9ecef;
  padding: 4px 10px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--primary-color, #3477ad);
  transition: background-color 0.15s;
}

.clue-ai-related-link:hover {
  background-color: #dee2e6;
  color: var(--primary-color, #3477ad);
}

/* --- Typing Indicator --- */
.clue-ai-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background-color: #f1f3f5;
  border-radius: 16px 16px 16px 4px;
}

.clue-ai-typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #adb5bd;
  animation: clue-ai-typing-bounce 1.2s infinite;
}

.clue-ai-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.clue-ai-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes clue-ai-typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* --- Input Area --- */
.clue-ai-input-area {
  padding: 12px 16px;
  border-top: 1px solid #dee2e6;
  flex-shrink: 0;
}

.clue-ai-input-wrapper {
  display: flex;
  gap: 8px;
}

.clue-ai-input {
  flex: 1;
  border: 1px solid #dee2e6;
  border-radius: 24px;
  padding: 8px 16px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.clue-ai-input:focus {
  border-color: var(--primary-color, #3477ad);
}

.clue-ai-send {
  background-color: var(--primary-color, #3477ad);
  color: white;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  flex-shrink: 0;
  transition: background-color 0.15s;
}

.clue-ai-send:hover {
  background-color: var(--primary-color-dark, #2a5f8a);
}

/* --- Mobile Responsive --- */
@media (max-width: 480px) {
  #clue-ai-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }

  #clue-ai-panel.clue-ai-left {
    left: 0;
    right: 0;
  }

  #clue-ai-bubble {
    bottom: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
    font-size: 1.3rem;
  }

  #clue-ai-bubble.clue-ai-left {
    right: auto;
    left: 16px;
  }
}

/* --- Accessibility --- */
#clue-ai-bubble:focus-visible,
.clue-ai-header-close:focus-visible,
.clue-ai-send:focus-visible,
.clue-ai-input:focus-visible {
  outline: 2px solid var(--primary-color, #3477ad);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  #clue-ai-bubble,
  #clue-ai-panel,
  .clue-ai-typing-dot {
    animation: none !important;
    transition: none !important;
  }
}
