/* ============================================================
 * 众效智囊 - 统一回答展示协议样式（v2 render blocks）
 * 同时被智囊页（/company/thinktank.php）和首页/服务页弹窗（agent-widget.js）使用
 * 设计原则：
 *   1. 不像知识库卡片（避免大边框 + 蓝色描边）
 *   2. 块之间用留白分隔，不用粗边框
 *   3. 不用黄底警告感
 *   4. 列表清晰、留白充足
 *   5. pitfall 默认折叠
 *   6. CTA 弱化（次要色 + 小尺寸）
 *   7. 移动端不横向溢出
 * ============================================================ */

/* ---------- 容器 ---------- */
.agent-response-root {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  font-size: 14px;
  line-height: 1.65;
  color: #1f2937;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.agent-response-root * {
  box-sizing: border-box;
  max-width: 100%;
}

/* ---------- 基础块间距（用 margin 而非边框分隔） ---------- */
.agent-block {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}
.agent-block + .agent-block {
  margin-top: 14px;
}

/* ---------- 普通段落 / intro ---------- */
.agent-block-paragraph {
  margin: 0;
  padding: 0;
  color: #1f2937;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
.agent-block-paragraph + .agent-block-paragraph {
  margin-top: 8px;
}

/* ---------- intro 块（开头自然分析段）---------- */
.agent-block-intro {
  color: #1f2937;
}

/* ---------- steps 块 ---------- */
.agent-block-steps-title {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}
.agent-block-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.agent-block-list-item {
  position: relative;
  padding-left: 18px;
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
  color: #334155;
}
.agent-block-list-item::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 9px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #94a3b8;
}
.agent-block-item-title {
  font-weight: 600;
  color: #0f172a;
}
.agent-block-item-text {
  color: #475569;
}

/* ---------- summary 块（我的判断 - 轻量卡片） ---------- */
.agent-block-summary {
  padding: 10px 12px;
  background: #f8fafc;
  border-left: 2px solid #cbd5e1;
  border-radius: 0 6px 6px 0;
  color: #334155;
}
.agent-block-summary-title {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 4px;
  letter-spacing: 0.04em;
}

/* ---------- pitfall 块（默认折叠，淡灰背景，非黄底） ---------- */
.agent-block-pitfall {
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
}
.agent-block-pitfall > summary {
  list-style: none;
  cursor: pointer;
  font-weight: 600;
  color: #475569;
  font-size: 13px;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
  outline: none;
}
.agent-block-pitfall > summary::-webkit-details-marker {
  display: none;
}
.agent-block-pitfall > summary::before {
  content: "▸";
  display: inline-block;
  width: 12px;
  color: #94a3b8;
  transition: transform 0.15s ease;
  font-size: 11px;
}
.agent-block-pitfall[open] > summary::before {
  transform: rotate(90deg);
}
.agent-block-pitfall-body {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e2e8f0;
  color: #475569;
}

/* ---------- CTA 块（弱化、底部、不强销售） ---------- */
.agent-block-cta {
  display: flex;
  justify-content: flex-start;
  margin-top: 4px;
}
.agent-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: #475569;
  background: transparent;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
  max-width: 100%;
}
.agent-action-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #334155;
}
.agent-action-btn:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}
.agent-action-cta {
  color: #1d4ed8;
  border-color: #bfdbfe;
  background: #f8fafc;
}
.agent-action-cta:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1e40af;
}

/* ---------- actions 按钮组（clarify / handoff / 快速回复） ---------- */
.agent-block-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.agent-block-actions .agent-action-btn {
  font-size: 12.5px;
  padding: 5px 12px;
}

