/**
 * ============================================================
 * WAVE ALPHA — AI ASSISTANT CSS v1.0
 * public/css/ai-assistant.css
 * ============================================================
 * Tất cả styles cho Wave AI UI layer
 * Critical styles đã được inject inline bởi ai-assistant.js
 * File này chứa extended styles: animations, responsive,
 * token analyst tab, screener, sonar narrator, smart money
 * ============================================================
 */

/* ── CSS Variables (kế thừa từ Wave Alpha theme) ─────────── */
:root {
  --wai-purple    : #9945FF;
  --wai-cyan      : #00F0FF;
  --wai-green     : #0ECB81;
  --wai-red       : #F6465D;
  --wai-bg        : #0d1117;
  --wai-bg2       : #111820;
  --wai-bg3       : #161f2c;
  --wai-border    : rgba(255, 255, 255, 0.07);
  --wai-text      : #c9d1d9;
  --wai-text-dim  : #848e9c;
  --wai-radius    : 12px;
  --wai-radius-sm : 8px;
  --wai-shadow    : 0 8px 40px rgba(0, 0, 0, 0.6);
  --wai-glow      : 0 0 20px rgba(153, 69, 255, 0.3);
}

/* ── FAB Button ──────────────────────────────────────────── */
#wave-ai-fab {
  position    : fixed;
  bottom      : 24px;
  right       : 24px;
  z-index     : 9990;
  width       : 52px;
  height      : 52px;
  border-radius : 50%;
  border      : none;
  cursor      : pointer;
  background  : linear-gradient(135deg, var(--wai-purple), var(--wai-cyan));
  box-shadow  : 0 4px 20px rgba(153, 69, 255, 0.45);
  display     : flex;
  align-items : center;
  justify-content: center;
  font-size   : 20px;
  color       : #fff;
  transition  : transform 0.2s ease, box-shadow 0.2s ease;
  user-select : none;
  -webkit-tap-highlight-color: transparent;
}

#wave-ai-fab:hover {
  transform  : scale(1.1);
  box-shadow : 0 6px 28px rgba(153, 69, 255, 0.65);
}

#wave-ai-fab:active {
  transform : scale(0.95);
}

/* Pulse ring khi đang streaming */
#wave-ai-fab.streaming::before {
  content       : '';
  position      : absolute;
  inset         : -4px;
  border-radius : 50%;
  border        : 2px solid var(--wai-cyan);
  animation     : waiPulseRing 1.4s ease-out infinite;
  pointer-events: none;
}

@keyframes waiPulseRing {
  0%   { opacity: 0.8; transform: scale(1); }
  100% { opacity: 0;   transform: scale(1.5); }
}

/* Status dot */
#wave-ai-fab .wave-ai-dot {
  position      : absolute;
  top           : 3px;
  right         : 3px;
  width         : 11px;
  height        : 11px;
  border-radius : 50%;
  background    : var(--wai-green);
  border        : 2px solid var(--wai-bg);
  display       : none;
}

#wave-ai-fab .wave-ai-dot.active {
  display   : block;
  animation : waiDotBlink 3s ease-in-out infinite;
}

@keyframes waiDotBlink {
  0%, 90%, 100% { opacity: 1; }
  95%           { opacity: 0.3; }
}

/* ── Chat Panel ──────────────────────────────────────────── */
#wave-ai-panel {
  position       : fixed;
  bottom         : 88px;
  right          : 24px;
  z-index        : 9991;
  width          : 360px;
  max-height     : 560px;
  border-radius  : var(--wai-radius);
  overflow       : hidden;
  background     : var(--wai-bg);
  border         : 1px solid rgba(153, 69, 255, 0.3);
  box-shadow     : var(--wai-shadow);
  display        : flex;
  flex-direction : column;
  transform      : translateY(20px) scale(0.97);
  opacity        : 0;
  pointer-events : none;
  transition     : transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
                   opacity 0.2s ease;
  will-change    : transform, opacity;
}

#wave-ai-panel.open {
  transform      : translateY(0) scale(1);
  opacity        : 1;
  pointer-events : all;
}

