/* ============================================================
   天机LTS V10 对话系统样式 - 聊天对话框 & 消息流
   ============================================================ */

/* ====== AI Greeting Card (首页) ====== */
.chat-stage {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  min-height: auto;
}
.ai-card {
  text-align: center;
  padding: var(--space-xl) var(--space-lg) var(--space-lg);
  background: var(--bg-card);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  animation: fadeInUp 0.45s var(--ease-out-expo);
}
.ai-card-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  margin: 0 auto 12px;
  background: linear-gradient(135deg, rgba(100, 140, 255, 0.3), rgba(100, 200, 255, 0.15));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  border: 2px solid rgba(100, 140, 255, 0.2);
  position: relative;
}
.ai-card-avatar::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--down);
  border: 2px solid var(--bg-card);
}
.ai-card-title { font-size: 17px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.ai-card-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; line-height: 1.5; }
.ai-card-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 28px;
  border: none;
  border-radius: 100px;
  background: linear-gradient(135deg, #648cff, #4a6cf7);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
  letter-spacing: .01em;
  transition: all 0.2s;
  box-shadow: 0 4px 20px rgba(74, 108, 247, 0.25);
}
.ai-card-cta:hover { transform: translateY(-2px); box-shadow: 0 6px 28px rgba(74, 108, 247, 0.35); }
.ai-card-cta:active { transform: scale(0.96); }
.ai-card-links {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.ai-link-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 100px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.15s;
}
.ai-link-btn:hover { color: var(--text-accent); background: rgba(100, 140, 255, 0.06); }

/* ====== 快捷操作栏 ====== */
.chat-action-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-xs);
  margin-top: var(--space-sm);
}
.chat-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: var(--space-sm) var(--space-xs);
  border: none;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--border-card);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-sans);
  text-align: center;
  min-height: 64px;
}
.chat-action-btn:active { transform: scale(0.97); }
.chat-action-btn.primary {
  background: linear-gradient(135deg, rgba(100, 140, 255, 0.15), rgba(60, 100, 220, 0.08));
  border-color: rgba(100, 140, 255, 0.25);
}
.chat-action-btn.primary .act-text { color: var(--text-accent); }
.act-icon { font-size: 20px; flex-shrink: 0; }
.act-text { font-size: 12px; color: var(--text-secondary); font-weight: 500; }

/* ====== AI浮动按钮 ====== */
.ai-float-btn {
  position: fixed;
  bottom: 80px;
  right: 16px;
  z-index: 90;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(100, 140, 255, 0.35), rgba(60, 100, 220, 0.2));
  border: 1px solid rgba(100, 140, 255, 0.4);
  color: var(--text-accent);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  overflow: visible;
}
.ai-float-btn::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(100, 140, 255, 0.22), transparent 65%);
  animation: floatGlow 2.5s infinite;
  z-index: -1;
}
@keyframes floatGlow {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}
.ai-float-btn:active { transform: scale(0.93); }
.ai-float-btn .unread-dot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--up);
}

/* ====== QA Overlay (全屏弹窗) ====== */
.qa-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: qaOverlayIn 0.2s var(--ease-out-expo);
}
.qa-overlay.hidden { display: none; }
@keyframes qaOverlayIn { from { opacity: 0; } to { opacity: 1; } }

.qa-dialog {
  width: 100%;
  max-width: 460px;
  height: 92dvh;
  max-height: 92dvh;
  background: var(--bg-base);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: qaSlideUp 0.3s var(--ease-spring);
}
@keyframes qaSlideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* Header */
.qa-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-card);
  flex-shrink: 0;
  background: var(--bg-base);
}
.qa-dialog-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.qa-dialog-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--bg-glass);
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qa-dialog-subtitle { font-size: 10px; color: var(--text-muted); font-weight: 400; }

/* ====== Category Chips ====== */
.qa-chip-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 6px 14px;
  scrollbar-width: none;
  flex-shrink: 0;
}
.qa-chip-row::-webkit-scrollbar { display: none; }
.qa-chip {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 100px;
  background: var(--bg-glass);
  border: 1px solid var(--border-card);
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-sans);
  user-select: none;
}
.qa-chip.active {
  background: rgba(100, 140, 255, 0.18);
  border-color: var(--border-active);
  color: var(--text-accent);
}

