/* Document agent panel (public/js/agent.js). Loaded after app.css. */
.agent-launch {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 11px;
  border: 1px solid #dcdcdc; border-radius: 14px; background: #fff;
  color: #3a3a3a; font: inherit; font-size: 12px; font-weight: 600; letter-spacing: .1px;
  cursor: pointer; flex: none;
}
.agent-launch:hover { background: #f2f2f2; border-color: #c9c9c9; }
.agent-launch.active { background: var(--app); color: #fff; border-color: var(--app); }
.agent-launch svg { width: 14px; height: 14px; }
.agent-launch:focus-visible { outline: 2px solid var(--app); outline-offset: 2px; }

#editor-view.agent-open .editor-scroll { margin-right: 380px; }
.agent-panel {
  position: fixed; top: 142px; right: 0; bottom: 28px; width: 380px; max-width: 100vw;
  display: flex; flex-direction: column; z-index: 70;
  background: #fafafa; border-left: 1px solid var(--line);
  box-shadow: -8px 0 24px rgba(0, 0, 0, .08);
  font-size: 13px; color: var(--ink);
}
.agent-head {
  flex: none; display: flex; align-items: center; gap: 7px; height: 40px; padding: 0 10px;
  background: var(--app); color: #fff;
}
.agent-spark { color: #ffd76a; font-size: 14px; line-height: 1; }
.agent-title { font-weight: 600; font-size: 13px; }
.agent-model {
  margin-left: 2px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 11px; color: #d7e4f8; opacity: .9;
}
.agent-icon-btn {
  width: 24px; height: 24px; border: 0; border-radius: 3px;
  background: transparent; color: #fff; font-size: 16px; line-height: 1; cursor: pointer;
}
.agent-head .agent-icon-btn:first-of-type { margin-left: auto; }
.agent-icon-btn + .agent-icon-btn { margin-left: 2px; }
.agent-icon-btn:hover { background: rgba(255,255,255,.2); }

.agent-status { flex: none; min-height: 0; padding: 0 12px; font-size: 11px; color: #5b6b82; }
.agent-status:not(:empty) { padding: 6px 12px; background: #eef3fb; border-bottom: 1px solid #e0e7f2; }
.agent-status.error { color: #a5291f; background: #fdf0ee; }

.agent-msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.agent-msgs::-webkit-scrollbar { width: 8px; }
.agent-msgs::-webkit-scrollbar-thumb { background: #c9d2df; border-radius: 4px; }

.agent-msg { display: flex; flex-direction: column; gap: 3px; max-width: 100%; }
.agent-who { font-size: 11px; color: #7a889c; }
.agent-bubble {
  padding: 8px 11px; border-radius: 8px; background: #fff; border: 1px solid #e5e5e5;
  line-height: 1.65; word-break: break-word; overflow-wrap: anywhere;
}
.agent-msg.user .agent-bubble { background: var(--app-weak); border-color: var(--app-weak-2); }
.agent-msg.user { align-items: flex-end; }
.agent-msg.user .agent-who { align-self: flex-end; }

.agent-p { margin: 0 0 6px; }
.agent-p:last-child { margin-bottom: 0; }
.agent-h { font-weight: 600; margin: 8px 0 4px; }
.agent-h1 { font-size: 15px; }
.agent-h2 { font-size: 14px; }
.agent-h3 { font-size: 13px; }
.agent-list { margin: 2px 0 6px; padding-left: 20px; }
.agent-list li { margin: 1px 0; }
.agent-h4 { font-size: 13px; }
.agent-h5, .agent-h6 { font-size: 12px; color: #4a4a4a; }
.agent-table-wrap { margin: 6px 0 8px; overflow-x: auto; border: 1px solid #e5e5e5; border-radius: 6px; }
.agent-table { border-collapse: collapse; width: 100%; font-size: 12px; }
.agent-table th, .agent-table td { padding: 6px 9px; border-right: 1px solid #f0f0f0; border-bottom: 1px solid #efefef; text-align: left; vertical-align: top; }
.agent-table th { background: #fafafa; font-weight: 600; color: #333; white-space: nowrap; }
.agent-table tr:last-child td { border-bottom: 0; }
.agent-table th:last-child, .agent-table td:last-child { border-right: 0; }
.agent-link { color: var(--app); text-decoration: underline; text-underline-offset: 2px; }
.agent-link:hover { color: var(--app-dark); }
.agent-code { background: #eef1f6; border-radius: 3px; padding: 0 3px; font-family: Consolas, "Courier New", monospace; font-size: 12px; }
.agent-pre { background: #f4f6fa; border: 1px solid #e2e7ef; border-radius: 4px; padding: 8px; overflow-x: auto; margin: 6px 0; }
.agent-pre code { font-family: Consolas, "Courier New", monospace; font-size: 12px; white-space: pre; }
.agent-quote { border-left: 3px solid #c9d6ea; padding-left: 8px; color: #55647a; margin: 4px 0; }
.agent-hr { border: 0; border-top: 1px solid #e2e7ef; margin: 8px 0; }
.agent-muted { color: #7a889c; }
.agent-caret { display: inline-block; width: 6px; height: 14px; margin-left: 2px; background: var(--app); vertical-align: -2px; animation: agent-blink 1s steps(2) infinite; }
@keyframes agent-blink { 50% { opacity: 0; } }

.agent-tool { border: 1px solid #e5e5e5; border-radius: 6px; background: #fafafa; font-size: 12px; overflow: hidden; }
.agent-tool.failed { border-color: #efc9c4; background: #fdf5f4; }
.agent-tool-head { display: flex; align-items: center; gap: 6px; padding: 6px 8px; cursor: default; }
.agent-tool.running .agent-tool-head { cursor: progress; }
.agent-tool-ic { width: 16px; height: 16px; border-radius: 50%; background: #dbe7fa; color: #2b579a; display: flex; align-items: center; justify-content: center; font-size: 11px; flex: none; }
.agent-tool.failed .agent-tool-ic { background: #f6d7d3; color: #a5291f; }
.agent-tool-label { color: #33455e; }
.agent-tool-args { color: #7a889c; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.agent-tool-meta { margin-left: auto; color: #8b97a8; font-size: 11px; flex: none; }
.agent-tool-preview { padding: 6px 8px 7px; color: #5b6b82; white-space: pre-wrap; word-break: break-word; border-top: 1px dashed #e3e8f0; }

.agent-notice { padding: 7px 9px; border-radius: 5px; background: #eef3fb; color: #33455e; font-size: 12px; }
.agent-notice.error { background: #fdf0ee; color: #a5291f; }

.agent-empty { margin: auto 0; padding: 18px 6px; text-align: center; color: #5d6c82; }
.agent-empty-mark {
  width: 42px; height: 42px; margin: 0 auto 10px; border-radius: 50%;
  background: linear-gradient(135deg, #2b579a, #4a7fd0); color: #fff; font-weight: 700; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
}
.agent-empty-title { margin: 0 0 6px; font-weight: 600; color: #243248; }
.agent-empty-text { margin: 0 0 8px; font-size: 12px; line-height: 1.6; }

.agent-suggest { flex: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 8px; }
.agent-chip {
  border: 1px solid #dcdcdc; background: #fff; color: #3a3a3a; border-radius: 14px;
  padding: 4px 10px; font: inherit; font-size: 11px; cursor: pointer;
}
.agent-chip:hover { background: var(--app-weak); border-color: var(--app-weak-2); color: var(--app); }

.agent-compose { flex: none; border-top: 1px solid #e0e6ef; padding: 8px 10px 9px; background: #fff; }
.agent-input {
  width: 100%; resize: none; border: 1px solid #d7d7d7; border-radius: 6px; padding: 7px 9px;
  font: inherit; font-size: 13px; line-height: 1.5; color: var(--ink); background: #fff; min-height: 44px;
}
.agent-input:focus { outline: 2px solid var(--app-weak-2); outline-offset: -1px; border-color: var(--app); }
.agent-compose-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.agent-hint { color: #8b97a8; font-size: 11px; margin-right: auto; }
.agent-compose-row .btn.small { padding: 6px 12px; }
.agent-compose-row .btn:disabled { opacity: .5; cursor: default; }

@media (max-width: 900px) {
  #editor-view.agent-open .editor-scroll { margin-right: 0; }
  .agent-panel { width: 100%; box-shadow: none; }
}
@media (max-width: 760px) {
  .agent-launch { padding: 0 7px; border-radius: 4px; }
  .agent-launch-text { display: none; }
}
@media print {
  .agent-panel, .agent-launch { display: none !important; }
  #editor-view.agent-open .editor-scroll { margin-right: 0; }
}