/* Header */
#wave-ai-panel .wai-header {
  padding         : 12px 16px;
  display         : flex;
  align-items     : center;
  justify-content : space-between;
  border-bottom   : 1px solid var(--wai-border);
  flex-shrink     : 0;
  background      : var(--wai-bg2);
}

#wave-ai-panel .wai-title {
  font-size      : 0.82rem;
  font-weight    : 700;
  color          : #fff;
  font-family    : 'Rajdhani', sans-serif;
  letter-spacing : 0.05em;
}

#wave-ai-panel .wai-provider {
  font-size  : 0.68rem;
  color      : var(--wai-text-dim);
  margin-top : 1px;
  transition : color 0.3s;
}

#wave-ai-panel .wai-provider.active {
  color : var(--wai-cyan);
}

#wave-ai-panel .wai-close {
  background : none;
  border     : none;
  color      : var(--wai-text-dim);
  cursor     : pointer;
  font-size  : 16px;
  padding    : 2px 6px;
  border-radius: 4px;
  transition : color 0.15s, background 0.15s;
}

#wave-ai-panel .wai-close:hover {
  color      : #fff;
  background : rgba(255, 255, 255, 0.08);
}

/* Quick chips */
.wai-chip-row {
  display    : flex;
  flex-wrap  : wrap;
  gap        : 6px;
  padding    : 10px 14px 6px;
  flex-shrink: 0;
  background : var(--wai-bg);
}

.wai-chip {
  background    : rgba(153, 69, 255, 0.1);
  border        : 1px solid rgba(153, 69, 255, 0.28);
  border-radius : 20px;
  padding       : 4px 12px;
  font-size     : 0.72rem;
  color         : #c9a5ff;
  cursor        : pointer;
  transition    : background 0.15s, border-color 0.15s;
  font-family   : 'Rajdhani', sans-serif;
  white-space   : nowrap;
}

.wai-chip:hover {
  background   : rgba(153, 69, 255, 0.22);
  border-color : rgba(153, 69, 255, 0.5);
}

/* Messages */
#wave-ai-messages {
  flex            : 1;
  overflow-y      : auto;
  padding         : 12px 14px;
  display         : flex;
  flex-direction  : column;
  gap             : 10px;
  scrollbar-width : thin;
  scrollbar-color : rgba(153, 69, 255, 0.25) transparent;
  overscroll-behavior: contain;
}

#wave-ai-messages::-webkit-scrollbar       { width: 4px; }
#wave-ai-messages::-webkit-scrollbar-track { background: transparent; }
#wave-ai-messages::-webkit-scrollbar-thumb { background: rgba(153, 69, 255, 0.25); border-radius: 2px; }

.wai-msg {
  max-width     : 88%;
  line-height   : 1.55;
  font-size     : 0.8rem;
  border-radius : 10px;
  padding       : 8px 12px;
  word-break    : break-word;
  animation     : waiFadeUp 0.18s ease;
}

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

.wai-msg.user {
  align-self              : flex-end;
  background              : rgba(153, 69, 255, 0.18);
  color                   : #e0d7ff;
  border-bottom-right-radius : 3px;
}

.wai-msg.ai {
  align-self             : flex-start;
  background             : rgba(255, 255, 255, 0.05);
  color                  : var(--wai-text);
  border-bottom-left-radius : 3px;
}

.wai-msg.ai.loading {
  color       : var(--wai-text-dim);
  font-style  : italic;
  position    : relative;
  padding-left: 24px;
}

.wai-msg.ai.loading::before {
  content   : '';
  position  : absolute;
  left      : 10px;
  top       : 50%;
  transform : translateY(-50%);
  width     : 8px;
  height    : 8px;
  border-radius : 50%;
  border    : 1.5px solid var(--wai-purple);
  border-top-color: transparent;
  animation : waiSpin 0.8s linear infinite;
}

@keyframes waiSpin {
  to { transform: translateY(-50%) rotate(360deg); }
}

/* Input row */
#wave-ai-input-row {
  display       : flex;
  gap           : 8px;
  padding       : 10px 14px;
  border-top    : 1px solid var(--wai-border);
  flex-shrink   : 0;
  background    : var(--wai-bg2);
  align-items   : flex-end;
}

