/**
 * chatbot.css
 * ─────────────────────────────────────────────────────────────────────────────
 * Chatbot styles for two modes:
 *
 *   1. FULLSCREEN (.chatbot-fullscreen)
 *      - Covers the entire viewport as an overlay
 *      - Centered panel with backdrop blur
 *      - Used as the initial state when the user first visits
 *
 *   2. FLOATING (.chatbot-floating)
 *      - Fixed panel in the bottom-right corner
 *      - Compact, non-intrusive
 *      - Activated when user navigates to a section
 *
 * Mode switching is handled by chatbot.js.
 * The FAB (#chatbot-fab) is shown when the chatbot is closed/minimized.
 * ─────────────────────────────────────────────────────────────────────────────
 */

/* ── CHATBOT CONTAINER ──────────────────────────────────────────
   Wrapper that holds both the backdrop and the panel.
   Position and size change based on mode class.
──────────────────────────────────────────────────────────────── */
.chatbot-container {
  position: fixed;
  z-index: var(--z-chatbot);
  transition: all var(--transition-slow);
}

/* ── FULLSCREEN MODE ────────────────────────────────────────────
   Covers the entire viewport. Panel is centered.
──────────────────────────────────────────────────────────────── */
.chatbot-container.chatbot-fullscreen {
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatbot-container.chatbot-fullscreen .chatbot-backdrop {
  display: block;
}

.chatbot-container.chatbot-fullscreen .chatbot-panel {
  width: min(560px, 90vw);
  height: min(680px, 85vh);
  border-radius: var(--chatbot-panel-radius);
  box-shadow:
    var(--shadow-xl),
    0 0 60px rgba(0, 212, 170, 0.1);
}

/* ── FLOATING MODE ──────────────────────────────────────────────
   Fixed to bottom-right corner. Compact panel.
──────────────────────────────────────────────────────────────── */
.chatbot-container.chatbot-floating {
  bottom: calc(var(--chatbot-fab-size) + var(--space-4) + var(--space-4));
  right: var(--space-6);
  width: var(--chatbot-width);
}

.chatbot-container.chatbot-floating .chatbot-backdrop {
  display: none;
}

.chatbot-container.chatbot-floating .chatbot-panel {
  width: 100%;
  height: var(--chatbot-height);
  border-radius: var(--chatbot-panel-radius);
  box-shadow:
    var(--shadow-xl),
    0 0 30px rgba(0, 212, 170, 0.1);
}

/* ── HIDDEN STATE ───────────────────────────────────────────────
   When chatbot is closed, hide the container and show the FAB.
──────────────────────────────────────────────────────────────── */
.chatbot-container.chatbot-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.95);
}

/* ── BACKDROP ───────────────────────────────────────────────────
   Semi-transparent overlay behind the fullscreen panel.
──────────────────────────────────────────────────────────────── */
.chatbot-backdrop {
  position: fixed;
  inset: 0;
  background: var(--color-bg-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: -1;
}

/* ── CHATBOT PANEL ──────────────────────────────────────────────
   The main chat window.
──────────────────────────────────────────────────────────────── */
.chatbot-panel {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border-light);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition:
    width var(--transition-slow),
    height var(--transition-slow),
    border-radius var(--transition-slow);
}

/* ── CHATBOT HEADER ─────────────────────────────────────────────
   Top bar with avatar, name, status, and action buttons.
──────────────────────────────────────────────────────────────── */
.chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  background: var(--color-bg-card-hover);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Avatar circle */
.chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gradient-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--color-text-inverse);
  flex-shrink: 0;
}

.chatbot-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  margin: 0;
}

.chatbot-status {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: 0;
}

.chatbot-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-success);
  animation: status-pulse 2s ease-in-out infinite;
}

@keyframes status-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Header action buttons */
.chatbot-header-actions {
  display: flex;
  gap: var(--space-2);
}

.chatbot-btn-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chatbot-btn-icon:hover {
  color: var(--color-text-primary);
  background: var(--color-bg-primary);
  border-color: var(--color-border-light);
}

