/* ============================================
   播客控制台 — AI 对话飘窗（ai-chat.css）
   借鉴 opencity/console/chat.css 一比一移植（对话区部分）：
   - 类名统一 aichat- 前缀，避免与 dashboard.css 冲突
   - 设计令牌映射到控制台变量（--bg/--border/--accent/--text…）
   - 动画名加 aichat 前缀，防止覆盖全局 fadeIn/bubbleIn
   - 承载体是右栏飘窗（固定 460px / 手机端 94vw），不依赖 --header-h/--nav-h
   ============================================ */

.aichat-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.aichat-role-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.aichat-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--gradient); display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0; overflow: hidden;
}
.aichat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.aichat-name {
  font-weight: 700; font-size: 1.02rem; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px;
}
.aichat-status {
  font-size: 0.78rem; color: var(--text3); margin-top: 3px;
  padding: 2px 10px; border-radius: 999px; background: var(--bg3);
  display: inline-block;
}
.aichat-status.online { color: var(--success); }
.aichat-status.listening { color: var(--accent); }
.aichat-status.speaking { color: var(--warning); }
.aichat-close {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--text2); cursor: pointer; font-size: 15px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: all .2s;
}
.aichat-close:hover { color: var(--text); border-color: var(--border-hover); }

/* ---------- 对话窗口 ---------- */
.aichat-window {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.aichat-window::-webkit-scrollbar { width: 6px; }
.aichat-window::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.aichat-placeholder {
  margin: auto; text-align: center; font-size: 0.9rem; line-height: 1.9;
  color: var(--text3);
}
.aichat-messages { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }

.aichat-msg {
  max-width: 82%; width: fit-content; padding: 10px 14px; border-radius: 14px;
  font-size: 0.9rem; line-height: 1.6; word-break: break-word;
  animation: aichatBubbleIn .2s;
}
.aichat-msg.user {
  align-self: flex-end; background: var(--gradient); color: #fff;
  border-bottom-right-radius: 4px;
}
.aichat-msg.ai {
  align-self: flex-start; background: var(--bg3); color: var(--text);
  border-bottom-left-radius: 4px; border: 1px solid var(--border);
}
.aichat-msg.system {
  align-self: center; background: transparent; color: var(--text3);
  font-size: 0.8rem; max-width: 90%; text-align: center;
}
.aichat-msg.partial {
  align-self: flex-start; background: var(--bg3); color: var(--text2);
  border: 1px dashed var(--border); opacity: 0.85;
}
@keyframes aichatBubbleIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* 加载更早消息 */
.aichat-load-more {
  text-align: center; padding: 8px; color: var(--text3); font-size: 0.8rem;
  cursor: pointer;
}
.aichat-load-more:hover { color: var(--accent); }

/* ---------- 底部麦克风 ---------- */
.aichat-bottom {
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  flex-shrink: 0;
}
.aichat-mic {
  width: 64px; height: 64px; border-radius: 50%; border: none;
  background: var(--gradient); color: #fff; font-size: 1.6rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px var(--accent-glow); transition: all .2s; cursor: pointer;
}
.aichat-mic:hover { transform: scale(1.05); }
.aichat-mic.listening {
  background: var(--danger); animation: aichatMicPulse 1.4s infinite;
}
@keyframes aichatMicPulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.5); }
  70% { box-shadow: 0 0 0 18px rgba(255, 107, 107, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0); }
}
.aichat-hint { font-size: 0.8rem; color: var(--text3); }

/* ---------- 响应式（飘窗窄时 / 手机端） ---------- */
@media (max-width: 520px) {
  .aichat-topbar { padding: 10px 12px; }
  .aichat-avatar { width: 38px; height: 38px; font-size: 1.1rem; }
  .aichat-name { font-size: 0.92rem; max-width: 55vw; }
  .aichat-window { padding: 12px; }
  .aichat-msg { max-width: 88%; font-size: 0.87rem; }
  .aichat-mic { width: 56px; height: 56px; font-size: 1.4rem; }
}
