/* ============================================================
   CHATBOT – Condor Trails FAQ Assistant
   ============================================================ */

/* Floating trigger button */
.chat-trigger {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 9998;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: transform var(--transition-interactive), background var(--transition-interactive), box-shadow var(--transition-interactive);
}
.chat-trigger:hover {
  background: var(--color-primary-hover);
  transform: scale(1.06);
  box-shadow: var(--shadow-hero);
}
.chat-trigger:active { background: var(--color-primary-active); transform: scale(0.97); }
.chat-trigger svg { transition: transform var(--transition-interactive); }
.chat-trigger[aria-expanded="true"] svg { transform: rotate(90deg); }

/* Notification dot */
.chat-trigger::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background: #c4622d;
  border-radius: var(--radius-full);
  border: 2px solid var(--color-surface);
  opacity: 1;
  transition: opacity var(--transition-interactive);
}
.chat-trigger[aria-expanded="true"]::after,
.chat-trigger.dot-hidden::after { opacity: 0; }

/* Panel */
.chat-panel {
  position: fixed;
  bottom: calc(var(--space-6) + 56px + var(--space-4));
  right: var(--space-6);
  z-index: 9999;
  width: 380px;
  max-height: min(560px, calc(100dvh - 140px));
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-hero);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  pointer-events: none;
  transition: opacity 260ms cubic-bezier(0.16, 1, 0.3, 1),
              transform 260ms cubic-bezier(0.16, 1, 0.3, 1);
}
.chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.chat-header {
  padding: var(--space-4) var(--space-5);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}
.chat-header-icon {
  width: 32px;
  height: 32px;
  background: rgba(255,255,255,0.18);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-header-text { flex: 1; }
.chat-header-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1.2;
}
.chat-header-subtitle {
  font-family: var(--font-body);
  font-size: 11px;
  opacity: 0.8;
  margin-top: 1px;
}

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 2px; }

/* Bubble */
.chat-bubble {
  max-width: 88%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  line-height: 1.55;
  animation: chatFadeIn 260ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes chatFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-bubble.bot {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  align-self: flex-start;
  border-bottom-left-radius: var(--radius-sm);
}
.chat-bubble.user {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  align-self: flex-end;
  border-bottom-right-radius: var(--radius-sm);
}
.chat-bubble a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.chat-bubble.bot a { color: var(--color-primary); }

/* Quick reply chips */
.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-self: flex-start;
  animation: chatFadeIn 260ms cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: 80ms;
}
.chat-chip {
  padding: 6px var(--space-3);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--transition-interactive), border-color var(--transition-interactive), color var(--transition-interactive);
  white-space: nowrap;
}
.chat-chip:hover {
  background: var(--color-primary-highlight);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* Typing indicator */
.chat-typing {
  display: flex;
  gap: 4px;
  align-self: flex-start;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: var(--radius-sm);
}
.chat-typing span {
  width: 6px;
  height: 6px;
  background: var(--color-text-muted);
  border-radius: var(--radius-full);
  animation: typingDot 1.2s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* Input area */
.chat-input-area {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
  background: var(--color-surface);
}
.chat-input {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text);
  outline: none;
  transition: border-color var(--transition-interactive);
}
.chat-input::placeholder { color: var(--color-text-faint); }
.chat-input:focus { border-color: var(--color-primary); }
.chat-send {
  width: 36px;
  height: 36px;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition-interactive);
}
.chat-send:hover { background: var(--color-primary-hover); }
.chat-send:disabled { opacity: 0.4; cursor: default; }

/* Mobile */
@media (max-width: 480px) {
  .chat-panel {
    width: calc(100vw - var(--space-6));
    right: calc(var(--space-6) / 2);
    bottom: calc(var(--space-6) + 56px + var(--space-3));
    max-height: calc(100dvh - 120px);
  }
  .chat-trigger {
    bottom: var(--space-4);
    right: var(--space-4);
  }
}