#wave-ai-input {
  flex          : 1;
  background    : rgba(255, 255, 255, 0.05);
  border        : 1px solid rgba(255, 255, 255, 0.1);
  border-radius : var(--wai-radius-sm);
  padding       : 8px 12px;
  color         : #fff;
  font-size     : 0.8rem;
  outline       : none;
  resize        : none;
  font-family   : 'Rajdhani', 'Inter', sans-serif;
  max-height    : 80px;
  overflow-y    : auto;
  line-height   : 1.4;
  transition    : border-color 0.15s;
}

#wave-ai-input::placeholder { color: rgba(255,255,255,0.25); }

#wave-ai-input:focus {
  border-color : rgba(153, 69, 255, 0.5);
  background   : rgba(255, 255, 255, 0.07);
}

#wave-ai-send {
  background    : linear-gradient(135deg, var(--wai-purple), #6e2fcf);
  border        : none;
  border-radius : var(--wai-radius-sm);
  padding       : 8px 16px;
  color         : #fff;
  cursor        : pointer;
  font-size     : 0.78rem;
  font-weight   : 700;
  white-space   : nowrap;
  transition    : opacity 0.15s, transform 0.1s;
  font-family   : 'Rajdhani', sans-serif;
  letter-spacing: 0.03em;
  flex-shrink   : 0;
}

#wave-ai-send:hover    { opacity: 0.85; }
#wave-ai-send:active   { transform: scale(0.96); }
#wave-ai-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ── Token Analyst Tab (tính năng ②) ─────────────────────── */
.wai-token-tab {
  padding    : 14px 16px;
  font-size  : 0.8rem;
  color      : var(--wai-text);
  line-height: 1.65;
  min-height : 80px;
}

.wai-loading-bar {
  height        : 3px;
  border-radius : 2px;
  background    : linear-gradient(90deg, var(--wai-purple), var(--wai-cyan), var(--wai-purple));
  background-size: 200% 100%;
  animation     : waiSlide 1.4s ease-in-out infinite;
}

@keyframes waiSlide {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.wai-provider-badge {
  font-size  : 0.68rem;
  color      : var(--wai-text-dim);
  margin-top : 10px;
  display    : flex;
  align-items: center;
  gap        : 4px;
}

.wai-provider-badge::before {
  content       : '✦';
  font-size     : 0.6rem;
  color         : var(--wai-purple);
}

/* ── Competition Coach Banner (tính năng ③) ──────────────── */
#wave-ai-coach {
  background    : rgba(0, 240, 255, 0.04);
  border        : 1px solid rgba(0, 240, 255, 0.18);
  border-radius : var(--wai-radius-sm);
  padding       : 12px 16px;
  margin        : 10px 0 6px;
  font-size     : 0.8rem;
  color         : var(--wai-text);
  line-height   : 1.6;
  display       : none;
  animation     : waiFadeUp 0.3s ease;
}

#wave-ai-coach.visible {
  display : block;
}

#wave-ai-coach .wai-coach-title {
  font-size      : 0.72rem;
  font-weight    : 700;
  color          : var(--wai-cyan);
  font-family    : 'Rajdhani', sans-serif;
  letter-spacing : 0.08em;
  margin-bottom  : 6px;
  display        : flex;
  align-items    : center;
  gap            : 6px;
}

#wave-ai-coach .wai-coach-refresh {
  margin-top    : 8px;
  background    : rgba(0, 240, 255, 0.08);
  border        : 1px solid rgba(0, 240, 255, 0.25);
  border-radius : 6px;
  padding       : 4px 12px;
  color         : var(--wai-cyan);
  font-size     : 0.72rem;
  cursor        : pointer;
  transition    : background 0.15s;
  font-family   : 'Rajdhani', sans-serif;
}

#wave-ai-coach .wai-coach-refresh:hover {
  background : rgba(0, 240, 255, 0.15);
}

/* ── NL Market Screener (tính năng ④) ───────────────────── */
#wai-screener-bar {
  display       : flex;
  gap           : 8px;
  padding       : 8px 0 10px;
  align-items   : center;
}