/* ---------- handoff 块（留资引导） ---------- */
.agent-block-handoff {
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.agent-block-handoff-title {
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 6px;
}

/* ---------- clarify 块（澄清选项） ---------- */
.agent-block-clarify {
  padding: 10px 12px;
  background: #f8fafc;
  border-radius: 8px;
}
.agent-block-clarify-title {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 6px;
}

/* ---------- mode 标识差异化（弱化） ---------- */
.agent-mode-direct .agent-block-paragraph {
  color: #334155;
}
.agent-mode-handoff .agent-block-handoff {
  background: #eff6ff;
  border-color: #bfdbfe;
}

/* ---------- 命名空间微调 ---------- */
.agent-response-thinktank {
  font-size: 14.5px;
}
.agent-response-agent {
  font-size: 14px;
}

/* ============================================================
 * 响应式适配
 * ============================================================ */
@media (max-width: 820px) {
  .agent-response-root {
    font-size: 13.5px;
  }
  .agent-response-thinktank {
    font-size: 14px;
  }
  .agent-block + .agent-block {
    margin-top: 12px;
  }
  .agent-block-list {
    gap: 8px;
  }
}

@media (max-width: 430px) {
  .agent-response-root {
    font-size: 13px;
    line-height: 1.6;
  }
  .agent-response-thinktank,
  .agent-response-agent {
    font-size: 13px;
  }
  .agent-block-paragraph,
  .agent-block-list-item {
    font-size: 13px;
    line-height: 1.6;
  }
  .agent-block-steps-title,
  .agent-block-summary-title,
  .agent-block-pitfall > summary,
  .agent-block-clarify-title {
    font-size: 12.5px;
  }
  .agent-block-actions {
    gap: 6px;
  }
  .agent-action-btn {
    font-size: 12.5px;
    padding: 6px 12px;
  }
}

@media (max-width: 375px) {
  .agent-response-root {
    font-size: 12.5px;
  }
  .agent-block-list-item {
    padding-left: 16px;
  }
  .agent-action-btn {
    font-size: 12px;
    padding: 5px 10px;
  }
}

/* ============================================================
 * 防止输入框遮挡回答底部
 * （由各页面消息容器的 padding-bottom 控制，这里只做安全兜底）
 * ============================================================ */
.agent-response-root:last-child {
  padding-bottom: 4px;
}

/* ============================================================
 * P0 structured answer restoration
 * Shared by /company/thinktank.php and the floating Agent widget.
 * ============================================================ */
.message-ai .message-bubble.thinktank-response:has(.pxy-answer-card),
.agent-chat-bubble-assistant:has(.pxy-answer-card) {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  max-width: min(92%, 680px) !important;
}

.agent-response-container,
.agent-response-root {
  min-width: 0;
}

.pxy-answer-card {
  position: relative;
  overflow: hidden;
  width: 100%;
  background: #fff;
  border: 1px solid #dbe4f0;
  border-radius: 14px;
  padding: 16px 18px 18px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  color: #1e293b;
}

.pxy-answer-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #0052cc, #5b8def);
}

.pxy-answer-card::after {
  content: "";
  position: absolute;
  top: 16px;
  left: 0;
  width: 3px;
  height: 28px;
  border-radius: 0 3px 3px 0;
  background: #0052cc;
  opacity: 0.9;
}

.pxy-answer-section {
  position: relative;
  margin: 0;
  padding: 0;
}

.pxy-answer-section + .pxy-answer-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #eef2f7;
}

.pxy-answer-section-title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 8px;
  color: #0052cc;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.pxy-answer-section-title::before {
  content: "";
  flex: 0 0 auto;
  width: 3px;
  height: 14px;
  border-radius: 999px;
  background: #0052cc;
}

.pxy-answer-section-content {
  color: #334155;
  font-size: 14px;
  line-height: 1.75;
}

.pxy-answer-paragraph {
  margin: 0;
  white-space: pre-wrap;
}

.pxy-answer-paragraph + .pxy-answer-paragraph {
  margin-top: 8px;
}

.pxy-answer-bold,
.pxy-answer-item-title {
  color: #0f172a;
  font-weight: 800;
}

.pxy-answer-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pxy-answer-paragraph + .pxy-answer-list,
.pxy-answer-list + .pxy-answer-paragraph {
  margin-top: 10px;
}

.pxy-answer-list-item {
  position: relative;
  margin: 0;
  padding-left: 20px;
  color: #334155;
  line-height: 1.7;
}

.pxy-answer-list-item::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 0.72em;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #7aa7ee;
}

.pxy-answer-section-summary {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
}

.pxy-answer-pitfall {
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  padding: 10px 12px;
  background: #f8fafc;
}

.pxy-answer-pitfall > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  margin-bottom: 0;
}

.pxy-answer-pitfall > summary::-webkit-details-marker {
  display: none;
}

.pxy-answer-pitfall[open] .pxy-answer-pitfall-content {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e2e8f0;
}

.pxy-answer-divider {
  height: 1px;
  border-top: 1px dashed #cbd5e1;
  margin: 16px 0;
}

