/* ============================================================
 * 众效智囊 - 统一回答展示协议样式（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;
  }
}
