/* ============ HTML Artifact ============ */
.artifact-block {
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--card-bg);
}
.artifact-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border-soft);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
}
.artifact-header-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.7;
}
.artifact-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.artifact-actions { display: flex; gap: 4px; flex-shrink: 0; }
.artifact-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  background: transparent;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.artifact-btn:hover {
  background: var(--card-bg);
  color: var(--text-2);
  border-color: var(--border);
}
.artifact-btn svg { width: 12px; height: 12px; flex-shrink: 0; opacity: 0.85; }
.artifact-frame {
  width: 100%;
  border: none;
  display: block;
  background: transparent;
}
.artifact-placeholder-body {
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(90deg, var(--card-bg) 0%, var(--sidebar-bg) 50%, var(--card-bg) 100%);
  background-size: 200% 100%;
  animation: artifact-shimmer 1.4s ease-in-out infinite;
}
.artifact-placeholder-label {
  font-size: 13px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 8px;
}
.artifact-placeholder-label::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent, #378ADD);
  animation: artifact-dot-pulse 1s ease-in-out infinite;
}
@keyframes artifact-shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
@keyframes artifact-dot-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50%      { opacity: 1;    transform: scale(1.1); }
}

/* ── 流式生成态：让用户「看见」模型在画 ──
   .artifact-block.is-streaming 给整体 + chip + iframe 底色加生命感 */
.artifact-block.is-streaming {
  border-color: rgba(31, 60, 51, 0.18);
  box-shadow: 0 0 0 3px rgba(31, 60, 51, 0.04), 0 8px 24px -10px rgba(31, 60, 51, 0.12);
  position: relative;
  overflow: hidden;
}
/* 顶部光带：从左到右扫过，2.4s 一轮，提示"还在写" */
.artifact-block.is-streaming::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--ink, #1f3c33), transparent);
  background-size: 40% 100%;
  background-repeat: no-repeat;
  animation: artifact-top-sweep 2.4s ease-in-out infinite;
  z-index: 2;
  pointer-events: none;
}
.artifact-block.is-streaming .artifact-header {
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--card-bg) 100%);
}
/* iframe 流式期：底色加极淡的 shimmer，给用户"内容正在浮现"的感觉。
   一旦 receiver 把 partial HTML 写入，iframe 自身背景会覆盖这层 shimmer。 */
.artifact-block.is-streaming .artifact-frame {
  background:
    linear-gradient(90deg, transparent 0%, rgba(31, 60, 51, 0.035) 50%, transparent 100%) var(--card-bg);
  background-size: 200% 100%, 100% 100%;
  animation: artifact-shimmer 1.8s ease-in-out infinite;
}
html[data-theme="dark"] .artifact-block.is-streaming {
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.03), 0 8px 24px -10px rgba(0, 0, 0, 0.4);
}
html[data-theme="dark"] .artifact-block.is-streaming::before {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  background-size: 40% 100%;
  background-repeat: no-repeat;
}

/* 「生成中」chip：脉冲圆点 + 渐变背景 + shimmer 文字 */
.artifact-streaming-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  padding: 2px 9px 2px 7px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink, #1f3c33);
  background: rgba(31, 60, 51, 0.08);
  border: 1px solid rgba(31, 60, 51, 0.14);
  border-radius: 10px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.artifact-streaming-tag::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink, #1f3c33);
  animation: artifact-tag-pulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}
html[data-theme="dark"] .artifact-streaming-tag {
  color: #e6e5e0;
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.16);
}
html[data-theme="dark"] .artifact-streaming-tag::before {
  background: #c8e6c9;
}
@keyframes artifact-top-sweep {
  0%   { background-position: -40% 0; }
  100% { background-position: 140% 0; }
}
@keyframes artifact-tag-pulse {
  0%, 100% { opacity: 0.55; transform: scale(0.85); box-shadow: 0 0 0 0 rgba(31, 60, 51, 0.35); }
  50%      { opacity: 1;    transform: scale(1);    box-shadow: 0 0 0 4px rgba(31, 60, 51, 0); }
}