.pxy-answer-cta {
  background: linear-gradient(135deg, #eef6ff, #f8fbff);
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 14px 16px;
}

.pxy-answer-cta-label {
  margin: 0 0 6px;
  color: #0052cc;
  font-size: 12px;
  font-weight: 800;
}

.pxy-answer-cta-text {
  margin: 0 0 10px;
  color: #1e3a8a;
  font-size: 13.5px;
  line-height: 1.65;
}

.pxy-answer-cta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pxy-answer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.pxy-answer-attachment-actions {
  padding-top: 12px;
  border-top: 1px solid #eef2f7;
}

.pxy-answer-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 13px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #f8fbff;
  color: #1d4ed8;
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.3;
  white-space: normal;
  text-align: center;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.pxy-answer-chip:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1e40af;
}

.pxy-answer-chip:active {
  transform: translateY(1px);
}

.pxy-answer-chip:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.pxy-answer-chip-primary {
  background: #0052cc;
  border-color: #0052cc;
  color: #fff;
}

.pxy-answer-chip-primary:hover {
  background: #003d9b;
  border-color: #003d9b;
  color: #fff;
}

.pxy-answer-direct {
  color: #334155;
  line-height: 1.72;
}

.pxy-answer-direct .pxy-answer-direct-paragraph {
  margin: 0;
  white-space: pre-wrap;
}

.pxy-answer-direct .pxy-answer-direct-paragraph + .pxy-answer-direct-paragraph {
  margin-top: 8px;
}

.pxy-answer-direct .pxy-answer-list {
  margin-top: 8px;
}

.pxy-handoff-card,
.pxy-clarify-card {
  background: #f8fbff;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 14px;
  color: #334155;
}

.pxy-handoff-title,
.pxy-clarify-title {
  margin: 0 0 8px;
  color: #0f172a;
  font-size: 14px;
  font-weight: 800;
}

.pxy-handoff-content,
.pxy-clarify-content {
  color: #475569;
  font-size: 13.5px;
  line-height: 1.7;
}

.pxy-handoff-actions,
.pxy-clarify-actions {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #dbeafe;
}

.thinktank-message-feedback,
.agent-feedback-bar {
  clear: both;
}

@media (max-width: 640px) {
  .message-ai .message-bubble.thinktank-response:has(.pxy-answer-card),
  .agent-chat-bubble-assistant:has(.pxy-answer-card) {
    max-width: 96% !important;
  }

  .pxy-answer-card {
    border-radius: 13px;
    padding: 14px 14px 16px;
  }

  .pxy-answer-section + .pxy-answer-section {
    margin-top: 14px;
    padding-top: 12px;
  }

  .pxy-answer-section-content,
  .pxy-answer-direct,
  .pxy-answer-list-item {
    font-size: 13px;
    line-height: 1.68;
  }

  .pxy-answer-actions {
    gap: 7px;
  }

  .pxy-answer-chip {
    min-height: 36px;
    padding: 7px 12px;
    font-size: 12px;
  }
}

/* ==================== Agent 接管通知横幅 ==================== */
.agent-takeover-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin: 4px 0;
  background: #f0f4f8;
  border: 1px solid #d6dee6;
  border-radius: 10px;
  font-size: 13px;
  color: #1e3a5f;
  position: sticky;
  top: 0;
  z-index: 5;
  animation: agentBannerSlideIn 0.35s ease-out;
}
@keyframes agentBannerSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.agent-takeover-banner-icon {
  font-size: 20px;
  flex-shrink: 0;
}
.agent-takeover-banner-text {
  flex: 1;
  line-height: 1.5;
}
.agent-takeover-banner-end {
  flex-shrink: 0;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  color: #1e3a5f;
  background: transparent;
  border: 1px solid #1e3a5f;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.agent-takeover-banner-end:hover {
  background: #1e3a5f;
  color: #fff;
  border-color: #1e3a5f;
}
.agent-session-feedback {
  margin: 8px 0;
  padding: 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  text-align: center;
}
.agent-session-feedback-title {
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 10px;
}
.agent-session-feedback-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 8px;
}
.agent-session-feedback-actions button {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.agent-session-feedback-actions button:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}
.agent-session-feedback-skip {
  font-size: 12px;
  color: #94a3b8;
  background: transparent;
  border: none;
  cursor: pointer;
  text-decoration: underline;
}
.agent-session-feedback-skip:hover {
  color: #64748b;
}
.agent-session-feedback-thanks {
  font-size: 14px;
  color: #16a34a;
  padding: 8px;
}

