/* ═══════════════════════════════════════════════════════════════
   AI Trading Instructor Chat — Styles
   Ported from prototype, adapted to existing guide design tokens
   ═══════════════════════════════════════════════════════════════ */

/* ── Chat Panel (slides in from right) ── */
.chat-panel {
  position: fixed;
  top: 0; right: 0;
  width: 400px;
  height: 100dvh;
  background: var(--color-surface, #111920);
  border-left: 1px solid var(--color-border);
  z-index: 950;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -8px 0 32px rgba(0,0,0,0.5);
}
.chat-panel.chat-open {
  transform: translateX(0);
}

@media (max-width: 640px) {
  .chat-panel {
    width: 100%;
    border-left: none;
  }
}

/* ── Chat Header ── */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  background: var(--color-surface, #111920);
}
.chat-header__left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-header__avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary, #00D4AA), var(--color-info, #3B82F6));
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}
.chat-header__avatar::after {
  content: '';
  position: absolute;
  bottom: 1px; right: 1px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--color-primary, #00D4AA);
  border: 2px solid var(--color-surface, #111920);
}
.chat-header__info {
  display: flex;
  flex-direction: column;
}
.chat-header__name {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.2;
}
.chat-header__status {
  font-size: 0.75rem;
  color: var(--color-primary, #00D4AA);
  display: flex;
  align-items: center;
  gap: 5px;
}
.chat-header__dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--color-primary, #00D4AA);
  animation: chat-blink 2s infinite;
}
@keyframes chat-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.chat-header__close {
  width: 34px; height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--color-text-muted);
  cursor: pointer;
  background: none; border: none;
}
.chat-header__close:hover {
  color: var(--color-text);
  background: var(--color-surface-2, #182230);
}

/* ── Chat Messages ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--color-surface-3, #1E2A3A) transparent;
}
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--color-surface-3, #1E2A3A); border-radius: 3px; }

.chat-message {
  display: flex;
  gap: 10px;
  max-width: 92%;
  animation: chat-msg-in 0.3s ease;
}
@keyframes chat-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-message--bot { align-self: flex-start; }
.chat-message--user { align-self: flex-end; flex-direction: row-reverse; }

.chat-message__avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary, #00D4AA), var(--color-info, #3B82F6));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-message--user .chat-message__avatar {
  background: var(--color-surface-3, #1E2A3A);
}

.chat-message__bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.55;
}
.chat-message--bot .chat-message__bubble {
  background: var(--color-surface-2, #182230);
  color: var(--color-text);
  border-bottom-left-radius: 4px;
}
.chat-message--user .chat-message__bubble {
  background: var(--color-primary, #00D4AA);
  color: #0B0F14;
  border-bottom-right-radius: 4px;
}
.chat-message--user .chat-message__bubble strong {
  color: #0B0F14;
}
.chat-message__bubble strong {
  color: var(--color-text);
  font-weight: 600;
}
.chat-message__time {
  font-size: 0.7rem;
  color: var(--color-text-faint, #556275);
  margin-top: 3px;
}

/* ── Typing Indicator ── */
.chat-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
}
.chat-typing-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--color-text-faint, #556275);
  animation: chat-typing 1.4s infinite;
}
.chat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes chat-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ── Suggestion Chips ── */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 18px;
  margin-bottom: 10px;
  flex-shrink: 0;
}
.chat-suggestion {
  font-size: 0.75rem;
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-text-muted);
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.chat-suggestion:hover {
  border-color: var(--color-primary, #00D4AA);
  color: var(--color-primary, #00D4AA);
  background: rgba(0,212,170,0.08);
}

/* ── Chat Input Area ── */
.chat-input-area {
  padding: 10px 14px;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}
.chat-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--color-surface-2, #182230);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.chat-input-wrapper:focus-within {
  border-color: var(--color-primary, #00D4AA);
  box-shadow: 0 0 0 3px rgba(0,212,170,0.12);
}
.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 0.875rem;
  color: var(--color-text);
  padding: 8px 4px;
  font-family: var(--font-body);
}
.chat-input::placeholder {
  color: var(--color-text-faint, #556275);
}
.chat-send {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary, #00D4AA);
  color: #0B0F14;
  border-radius: 10px;
  flex-shrink: 0;
  cursor: pointer;
  border: none;
  transition: background 0.2s ease;
}
.chat-send:hover {
  background: var(--color-primary-hover, #00B894);
}
.chat-disclaimer {
  text-align: center;
  font-size: 0.7rem;
  color: var(--color-text-faint, #556275);
  padding: 2px 14px 8px;
}

/* ── Chat Overlay (backdrop when open on mobile) ── */
.chat-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 949;
}
.chat-overlay.active {
  display: block;
}

/* ── Chat FAB (3rd button in the fab group) ── */
.journal-fab-chat {
  background: linear-gradient(135deg, var(--color-primary, #00D4AA), var(--color-info, #3B82F6));
  color: #fff;
  position: relative;
}
.journal-fab-chat:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 24px rgba(0,212,170,0.4);
}
/* Pulse ring on the chat FAB */
.journal-fab-chat::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--color-primary, #00D4AA);
  opacity: 0;
  animation: chat-fab-pulse 3s ease-out infinite;
}
@keyframes chat-fab-pulse {
  0% { transform: scale(1); opacity: 0.4; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* Notification badge on FAB */
.chat-fab-badge {
  position: absolute;
  top: -2px; right: -2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #EF4444;
  border: 2px solid var(--color-bg, #0B0F14);
  display: none;
}
.chat-fab-badge.active { display: block; }

/* ── Mobile adjustments ── */
@media (max-width: 640px) {
  .chat-panel {
    height: 80dvh;
    top: auto; bottom: 0;
    border-radius: 20px 20px 0 0;
    border-left: none;
    border-top: 1px solid var(--color-border);
    transform: translateY(100%);
  }
  .chat-panel.chat-open {
    transform: translateY(0);
  }
  .chat-suggestions {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }
}