.chatbot-btn-icon svg {
  width: 14px;
  height: 14px;
}

/* ── MESSAGES AREA ──────────────────────────────────────────────
   Scrollable chat message log.
──────────────────────────────────────────────────────────────── */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  scroll-behavior: smooth;
}

/* ── MESSAGE BUBBLE ─────────────────────────────────────────────
   Individual chat message.
──────────────────────────────────────────────────────────────── */
.message {
  display: flex;
  gap: var(--space-2);
  max-width: 85%;
  animation: message-appear 0.3s ease;
}

@keyframes message-appear {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Bot message — left aligned */
.message.bot {
  align-self: flex-start;
  flex-direction: row;
}

/* User message — right aligned */
.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

/* Small avatar for bot messages */
.message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gradient-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--color-text-inverse);
  flex-shrink: 0;
  margin-top: 2px;
}

.message.user .message-avatar {
  background: var(--color-bg-card-hover);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
}

/* Message bubble */
.message-bubble {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.message.bot .message-bubble {
  background: var(--color-bg-card-hover);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
  border-bottom-left-radius: var(--radius-sm);
}

.message.user .message-bubble {
  background: var(--gradient-accent);
  color: var(--color-text-inverse);
  border-bottom-right-radius: var(--radius-sm);
}

/* Typing indicator */
.message.typing .message-bubble {
  padding: var(--space-3) var(--space-5);
}

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

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

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

@keyframes typing-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-6px);
  }
}

/* ── SUGGESTED PROMPTS ──────────────────────────────────────────
   Quick-action chips shown initially.
──────────────────────────────────────────────────────────────── */
.chatbot-suggestions {
  padding: 0 var(--space-5) var(--space-3);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chatbot-suggestions.hidden {
  display: none;
}

.suggestion-chip {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--color-accent);
  background: var(--color-accent-dim);
  border: 1px solid var(--color-accent-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.suggestion-chip:hover {
  background: var(--color-accent);
  color: var(--color-text-inverse);
  border-color: var(--color-accent);
}

/* ── INPUT AREA ─────────────────────────────────────────────────
   Text input + send button at the bottom.
──────────────────────────────────────────────────────────────── */
.chatbot-input-area {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-card-hover);
  flex-shrink: 0;
}

.chatbot-input {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  outline: none;
  transition: border-color var(--transition-fast);
}

.chatbot-input:focus {
  border-color: var(--color-accent-border);
}

.chatbot-input::placeholder {
  color: var(--color-text-muted);
}

.chatbot-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gradient-accent);
  border: none;
  color: var(--color-text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition:
    transform var(--transition-spring),
    box-shadow var(--transition-base);
}

.chatbot-send-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 212, 170, 0.4);
}

.chatbot-send-btn:active {
  transform: scale(0.95);
}

.chatbot-send-btn svg {
  width: 16px;
  height: 16px;
}

/* ── FLOATING ACTION BUTTON (FAB) ───────────────────────────────
   Shown when chatbot is closed. Click to reopen.
──────────────────────────────────────────────────────────────── */
.chatbot-fab {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-chatbot);
  width: var(--chatbot-fab-size);
  height: var(--chatbot-fab-size);
  border-radius: 50%;
  background: var(--gradient-accent);
  border: none;
  color: var(--color-text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 212, 170, 0.4);
  transition:
    transform var(--transition-spring),
    box-shadow var(--transition-base);
}

.chatbot-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 30px rgba(0, 212, 170, 0.5);
}

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

.chatbot-fab svg {
  width: 24px;
  height: 24px;
}

/* Pulse ring around FAB */
.chatbot-fab-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--color-accent);
  opacity: 0;
  animation: fab-pulse 2s ease-out infinite;
}

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

/* Navigation link in chat messages */
.chat-nav-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--color-accent);
  font-weight: var(--weight-medium);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  font-size: inherit;
  padding: 0;
}

.chat-nav-link:hover {
  color: var(--color-accent-hover);
}