#wai-screener-input {
  flex          : 1;
  background    : rgba(255, 255, 255, 0.05);
  border        : 1px solid rgba(255, 255, 255, 0.1);
  border-radius : var(--wai-radius-sm);
  padding       : 7px 12px;
  color         : #fff;
  font-size     : 0.78rem;
  outline       : none;
  font-family   : 'Rajdhani', sans-serif;
  transition    : border-color 0.15s;
}

#wai-screener-input:focus {
  border-color : rgba(153, 69, 255, 0.5);
}

#wai-screener-input::placeholder {
  color : rgba(255,255,255,0.22);
}

#wai-screener-btn {
  background    : rgba(153, 69, 255, 0.15);
  border        : 1px solid rgba(153, 69, 255, 0.35);
  border-radius : var(--wai-radius-sm);
  padding       : 7px 14px;
  color         : #c9a5ff;
  font-size     : 0.75rem;
  font-weight   : 700;
  cursor        : pointer;
  transition    : background 0.15s;
  font-family   : 'Rajdhani', sans-serif;
  white-space   : nowrap;
}

#wai-screener-btn:hover {
  background : rgba(153, 69, 255, 0.28);
}

#wai-screener-result {
  font-size  : 0.78rem;
  color      : var(--wai-text);
  line-height: 1.6;
  padding    : 6px 0;
  min-height : 30px;
}

/* ── Sonar Narrator (tính năng ⑥) ──────────────────────── */
#wai-sonar-narrator {
  position      : absolute;
  top           : 12px;
  right         : 12px;
  width         : 220px;
  background    : rgba(13, 17, 23, 0.92);
  border        : 1px solid rgba(153, 69, 255, 0.3);
  border-radius : var(--wai-radius-sm);
  padding       : 10px 12px;
  font-size     : 0.75rem;
  color         : var(--wai-text);
  line-height   : 1.6;
  backdrop-filter: blur(8px);
  pointer-events : none;
  opacity        : 0;
  transition     : opacity 0.2s;
  z-index        : 10;
}

#wai-sonar-narrator.visible {
  opacity        : 1;
  pointer-events : none;
}

#wai-sonar-narrator .wai-sonar-sym {
  font-size      : 0.82rem;
  font-weight    : 700;
  color          : var(--wai-cyan);
  font-family    : 'Rajdhani', sans-serif;
  margin-bottom  : 4px;
}

/* ── Quant Explainer tooltip (tính năng ⑦) ──────────────── */
.wai-quant-explain {
  font-size     : 0.75rem;
  color         : var(--wai-text-dim);
  line-height   : 1.5;
  margin-top    : 6px;
  padding       : 6px 10px;
  background    : rgba(153, 69, 255, 0.07);
  border-left   : 2px solid rgba(153, 69, 255, 0.4);
  border-radius : 0 4px 4px 0;
  transition    : color 0.3s;
}

.wai-quant-explain.loaded {
  color : var(--wai-text);
}

/* ── Smart Money AI (tính năng ⑤) ──────────────────────── */
#wai-smartmoney-summary {
  background    : rgba(255, 255, 255, 0.03);
  border        : 1px solid var(--wai-border);
  border-radius : var(--wai-radius-sm);
  padding       : 10px 14px;
  font-size     : 0.78rem;
  color         : var(--wai-text);
  line-height   : 1.65;
  margin-bottom : 10px;
}

#wai-smartmoney-summary .wai-sm-title {
  font-size      : 0.7rem;
  font-weight    : 700;
  color          : var(--wai-purple);
  font-family    : 'Rajdhani', sans-serif;
  letter-spacing : 0.07em;
  margin-bottom  : 5px;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 480px) {
  #wave-ai-panel {
    width         : calc(100vw - 16px);
    right         : 8px;
    bottom        : 78px;
    max-height    : calc(100vh - 100px);
    border-radius : 14px;
  }

  #wave-ai-fab {
    bottom : 16px;
    right  : 16px;
    width  : 48px;
    height : 48px;
  }

  .wai-chip {
    font-size : 0.68rem;
    padding   : 3px 10px;
  }
}

