/* ==========================================================================
 * project.css — 项目对话页（两栏：项目列表 + 对话主区）
 * 左栏 .project-list (260px) | 右栏 .chat-area (flex)
 * 阶段进展以对话流内消息呈现（样式见 pipeline.css），非常驻泳道。
 * ========================================================================== */
.project-page { height: 100%; display: flex; overflow: hidden; }

/* ---- 左栏：项目列表 ---- */
.project-list {
  width: 260px; min-width: 260px; border-right: 1px solid var(--border);
  background: var(--card); display: flex; flex-direction: column; overflow: hidden;
}
.project-list-header { padding: 16px; border-bottom: 1px solid var(--border); }
.pl-head-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.pl-title { font-weight: var(--fw-semi); font-size: var(--fs-h4); }
.project-list-search { position: relative; }
.project-list-search input {
  width: 100%; padding: 8px 12px 8px 34px; border: 1px solid var(--border);
  border-radius: var(--r-btn); font-size: var(--fs-caption); background: var(--bg); outline: none;
  color: var(--text-main);
}
.project-list-search input:focus { border-color: var(--primary); }
.project-list-search .search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-weak); display: flex;
}
.project-items { flex: 1; overflow-y: auto; padding: 8px; }
.project-item {
  padding: 12px; border-radius: var(--r-btn); cursor: pointer;
  transition: all var(--dur-fast); margin-bottom: 4px; border: 1px solid transparent;
}
.project-item:hover { background: var(--bg); }
.project-item.active { background: var(--primary-ghost); border-color: var(--primary-light); }
.project-item-name { font-size: var(--fs-body); font-weight: var(--fw-medium); margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.project-item-meta { font-size: var(--fs-xs); color: var(--text-weak); display: flex; align-items: center; gap: 8px; }
.project-item-stage {
  font-size: 10px; padding: 1px 6px; border-radius: var(--r-xs); font-weight: var(--fw-medium);
  background: var(--primary-ghost); color: var(--primary);
}

/* ---- 右栏：对话主区 ---- */
.chat-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; background: var(--bg); }
.chat-header {
  padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--card);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; gap: 12px;
}
.chat-header-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.chat-proj-icon { font-size: 20px; line-height: 1; }
.chat-header-titles { min-width: 0; }
.chat-header-title { font-size: var(--fs-h4); font-weight: var(--fw-semi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header-stage { font-size: var(--fs-caption); color: var(--text-weak); }
.chat-header-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ---- 消息流 ---- */
.chat-messages { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.msg { display: flex; gap: 12px; max-width: 85%; animation: slideUp var(--dur) var(--ease) both; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar { flex-shrink: 0; }
.msg-content { flex: 1; min-width: 0; }
.msg-bubble {
  padding: 12px 16px; border-radius: var(--r-card); font-size: var(--fs-body);
  line-height: var(--lh-body); word-break: break-word;
}
.msg.assistant .msg-bubble { background: var(--card); border: 1px solid var(--border); border-top-left-radius: 4px; box-shadow: var(--shadow-card); }
.msg.user .msg-bubble { background: var(--primary); color: #fff; border-top-right-radius: 4px; }
.msg-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: var(--fs-caption); }
.msg.user .msg-meta { flex-direction: row-reverse; }
.msg-author { font-weight: var(--fw-semi); }
.msg-time { color: var(--text-weak); font-size: var(--fs-xs); }
.author-badge {
  font-size: 10px; padding: 1px 7px; border-radius: var(--r-pill); font-weight: var(--fw-medium);
}
.author-badge.agent { background: var(--primary-ghost); color: var(--primary); }
.author-badge.human { background: rgba(249,202,36,.15); color: var(--amigo-gold-deep); }
.author-badge.skill { background: rgba(0,184,148,.15); color: var(--success); }

/* markdown 气泡内容 */
.msg-bubble p { margin: 0 0 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { margin: 4px 0 8px; padding-left: 20px; }
.msg-bubble code { font-family: var(--font-mono); font-size: 12.5px; background: rgba(108,92,231,.15); padding: 1px 5px; border-radius: 4px; }
.msg.user .msg-bubble code { background: rgba(255,255,255,.2); }
.msg-bubble pre { background: #14152a; border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px; margin: 8px 0; overflow-x: auto; }
.msg-bubble pre code { background: transparent; padding: 0; color: #e6e6f0; font-size: 12.5px; line-height: 1.5; }
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 { margin: 8px 0 6px; line-height: var(--lh-title); }
.msg-bubble a { color: var(--primary-light); }

/* 流式打字光标 */
.typing-cursor { display: inline-block; width: 8px; height: 15px; background: var(--primary); vertical-align: text-bottom; margin-left: 2px; animation: blink 1s step-end infinite; }
.spin-inline { display: inline-flex; animation: spin .9s linear infinite; }

/* ---- 执行轨迹卡 ---- */
.agent-trajectory { background: var(--bg); border-radius: var(--r-md); padding: 12px; margin-top: 10px; border: 1px solid var(--border); }
.trajectory-head { font-size: var(--fs-xs); color: var(--text-weak); margin-bottom: 6px; font-weight: var(--fw-medium); }
.trajectory-step { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; font-size: var(--fs-caption); color: var(--text-sub); }
.trajectory-step:not(:last-child) { border-bottom: 1px dashed var(--border); }
.trajectory-icon { width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 10px; }
.trajectory-icon.done { background: rgba(0,184,148,.15); color: var(--success); }
.trajectory-icon.running { background: var(--primary-ghost); color: var(--primary); }
.trajectory-icon.pending { background: var(--border); color: var(--text-weak); }
.trajectory-text { flex: 1; }
.step-title { font-weight: var(--fw-medium); color: var(--text-main); }
.step-detail { color: var(--text-weak); font-size: var(--fs-xs); margin-top: 2px; }

/* ---- 决策卡 ---- */
.decision-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md); padding: 16px; margin-top: 10px; box-shadow: var(--shadow-card); }
.decision-title { font-size: var(--fs-body); font-weight: var(--fw-semi); margin-bottom: 10px; }
.decision-options { display: flex; flex-direction: column; gap: 8px; }
.decision-option {
  padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--r-btn);
  cursor: pointer; transition: all var(--dur-fast); display: flex; align-items: center; gap: 10px;
}
.decision-option:hover { border-color: var(--primary); background: var(--primary-ghost); }
.decision-option.selected { border-color: var(--primary); background: var(--primary-ghost); }
.decision-option-radio {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.decision-option.selected .decision-option-radio { border-color: var(--primary); }
.decision-option.selected .decision-option-radio::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.opt-label { font-weight: var(--fw-medium); font-size: var(--fs-body); }
.opt-desc { font-size: var(--fs-caption); color: var(--text-sub); margin-top: 2px; }
.decision-foot { margin-top: 12px; text-align: right; }

/* ---- 报告卡 ---- */
.report-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md); padding: 16px; margin-top: 10px; overflow: hidden; }
.report-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.report-type { font-size: var(--fs-caption); font-weight: var(--fw-semi); color: var(--primary); letter-spacing: .5px; }
.report-title { font-size: var(--fs-h4); font-weight: var(--fw-semi); margin-bottom: 8px; }
.report-summary { font-size: var(--fs-body); color: var(--text-sub); line-height: var(--lh-body); }
.report-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.report-stat { text-align: center; padding: 10px; background: var(--bg); border-radius: var(--r-sm); }
.report-stat-value { font-size: var(--fs-h3); font-weight: var(--fw-bold); }
.report-stat-label { font-size: var(--fs-xs); color: var(--text-weak); margin-top: 2px; }

/* ---- 输入区 ---- */
.chat-input-area { padding: 12px 20px 16px; border-top: 1px solid var(--border); background: var(--card); flex-shrink: 0; }
.chat-input-toolbar { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.chat-tool-btn {
  display: flex; align-items: center; gap: 4px; padding: 5px 10px;
  border-radius: var(--r-sm); font-size: var(--fs-xs); color: var(--text-sub);
  cursor: pointer; transition: all var(--dur-fast); border: 1px solid transparent;
}
.chat-tool-btn:hover { background: var(--primary-ghost); color: var(--primary); }
.chat-input-wrapper {
  display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--r-card); background: var(--bg);
  transition: all var(--dur-fast); position: relative;
}
.chat-input-wrapper:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ghost); background: var(--card); }
.chat-input-wrapper textarea {
  flex: 1; border: none; background: transparent; outline: none; resize: none;
  font-size: var(--fs-body); color: var(--text-main); max-height: 120px; min-height: 24px; line-height: var(--lh-body);
}
.chat-input-wrapper textarea::placeholder { color: var(--text-weak); }
.chat-voice-btn {
  width: 36px; height: 36px; border-radius: var(--r-btn); background: var(--primary-ghost);
  color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.chat-voice-btn:hover { background: var(--primary); color: #fff; }
.chat-voice-btn.recording { background: var(--accent); color: #fff; animation: pulseRing 1.6s infinite; }
.chat-send-btn {
  width: 36px; height: 36px; border-radius: var(--r-btn); background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all var(--dur-fast);
}
.chat-send-btn:hover:not(:disabled) { background: var(--primary-hover); transform: scale(1.05); }
.chat-send-btn:disabled { opacity: .5; cursor: not-allowed; }
/* 本地 dsh：停止生成按钮（流式中替换发送按钮） */
.chat-stop-btn {
  width: 36px; height: 36px; border-radius: var(--r-btn); background: var(--danger); color: #fff;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all var(--dur-fast);
}
.chat-stop-btn:hover { filter: brightness(1.1); transform: scale(1.05); }
/* 子代理块 */
.subagent-block { border-left: 2px solid var(--primary); }

/* @ 下拉 */
.mention-dropdown {
  position: absolute; bottom: 100%; left: 0; margin-bottom: 8px; width: 320px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-modal); max-height: 260px; overflow-y: auto; z-index: var(--z-popover);
}
.mention-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; transition: all var(--dur-fast); }
.mention-item:hover { background: var(--primary-ghost); }
.mention-item-info { flex: 1; min-width: 0; }
.mention-item-name { font-size: var(--fs-caption); font-weight: var(--fw-medium); display: flex; align-items: center; gap: 6px; }
.mention-item-desc { font-size: var(--fs-xs); color: var(--text-weak); }

/* ---- 右浏览区（#rightPanel） ---- */
.right-panel { width: 300px; min-width: 300px; border-left: 1px solid var(--border); background: var(--card); overflow-y: auto; }
.right-panel-inner { padding: 16px; }
.rp-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-card); padding: 16px; margin-bottom: 16px; }
.rp-label { font-size: var(--fs-caption); color: var(--text-weak); margin-bottom: 8px; }
.rp-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.rp-name { font-weight: var(--fw-semi); font-size: var(--fs-body); }
.rp-hint { font-size: var(--fs-xs); color: var(--text-weak); margin-top: 6px; }
.usage-bar { height: 6px; border-radius: var(--r-full); background: var(--border); overflow: hidden; }
.usage-bar-fill { height: 100%; background: var(--grad-primary); border-radius: var(--r-full); transition: width var(--dur) var(--ease); }
.rp-section { margin-bottom: 18px; }
.rp-section-title { font-size: var(--fs-caption); font-weight: var(--fw-semi); color: var(--text-sub); margin-bottom: 10px; }
.rp-doc { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r-sm); cursor: pointer; transition: background var(--dur-fast); }
.rp-doc:hover { background: var(--bg); }
.rp-doc-icon { font-size: 16px; }
.rp-doc-main { flex: 1; min-width: 0; }
.rp-doc-name { font-size: var(--fs-caption); font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-doc-meta { font-size: 10px; color: var(--text-weak); margin-top: 3px; display: flex; align-items: center; gap: 6px; }
.rp-act { display: flex; gap: 10px; padding: 6px 0; font-size: var(--fs-caption); color: var(--text-sub); }
.rp-act-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex-shrink: 0; }
.rp-act-main strong { color: var(--text-main); }
.rp-act-time { font-size: 10px; color: var(--text-weak); margin-top: 2px; }

