/* AI 助手对话页（agent- 前缀）。复用 styles.css 全局类；此处仅补布局与消息气泡。
   v0.98：三区简约排版（左会话/审批 · 中对话流 · 通知折叠条）。 */

.agent-wrap { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: stretch; }

/* 左侧会话列表 */
.agent-side {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 74vh;
}
.agent-side-head {
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted, #6b7280);
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.agent-sessions { overflow-y: auto; flex: 1 1 auto; }
.agent-side-empty { padding: 16px 12px; font-size: 12px; color: var(--text-muted, #6b7280); }
.agent-side-sec { display: flex; flex-direction: column; max-height: 40%; min-height: 0; }
.agent-pending-list { overflow-y: auto; }
.agent-sess { padding: 10px 12px; border-bottom: 1px solid var(--border, #f1f3f5); cursor: pointer; }
.agent-sess:hover { background: var(--hover, #f8fafc); }
.agent-sess.active { background: var(--active, #eef4ff); border-left: 3px solid var(--primary, #2563eb); }
.agent-sess-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-sess-meta { font-size: 11px; color: var(--text-muted, #6b7280); margin-top: 2px; }

/* 右侧对话区 */
.agent-main {
  display: flex;
  flex-direction: column;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 12px;
  min-height: 60vh;
  max-height: 74vh;
}
.agent-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border, #f1f3f5);
}
.agent-meta { font-size: 12px; color: var(--text-muted, #6b7280); }
.agent-tools-det summary, .agent-steps summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted, #6b7280);
  user-select: none;
}
.agent-tools-badge {
  font-weight: 600;
  color: var(--text, #111827);
  font-size: 12px;
  white-space: nowrap;
}
.agent-tools-list { max-height: 180px; overflow-y: auto; margin-top: 6px; }
.agent-tool {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px dashed var(--border, #f1f3f5);
  font-size: 12px;
}
.agent-tool-name { font-weight: 600; font-family: var(--mono, ui-monospace, monospace); }
.agent-tool-desc { color: var(--text-muted, #6b7280); flex: 1 1 100%; }

/* 消息流 */
.agent-msgs {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px 2px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.agent-empty { color: var(--text-muted, #6b7280); font-size: 13px; text-align: center; margin-top: 24px; }
.agent-empty-ico { font-size: 34px; margin-bottom: 6px; }
.agent-empty-t { font-size: 15px; font-weight: 700; color: var(--text, #111827); margin-bottom: 6px; }
.agent-empty-d { font-size: 12px; line-height: 1.7; margin-bottom: 10px; }
.agent-empty-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 520px; margin: 0 auto; }
.agent-msg { display: flex; flex-direction: column; max-width: 82%; }
.agent-msg-user { align-self: flex-end; align-items: flex-end; }
.agent-msg-assistant, .agent-msg-system { align-self: flex-start; }
.agent-role { font-size: 11px; color: var(--text-muted, #6b7280); margin-bottom: 3px; }
.agent-bubble {
  background: var(--bubble, #f4f6f8);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.agent-msg-user .agent-bubble { background: var(--primary, #2563eb); color: #fff; }
.agent-pre {
  margin: 0;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow: auto;
}

/* 工具返回行内折叠条（v0.98：替代整屏 JSON 气泡） */
.agent-toolrow {
  align-self: flex-start;
  max-width: 92%;
  width: 100%;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  background: var(--bg-soft, #fafafa);
  overflow: hidden;
}
.agent-toolrow > summary {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; cursor: pointer; user-select: none;
  font-size: 12px; color: var(--text-muted, #6b7280);
  list-style: none;
}
.agent-toolrow > summary::-webkit-details-marker { display: none; }
.agent-toolrow > summary:hover { background: var(--hover, #f3f4f6); }
.agent-toolrow-ico { flex: 0 0 auto; }
.agent-toolrow-name { font-weight: 600; font-family: var(--mono, ui-monospace, monospace); color: var(--text, #111827); }
.agent-toolrow-hint { font-size: 11px; }
.agent-toolrow.bad { border-color: var(--danger-border, #fecaca); background: var(--danger-bg, #fef2f2); }
.agent-toolrow.bad .agent-toolrow-hint { color: var(--danger-text, #b91c1c); }
.agent-toolrow .agent-pre { padding: 8px 10px; border-top: 1px solid var(--border, #e5e7eb); max-height: 200px; }

/* 待审批卡片（v0.95 升级：图标 + 工具徽标 + 键值参数摘要） */
.agent-pending {
  margin: 8px 0;
  border: 1px solid var(--warn-border, #f0c36d);
  background: var(--warn-bg, #fffbe6);
  border-radius: 10px;
  padding: 10px 12px;
}
.agent-pending.is-v2 { box-shadow: 0 1px 4px rgba(240, 195, 109, 0.25); }
.agent-pending-head { font-size: 13px; font-weight: 600; color: var(--warn-text, #8a6d3b);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.agent-pending-icon { font-size: 15px; }
.agent-pending-tool { background: var(--warn-bg, #fff3cd); border: 1px solid var(--warn-border, #f0c36d);
  border-radius: 999px; padding: 1px 9px; font-size: 11px; font-weight: 500; }
.agent-pending-reason { font-size: 12px; color: var(--warn-text, #8a6d3b); margin: 5px 0; }
.agent-pending-args { margin: 6px 0; display: flex; flex-direction: column; gap: 3px; }
.agent-pending-kv { display: flex; gap: 8px; font-size: 11px; align-items: baseline; }
.agent-pending-k { color: var(--text-muted, #6b7280); min-width: 90px; flex-shrink: 0; }
.agent-pending-v { font-family: var(--mono, ui-monospace, monospace); word-break: break-all; }
.agent-pending-actions { display: flex; gap: 8px; margin-top: 8px; }

/* 运行步骤（v0.95 升级：状态图标） */
.agent-steps { margin: 8px 0; }
.agent-step-list { margin-top: 6px; display: flex; flex-direction: column; gap: 3px; }
.agent-step { display: flex; gap: 8px; align-items: baseline; font-size: 11px; }
.agent-step.ok .agent-step-t { color: var(--success, #16a34a); }
.agent-step.bad .agent-step-t { color: var(--danger, #dc2626); }
.agent-step-ico { font-weight: 700; }
.agent-step.ok .agent-step-ico { color: var(--success, #16a34a); }
.agent-step.bad .agent-step-ico { color: var(--danger, #dc2626); }
.agent-step-tool { font-family: var(--mono, ui-monospace, monospace); }
.agent-step-e { color: var(--danger, #dc2626); }
.agent-step-d { color: var(--text-muted, #6b7280); margin-left: auto; }

/* 输入区 */
.agent-input { border-top: 1px solid var(--border, #e5e7eb); padding-top: 10px; }
.agent-text {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
}
.agent-input-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; }
.agent-auto { font-size: 12px; color: var(--text-muted, #6b7280); }
.agent-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.agent-q {
  border: 1px dashed var(--border, #d1d5db);
  background: transparent;
  border-radius: 14px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--text-muted, #6b7280);
  cursor: pointer;
}
.agent-q:hover { border-color: var(--primary, #2563eb); color: var(--primary, #2563eb); }

/* ---------- LLM 服务商徽标（Qwen2.5-7B 本地/在线 / 离线） ---------- */
.agent-llm { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.agent-llm-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border, #e5e7eb);
  white-space: nowrap;
}
.agent-llm-badge.is-on {
  border-color: var(--success-border, #86efac);
  background: var(--success-bg, #f0fdf4);
  color: var(--success-text, #15803d);
}
.agent-llm-badge.is-off {
  border-color: var(--border, #e5e7eb);
  background: var(--bg-soft, #f9fafb);
  color: var(--text-muted, #6b7280);
}
.agent-llm-badge.is-loading {
  border-color: var(--border, #e5e7eb);
  color: var(--text-muted, #6b7280);
}

/* ---------- 待审批队列（侧栏） ---------- */
.agent-side-head-sub {
  margin-top: 10px;
  border-top: 1px solid var(--border, #e5e7eb);
  padding-top: 10px;
}
.agent-pending-list { display: flex; flex-direction: column; gap: 6px; }
.agent-pend-item {
  border: 1px solid var(--warning-border, #fcd34d);
  background: var(--warning-bg, #fffbeb);
  border-radius: 8px;
  padding: 7px 9px;
}
.agent-pend-tool { font-size: 12px; font-weight: 600; color: var(--text, #111827); }
.agent-pend-task { font-size: 12px; color: var(--text, #374151); margin-top: 2px; }
.agent-pend-reason {
  font-size: 11px;
  color: var(--warning-text, #92400e);
  margin-top: 2px;
}
.agent-pend-meta {
  font-size: 11px;
  color: var(--text-muted, #6b7280);
  margin-top: 2px;
}
.agent-pend-actions { margin-top: 6px; display: flex; gap: 6px; }

@media (max-width: 860px) {
  .agent-wrap { grid-template-columns: 1fr; }
  .agent-side { max-height: 30vh; }
  .agent-main { max-height: none; }
}

/* ============ v63 N1：跨模块通知面板 ============
   v0.98：收纳为 agent-main 内的折叠条（默认收起）——summary 一行 =
   标题 + 未读红点 + 严重度徽标 + 展开提示；展开后为分组明细列表。 */
.agent-nt { margin: 8px 0 0; border-radius: 10px; flex: 0 0 auto; }
.agent-nt > .agent-nt-summary {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; cursor: pointer; user-select: none; list-style: none;
}
.agent-nt > .agent-nt-summary::-webkit-details-marker { display: none; }
.agent-nt > .agent-nt-summary strong { font-size: 13px; margin-right: auto; }
.agent-nt-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.agent-nt-toggle { font-size: 11px; white-space: nowrap; }
.agent-nt-dot {
  width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto;
  background: var(--danger, #dc2626);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}
.agent-nt[open] .agent-nt-dot { display: none; }
.agent-nt .card-body { border-top: 1px solid var(--border, #f1f3f5); max-height: 320px; overflow-y: auto; }
.agent-nt-sev { margin-bottom: 14px; }
.agent-nt-sev-t {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 700; margin-bottom: 8px; letter-spacing: .01em;
}
.agent-nt-sev-t::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.agent-nt-urgent .agent-nt-sev-t { color: var(--danger-text, #b91c1c); }
.agent-nt-warn .agent-nt-sev-t { color: var(--warning-text, #92400e); }
.agent-nt-info .agent-nt-sev-t { color: var(--text-muted, #6b7280); }
.agent-nt-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px 9px 16px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--border, #e5e7eb); margin-bottom: 7px;
  background: var(--bg, #fff);
  transition: box-shadow .15s ease, transform .15s ease, opacity .15s ease;
}
.agent-nt-item::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  border-radius: 9px 0 0 9px; background: var(--border, #e5e7eb);
}
.agent-nt-item:hover {
  background: var(--bg-soft, #f3f4f6);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
  transform: translateY(-1px);
}
.agent-nt-urgent .agent-nt-item::before { background: var(--danger, #dc2626); }
.agent-nt-warn .agent-nt-item::before { background: var(--warning, #f59e0b); }
.agent-nt-info .agent-nt-item::before { background: var(--muted-2, #9ca3af); }
.agent-nt-item.is-read { opacity: 0.55; }
.agent-nt-item.is-read::before { background: var(--border, #e5e7eb); }
.agent-nt-item.is-read .agent-nt-title { text-decoration: line-through; text-decoration-color: var(--muted, #9ca3af); }
.agent-nt-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.agent-nt-line1 { display: flex; align-items: center; gap: 8px; min-width: 0; }
.agent-nt-title {
  font-size: 13px; font-weight: 600; flex: 1; min-width: 200px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.agent-nt-meta { white-space: nowrap; }
.agent-nt-item.is-read .agent-nt-title::after { content: " ✓"; color: var(--text-muted, #6b7280); font-size: 11px; text-decoration: none; }
.agent-nt-ico { flex: 0 0 auto; font-size: 15px; line-height: 1; }
.agent-nt-go { flex: 0 0 auto; font-size: 16px; font-weight: 700; opacity: .5; }
.agent-nt-item:hover .agent-nt-go { opacity: 1; }

/* ---------- 受控学习：引用、降级、反馈与本人记忆 ---------- */
.agent-citations { margin-top: 6px; font-size: 11px; color: var(--text-muted, #6b7280); }
.agent-citations > summary { cursor: pointer; user-select: none; }
.agent-citation-list { display: flex; flex-direction: column; gap: 5px; margin-top: 6px; }
.agent-citation { padding: 6px 8px; border: 1px solid var(--border, #e5e7eb); border-radius: 7px; background: var(--bg-soft, #fafafa); }
.agent-citation strong { display: block; color: var(--text, #111827); margin-bottom: 2px; }
.agent-citation span { display: block; white-space: pre-wrap; word-break: break-word; }
.agent-msg-warning { margin-top: 6px; padding: 6px 8px; border-radius: 7px; background: var(--warning-bg, #fffbeb); color: var(--warning-text, #92400e); font-size: 11px; line-height: 1.5; }
.agent-learning-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 4px; }
.agent-learning-actions .btn + .btn { margin-left: 0; }
.agent-learning-actions .btn.is-active { color: var(--primary, #2563eb); background: var(--active, #eef4ff); }
.agent-candidate-state { font-size: 11px; color: var(--text-muted, #6b7280); }
.agent-memory-modal { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); max-width: 100%; height: 100vh; height: 100dvh; max-height: none; border-radius: 12px 0 0 12px; }
.agent-memory-notice { margin-bottom: 12px; line-height: 1.6; }
.agent-memory-list { display: flex; flex-direction: column; gap: 8px; max-height: 45vh; overflow-y: auto; margin-bottom: 14px; }
.agent-memory-item { padding: 10px; border: 1px solid var(--border, #e5e7eb); border-radius: 8px; background: var(--bg-soft, #fafafa); }
.agent-memory-item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.agent-memory-item-head .btn { margin-left: auto; }
.agent-memory-content { font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.agent-memory-empty { padding: 18px 10px; text-align: center; color: var(--text-muted, #6b7280); font-size: 12px; }
.agent-memory-editor { border-top: 1px solid var(--border, #e5e7eb); padding-top: 12px; }

@media (max-width: 640px) {
  .agent-msg { max-width: 94%; }
  .agent-memory-modal { border-radius: 0; }
}