@media (max-width: 360px) {
  .wai-chip-row { display: none; }
}

/* ── Accessibility ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #wave-ai-fab,
  #wave-ai-panel,
  .wai-msg,
  .wai-loading-bar {
    animation  : none !important;
    transition : none !important;
  }
}

/* ── Dark mode override (Wave Alpha is always dark) ─────── */
@media (prefers-color-scheme: light) {
  /* Force dark — Wave Alpha không có light mode */
  #wave-ai-panel,
  #wave-ai-fab,
  #wave-ai-coach { color-scheme: dark; }
}

/* Khối hộp tiến trình tư duy dạng Accordion */
.wai-loading-container {
background: rgba(153, 69, 255, 0.05);
border: 1px dashed rgba(0, 240, 255, 0.3);
padding: 10px;
border-radius: 8px;
margin-bottom: 4px;
transition: background 0.2s;
}
.wai-loading-container:hover {
background: rgba(153, 69, 255, 0.1);
}
@keyframes waiSpinnerBlink {
0% { transform: rotate(0deg); opacity: 0.6; }
50% { opacity: 1; }
100% { transform: rotate(360deg); opacity: 0.6; }
}
.wai-loading-spinner {
display: inline-block;
animation: waiSpinnerBlink 2s linear infinite;
color: var(--wai-cyan);
}

@keyframes waiPulse {
0% { transform: scale(0.95); opacity: 0.7; }
50% { transform: scale(1.05); opacity: 1; }
100% { transform: scale(0.95); opacity: 0.7; }
}

/* ── Think Box — smooth accordion (checklist #14) ─────────── */
.wai-think-box {
background    : rgba(153,69,255,.04);
border        : 1px solid rgba(0,240,255,.18);
border-radius : 8px;
padding       : 8px 12px;
margin-bottom : 6px;
cursor        : pointer;
transition    : background 0.2s;
overflow      : hidden;
}
.wai-think-box:hover { background: rgba(153,69,255,.08); }

.wai-think-steps {
display              : grid;
grid-template-rows   : 0fr;
transition           : grid-template-rows 0.25s ease;
}
.wai-think-steps.open { grid-template-rows: 1fr; }
.wai-think-inner      { overflow: hidden; padding-top: 4px; }

.wai-step-item {
font-size    : 0.71rem;
color        : #848e9c;
padding      : 2px 0;
display      : flex;
align-items  : center;
gap          : 6px;
font-family  : 'Inter', sans-serif;
}
.wai-step-item.done   { color: #0ECB81; }
.wai-step-item.active { color: #00F0FF; }
.wai-step-item::before {
content       : '·';
font-size     : 1rem;
line-height   : 1;
flex-shrink   : 0;
}
.wai-step-item.done::before  { content: '✓'; font-size: .7rem; }
.wai-step-item.active::before { content: '›'; color: #00F0FF; }

/* ── Table support (checklist #15) ───────────────────────── */
.wai-table {
width           : 100%;
border-collapse : collapse;
font-size       : 0.75rem;
margin          : 6px 0;
font-family     : 'Inter', sans-serif;
}
.wai-table td {
padding      : 4px 8px;
border-bottom: 1px solid rgba(255,255,255,.06);
color        : #c9d1d9;
}
.wai-table tr:first-child td {
color       : #00F0FF;
font-weight : 600;
font-family : 'Rajdhani', sans-serif;
letter-spacing: .04em;
}
.wai-table tr:hover td { background: rgba(255,255,255,.02); }

/* ── Live dot + token badge (checklist #16) ──────────────── */
.wai-dot-live {
width         : 6px;
height        : 6px;
border-radius : 50%;
background    : #0ECB81;
display       : inline-block;
flex-shrink   : 0;
animation     : waiDotBlink 2s ease-in-out infinite;
}
.wai-token-badge {
font-size     : 0.65rem;
color         : #848e9c;
background    : rgba(255,255,255,.05);
padding       : 1px 6px;
border-radius : 10px;
margin-left   : auto;
font-family   : 'Inter', sans-serif;
}