/* ====== Message Flow Area ====== */
.qa-msg-area {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  scroll-behavior: smooth;
}

/* Message Bubble Row */
.msg-row {
  display: flex;
  gap: 8px;
  animation: msgIn 0.35s var(--ease-out-expo) both;
  max-width: 100%;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.msg-row.ai { justify-content: flex-start; }
.msg-row.user { justify-content: flex-end; flex-direction: row-reverse; }
.msg-row.user .msg-avatar { display: none; }

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(135deg, rgba(100, 140, 255, 0.3), rgba(100, 200, 255, 0.12));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  align-self: flex-start;
}
.msg-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.7;
  position: relative;
  word-break: break-word;
}
.msg-row.ai .msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-top-left-radius: 4px;
  color: var(--text-secondary);
}
.msg-row.ai .msg-bubble b,
.msg-row.ai .msg-bubble strong { color: var(--text-accent); font-weight: 600; }
.msg-row.user .msg-bubble {
  background: linear-gradient(135deg, rgba(100, 140, 255, 0.25), rgba(60, 100, 220, 0.15));
  border: 1px solid rgba(100, 140, 255, 0.3);
  border-top-right-radius: 4px;
  color: var(--text-primary);
}

/* System message */
.msg-row.system { justify-content: center; }
.msg-row.system .msg-bubble {
  font-size: 11px;
  color: var(--text-muted);
  background: transparent;
  border: none;
  text-align: center;
  padding: 4px 0;
  max-width: 100%;
}

/* Bubble actions */
.msg-bubble .bubble-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 8px 14px;
  border-radius: 100px;
  background: linear-gradient(135deg, rgba(100, 140, 255, 0.2), rgba(60, 100, 220, 0.1));
  color: var(--text-accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid rgba(100, 140, 255, 0.25);
  transition: all 0.15s;
}
.msg-bubble .bubble-nav:active { transform: scale(0.96); }

.msg-bubble .bubble-sugs {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.msg-bubble .bubble-sug {
  padding: 6px 12px;
  border-radius: 100px;
  background: var(--bg-glass);
  border: 1px solid var(--border-card);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.msg-bubble .bubble-sug:active {
  background: rgba(100, 140, 255, 0.15);
  border-color: var(--border-active);
  color: var(--text-accent);
}

.msg-bubble .bubble-stock-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 5px 10px;
  border-radius: 100px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--up);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

/* ====== Typing Indicator ====== */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 0 40px;
  opacity: 0;
  animation: fadeIn 0.2s forwards;
}
.typing-indicator .typing-bubble {
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  border-top-left-radius: 4px;
}
.typing-dots { display: flex; gap: 3px; }
.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: dotBounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotBounce {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* ====== Quick Hints ====== */
.qa-quick-hints {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 14px 4px;
  scrollbar-width: none;
  flex-shrink: 0;
}
.qa-quick-hints::-webkit-scrollbar { display: none; }
.qa-hint-chip {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 100px;
  background: var(--bg-glass);
  border: 1px solid var(--border-card);
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.qa-hint-chip:active {
  background: rgba(100, 140, 255, 0.12);
  border-color: var(--border-active);
  color: var(--text-accent);
}
.qa-hint-chip .hint-icon { font-size: 12px; margin-right: 2px; }

/* ====== Input Bar ====== */
.qa-input-bar {
  flex-shrink: 0;
  padding: 10px 14px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: var(--bg-base);
  border-top: 1px solid var(--border-card);
}
.qa-input-bar-inner {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.qa-chat-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 20px;
  padding: 10px 16px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  resize: none;
  max-height: 100px;
  min-height: 42px;
  line-height: 1.4;
  transition: border-color 0.2s;
}
.qa-chat-input:focus { border-color: var(--border-active); }
.qa-chat-input::placeholder { color: var(--text-muted); }
.qa-input-bar-inner .qa-send-btn {
  min-width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #648cff, #4a6cf7);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.qa-input-bar-inner .qa-send-btn:active { transform: scale(0.93); }
.qa-input-bar-inner .qa-send-btn:disabled { opacity: 0.35; }

/* ====== 响应式 ====== */
@media (max-width: 480px) {
  .chat-action-bar { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 360px) {
  .chat-action-bar { grid-template-columns: repeat(2, 1fr); }
}