/* ---- 空 / 加载态 ---- */
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--text-sub); text-align: center; padding: 24px; }
.empty-state .es-icon { font-size: 48px; }
.empty-state h3 { font-size: var(--fs-h4); color: var(--text-main); }
.empty-state p { font-size: var(--fs-caption); max-width: 320px; }
.list-loading { padding: 20px; text-align: center; color: var(--text-weak); font-size: var(--fs-caption); }

/* ---- 新建项目弹窗：Agents 多选区 ---- */
.np-agent-list { display: flex; flex-direction: column; gap: 8px; }
.np-agent-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--r-sm); cursor: pointer;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.np-agent-item:hover { border-color: var(--primary); background: var(--primary-ghost); }
.np-agent-item input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); flex-shrink: 0; }
.np-agent-name { font-size: var(--fs-body); font-weight: var(--fw-medium); color: var(--text-main); }
.np-agent-desc { font-size: var(--fs-xs); color: var(--text-weak); margin-left: auto; }

/* ---- M2: 工具执行块 ---- */
.tool-block {
  font-family: var(--font-mono); font-size: 12px;
  background: #14152a; border: 1px solid var(--border);
  border-radius: var(--r-sm); margin: 8px 0; overflow: hidden;
}
.tool-block-head {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; background: var(--card); border-bottom: 1px solid var(--border);
}
.tool-block-icon { color: var(--info); font-weight: bold; }
.tool-block-name { color: var(--text-main); font-weight: var(--fw-medium); }
.tool-block-status { margin-left: auto; font-size: 10px; color: var(--text-weak); }
.tool-block.loading .tool-block-status { animation: blink 1s step-end infinite; }
.tool-block-args {
  padding: 8px 10px; color: var(--text-sub); white-space: pre-wrap;
  word-break: break-all; font-size: 11.5px; line-height: 1.5; margin: 0;
}
.tool-block-body { padding: 0 10px 8px; }
.tool-block-body details summary { cursor: pointer; font-size: 10px; color: var(--text-weak); margin-bottom: 4px; }
.tool-block-body pre {
  margin: 0; padding: 8px; background: #0d0e1f; border-radius: var(--r-xs);
  max-height: 200px; overflow-y: auto; font-size: 11px; line-height: 1.5;
  color: #c8c8e0; white-space: pre-wrap; word-break: break-word;
}
.stream-tools-final { margin-top: 8px; }

/* ---- M2: Agents 多选 chip ---- */
.agents-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.agent-chip {
  padding: 5px 14px; border-radius: var(--r-pill);
  border: 1px solid var(--border); font-size: 12px;
  color: var(--text-sub); cursor: pointer; transition: all var(--dur-fast);
  user-select: none;
}
.agent-chip:hover { border-color: var(--info); color: var(--text-main); }
.agent-chip.selected {
  background: rgba(0,184,148,.15); border-color: var(--success); color: var(--success);
  font-weight: var(--fw-medium);
}