/* ==================== 系统提示条（区别于 AI/客服气泡） ==================== */
/* 用于：转人工等待、转人工超时、追问引导、会话已结束等系统级提示 */
/* 居中显示，不占据 AI 气泡宽度，无反馈按钮 */
.agent-system-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 85%;
  margin: 8px auto;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  animation: agentMsgIn 0.26s ease both;
}
.agent-system-notice-icon {
  font-size: 16px;
  flex-shrink: 0;
  line-height: 1;
}
.agent-system-notice--info {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #475569;
}
.agent-system-notice--waiting {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}
.agent-system-notice--success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}
.agent-system-notice--warning {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}
/* 卡片变体：含交互内容（表单/多行信息） */
.agent-system-notice--card {
  flex-direction: column;
  gap: 6px;
  max-width: 300px;
  padding: 14px 18px;
}
.agent-system-notice-title {
  font-size: 14px;
  font-weight: 600;
}
.agent-system-notice-subtext {
  font-size: 12px;
  opacity: 0.85;
}
.agent-system-notice-form {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 240px;
  margin-top: 4px;
}
.agent-system-notice-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}
.agent-system-notice-input:focus {
  border-color: #6366f1;
}
.agent-system-notice-btn {
  padding: 8px 16px;
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.agent-system-notice-btn:hover {
  background: #4f46e5;
}

/* ==================== 右侧进度导航条 ==================== */
/* DeepSeek 风格：多轮对话后右侧竖条，hover 显示锚点列表，点击定位 */
/* 注意：top/bottom 由 JS 注入时根据容器设置，避免双 CSS 冲突 */
.chat-progress-rail {
  position: absolute;
  right: 4px;
  width: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  cursor: pointer;
  z-index: 5;
  transition: width 0.15s ease;
}
.chat-progress-rail:hover {
  width: 6px;
}
.chat-progress-rail.is-hidden {
  display: none;
}
.chat-progress-thumb {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: #6366f1;
  border-radius: 2px;
  height: 0%;
  transition: height 0.12s linear;
}
.chat-progress-popover {
  position: absolute;
  right: 14px;
  top: 0;
  width: 180px;
  max-height: 280px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  padding: 6px;
  opacity: 0;
  transform: translateX(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 23, 42, 0.15) transparent;
}
.chat-progress-popover::-webkit-scrollbar {
  width: 5px;
}
.chat-progress-popover::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.15);
  border-radius: 4px;
}
.chat-progress-rail:hover .chat-progress-popover {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
.chat-progress-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: #475569;
  transition: background 0.12s ease;
}
.chat-progress-item:hover {
  background: #f1f5f9;
}
.chat-progress-item.is-active {
  color: #6366f1;
  font-weight: 600;
}
.chat-progress-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #cbd5e1;
  flex-shrink: 0;
  transition: transform 0.15s ease, background 0.15s ease;
}
.chat-progress-item.is-active .chat-progress-dot {
  background: #6366f1;
  transform: scale(1.4);
}
.chat-progress-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-progress-num {
  font-size: 10px;
  color: #94a3b8;
  flex-shrink: 0;
}
.chat-message-flash {
  animation: chatFlashHighlight 1.2s ease-out;
}
@keyframes chatFlashHighlight {
  0% { background-color: rgba(99, 102, 241, 0.15); }
  100% { background-color: transparent; }
}

/* ==================== Agent 客服消息气泡 ==================== */
.agent-bubble-agent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  align-self: flex-start;
  max-width: 85%;
  margin: 4px 0;
}
.agent-bubble-agent .agent-bubble-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #1e3a5f;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  line-height: 1;
}
.agent-bubble-agent .agent-bubble-body {
  flex: 1;
  min-width: 0;
}
.agent-bubble-agent .agent-bubble-inner {
  background: #f0f4f8;
  border: 1px solid #d6dee6;
  border-radius: 14px 14px 14px 4px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.6;
  color: #1f2430;
  word-break: break-word;
  max-width: 100%;
}
.agent-bubble-agent .agent-bubble-label {
  font-size: 11px;
  color: #6b7785;
  margin-top: 4px;
  padding-left: 2px;
  font-weight: 600;
}