/* ── 报告 / 汇报材料 Canvas 面板 (reportCanvas.js) ──────────────────
   右侧独立平行第三列(侧栏 | 对话 | Canvas),复用 .artifact-block 渲染报告。
   作为 body flex 流内第三列:打开时 .main(flex:1)自动让位收窄、两者并排可见,
   不覆盖对话(Codex 风格);关闭([hidden])退出 flex 行,main 自动回满。
   用 flex:0 0 auto + width(不用 flex-basis),让拖拽时设的 inline width 生效;
   position:relative 给左缘 resize handle 作定位锚。窄屏退回全屏覆盖(见下方断点)。 */
.report-canvas {
  position: relative;
  flex: 0 0 auto;
  /* 默认宽度够放下一张固定 794px 的 A4 页(+内边距)而不横向滚动;窄屏/小窗
     会触发 840 断点退全屏覆盖。用户可拖左缘改宽。 */
  width: var(--report-canvas-w, clamp(420px, 54vw, 880px));
  min-width: 360px;
  max-width: 76%;
  height: 100%;
  align-self: stretch;
  background: var(--bg, #fff);
  border-left: 1px solid var(--border-soft, rgba(0,0,0,0.08));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* 开/合平滑过渡：宽度收放 + 淡入淡出。关态不再 display:none（不可过渡），
     改 width:0（仍在 flex 流里，主栏随之平滑收放）。 */
  transition: width .28s ease, opacity .22s ease;
}
/* 关态：宽度收到 0 + 淡出（!important 压过拖拽设的 inline width，保证能收起）。
   保持元素在 DOM/布局里（非 display:none）才能过渡。 */
.report-canvas[hidden] {
  width: 0 !important;
  min-width: 0 !important;
  opacity: 0;
  border-left: none;
  pointer-events: none;
}
.report-canvas-resize {
  position: absolute;
  left: 0;
  top: 0;
  width: 6px;
  height: 100%;
  cursor: ew-resize;
  z-index: 2;
}
.report-canvas-resize:hover { background: var(--border, rgba(0,0,0,0.1)); }
body.report-canvas-resizing { user-select: none; cursor: ew-resize; }
.report-canvas-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft, rgba(0,0,0,0.06));
  flex-shrink: 0;
}
.report-canvas-title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink, #1f2320);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.report-canvas-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  background: none;
  color: var(--text-3, #8a8578);
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
}
.report-canvas-close:hover { background: var(--ink-soft, rgba(0,0,0,0.05)); color: var(--ink, #1f2320); }
.report-canvas-close svg { width: 16px; height: 16px; }
/* 顶栏导出按钮组（HTML / PDF）—— 复用 .artifact-btn 样式，放在标题与关闭之间 */
.report-canvas-actions { display: flex; gap: 6px; flex-shrink: 0; }
.report-canvas-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
}
/* Canvas 里的报告**平铺**：去掉内层 artifact 卡片的边框/底色/圆角/外边距，
   并隐藏它自己的头部（标题 + 导出按钮已上移到 Canvas 顶栏）——否则会出现
   "卡片套卡片 + 标题重复"的怪异嵌套（用户实测痛点）。 */
.report-canvas-body .artifact-block {
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
}
.report-canvas-body .artifact-header { display: none; }

/* 主对话气泡里替代报告 artifact 的小 chip:点开右侧 Canvas */
.report-canvas-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--ink, #1f2320);
  background: var(--ink-soft, rgba(0,0,0,0.04));
  border: 1px solid var(--border-soft, rgba(0,0,0,0.06));
  border-radius: 10px;
  cursor: pointer;
}
.report-canvas-chip:hover { border-color: var(--border, rgba(0,0,0,0.12)); }
.report-canvas-chip .rcc-ico { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.8; }

/* 窄屏(<840,与 sidebar 浮层化同断点):三列放不下 → Canvas 退回全屏覆盖。 */
@media (max-width: 840px) {
  .report-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 100%;
    z-index: 80;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.12);
    /* 窄屏是全屏浮层 → 用滑入代替宽度收放（宽度收放在 fixed 全屏下不自然）。 */
    transform: translateX(0);
    transition: transform .3s ease, opacity .22s ease;
  }
  /* 关态：滑出右侧而非收宽（覆盖桌面态的 width:0）。 */
  .report-canvas[hidden] {
    width: 100% !important;
    transform: translateX(100%);
    opacity: 1;
  }
}
