/* =============================================================================
   TradersVault Academy — AI Chat Widget
   Electric Blue floating chat bubble
   ============================================================================= */

/* ── Chat Trigger Button ── */
.tva-chat-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3B82F6, #2563EB);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 4px 20px rgba(59, 130, 246, 0.35),
    0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform 180ms cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

.tva-chat-trigger:hover {
  transform: scale(1.08);
  box-shadow:
    0 6px 28px rgba(59, 130, 246, 0.45),
    0 4px 12px rgba(0, 0, 0, 0.35);
}

.tva-chat-trigger:active {
  transform: scale(0.95);
}

.tva-chat-trigger svg {
  width: 26px;
  height: 26px;
  color: #fff;
  transition: transform 200ms ease;
}

.tva-chat-trigger[data-open="true"] svg.chat-icon {
  display: none;
}

.tva-chat-trigger[data-open="false"] svg.close-icon,
.tva-chat-trigger:not([data-open]) svg.close-icon {
  display: none;
}

.tva-chat-trigger[data-open="true"] svg.close-icon {
  display: block;
}

/* Pulse animation on first load */
.tva-chat-trigger.pulse {
  animation: chatPulse 2s ease-in-out 3;
}

@keyframes chatPulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(59, 130, 246, 0.35), 0 2px 8px rgba(0,0,0,0.3); }
  50% { box-shadow: 0 4px 30px rgba(59, 130, 246, 0.6), 0 2px 12px rgba(0,0,0,0.35); }
}

/* ── Chat Panel ── */
.tva-chat-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  z-index: 9999;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 140px);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #0f172a;
  border: 1px solid #1e3a5f;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.5),
    0 8px 24px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(59, 130, 246, 0.1);
  transform: translateY(16px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: transform 250ms cubic-bezier(0.16, 1, 0.3, 1),
              opacity 250ms cubic-bezier(0.16, 1, 0.3, 1);
}

.tva-chat-panel.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ── */
.tva-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #111b2e, #0f172a);
  border-bottom: 1px solid #1e3a5f;
  flex-shrink: 0;
}

.tva-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3B82F6, #1D4ED8);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tva-chat-avatar svg {
  width: 20px;
  height: 20px;
  color: #fff;
}

.tva-chat-header-info {
  flex: 1;
  min-width: 0;
}

.tva-chat-header-title {
  font-family: 'Cabinet Grotesk', 'Satoshi', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #E2E8F0;
  line-height: 1.2;
}

.tva-chat-header-status {
  font-family: 'Satoshi', sans-serif;
  font-size: 12px;
  color: #22C55E;
  display: flex;
  align-items: center;
  gap: 5px;
}

.tva-chat-header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22C55E;
}

.tva-chat-close {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid #243047;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94A3B8;
  transition: all 150ms ease;
  flex-shrink: 0;
}

.tva-chat-close:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: #3B82F6;
  color: #E2E8F0;
}

/* ── Messages Area ── */
.tva-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: #243047 transparent;
}

.tva-chat-messages::-webkit-scrollbar {
  width: 4px;
}

.tva-chat-messages::-webkit-scrollbar-thumb {
  background: #243047;
  border-radius: 4px;
}

/* ── Message Bubbles ── */
.tva-msg {
  display: flex;
  gap: 8px;
  max-width: 92%;
  animation: msgFadeIn 200ms ease;
}

@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.tva-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.tva-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-family: 'Satoshi', sans-serif;
  font-size: 13.5px;
  line-height: 1.55;
  color: #E2E8F0;
  word-break: break-word;
}

.tva-msg.assistant .tva-msg-bubble {
  background: #1a2236;
  border: 1px solid #243047;
  border-bottom-left-radius: 4px;
}

.tva-msg.user .tva-msg-bubble {
  background: linear-gradient(135deg, #3B82F6, #2563EB);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Markdown-like formatting in assistant messages */
.tva-msg.assistant .tva-msg-bubble strong,
.tva-msg.assistant .tva-msg-bubble b {
  color: #60A5FA;
  font-weight: 600;
}

.tva-msg.assistant .tva-msg-bubble code {
  background: rgba(59, 130, 246, 0.15);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'Fira Code', monospace;
}

.tva-msg.assistant .tva-msg-bubble ul,
.tva-msg.assistant .tva-msg-bubble ol {
  margin: 6px 0;
  padding-left: 18px;
}

.tva-msg.assistant .tva-msg-bubble li {
  margin: 3px 0;
}

/* ── Typing Indicator ── */
.tva-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  align-items: center;
}

.tva-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3B82F6;
  animation: typingBounce 1.2s ease-in-out infinite;
}

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

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Welcome Message ── */
.tva-welcome {
  text-align: center;
  padding: 32px 20px;
}

.tva-welcome-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(59,130,246,0.15), rgba(59,130,246,0.05));
  border: 1px solid rgba(59, 130, 246, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.tva-welcome-icon svg {
  width: 24px;
  height: 24px;
  color: #3B82F6;
}

.tva-welcome h3 {
  font-family: 'Cabinet Grotesk', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #E2E8F0;
  margin: 0 0 6px;
}

.tva-welcome p {
  font-family: 'Satoshi', sans-serif;
  font-size: 13px;
  color: #94A3B8;
  margin: 0 0 20px;
  line-height: 1.5;
}

/* ── Quick Action Chips ── */
.tva-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.tva-quick-action {
  padding: 7px 12px;
  border-radius: 20px;
  border: 1px solid #243047;
  background: rgba(59, 130, 246, 0.06);
  color: #60A5FA;
  font-family: 'Satoshi', sans-serif;
  font-size: 12px;
  cursor: pointer;
  transition: all 150ms ease;
  white-space: nowrap;
}

.tva-quick-action:hover {
  background: rgba(59, 130, 246, 0.15);
  border-color: #3B82F6;
  color: #93BBFC;
}

/* ── Input Area ── */
.tva-chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid #1e3a5f;
  background: #0c1322;
  flex-shrink: 0;
}

.tva-chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #111b2e;
  border: 1px solid #243047;
  border-radius: 12px;
  padding: 4px 4px 4px 14px;
  transition: border-color 150ms ease;
}

.tva-chat-input-wrap:focus-within {
  border-color: #3B82F6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.tva-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #E2E8F0;
  font-family: 'Satoshi', sans-serif;
  font-size: 13.5px;
  line-height: 1.4;
  resize: none;
  max-height: 100px;
  min-height: 36px;
  padding: 8px 0;
}

.tva-chat-input::placeholder {
  color: #4A5568;
}

.tva-chat-send {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: #3B82F6;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  transition: background 150ms ease, transform 100ms ease;
}

.tva-chat-send:hover {
  background: #2563EB;
}

.tva-chat-send:active {
  transform: scale(0.92);
}

.tva-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tva-chat-send svg {
  width: 16px;
  height: 16px;
}

/* ── Powered By ── */
.tva-chat-footer {
  text-align: center;
  padding: 6px;
  font-family: 'Satoshi', sans-serif;
  font-size: 10px;
  color: #4A5568;
  background: #0c1322;
}

/* ── Mobile Responsive ── */
@media (max-width: 480px) {
  .tva-chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }

  .tva-chat-trigger {
    bottom: 16px;
    right: 16px;
    width: 50px;
    height: 50px;
  }
}
