/* AgentHub demo — giao diện riêng từng màn. */

/* ---------- Tổng quan ---------- */
.hero {
  display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 22px 24px; margin-bottom: 16px;
  border-radius: var(--radius); border: 1px solid var(--line); background: linear-gradient(120deg, var(--accent-soft), var(--surface) 70%);
}
.hero h2 { font-size: 19px; max-width: 560px; margin: 2px 0 14px; }
.hero-flow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 420px; }
.hero-flow span { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; }
.hero-flow i { color: var(--accent); font-style: normal; }
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.agent-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.agent-card:hover { border-color: var(--accent); }
.agent-card p { margin: 0; color: var(--ink-2); }
.card-side { position: sticky; top: calc(var(--bar-h) + 16px); }

/* ---------- Đội agent ---------- */
.agent-table { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.agent-row {
  display: grid; grid-template-columns: 240px minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.agent-row:hover { border-color: var(--accent); }
.agent-row p { margin: 0; color: var(--ink-2); }

/* ---------- Giao việc ---------- */
.view:has(.chat-layout) { max-width: none; padding: 0; }
.chat-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr) 290px; height: calc(100vh - var(--bar-h)); }
.channels { border-right: 1px solid var(--line); background: var(--surface); overflow-y: auto; padding: 12px 8px; }
.channels-group { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 12px 8px 6px; }
.channel { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 9px; }
.channel:hover { background: var(--surface-2); }
.channel.is-active { background: var(--accent-soft); }
.channel-icon { width: 30px; height: 30px; border-radius: 8px; background: var(--gray-bg); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.channel-text { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.channel-text strong { font-size: 13px; }
.channel-text small { color: var(--muted); font-size: 12px; }
.thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.thread-head { padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.thread-head div { display: flex; flex-direction: column; }
.feed { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.day-divider { text-align: center; position: relative; margin: 4px 0; }
.day-divider span { background: var(--bg); padding: 0 10px; font-size: 12px; color: var(--muted); position: relative; z-index: 1; }
.day-divider::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--line); }
.msg { display: flex; gap: 10px; align-items: flex-start; max-width: 820px; }
.msg-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.msg-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.msg-head strong { font-size: 13px; }
.bubble { background: var(--surface); border: 1px solid var(--line); border-radius: 4px 12px 12px 12px; padding: 9px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-agent .bubble { background: var(--surface-2); }
.msg-mine .bubble { background: var(--accent-soft); border-color: transparent; }
.typing { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: 0.2s; } .dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }
.composer { border-top: 1px solid var(--line); background: var(--surface); padding: 10px 14px 14px; }
.samples { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.composer-box { border: 1px solid var(--line-strong); border-radius: 12px; padding: 8px 10px; background: var(--surface); }
.composer-box:focus-within { border-color: var(--accent); }
.composer-box textarea { width: 100%; border: 0; outline: 0; resize: none; background: transparent; min-height: 44px; }
.composer-actions { display: flex; justify-content: space-between; align-items: center; }
.run-panel { border-left: 1px solid var(--line); background: var(--surface); padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.run-panel h2 { font-size: 14px; }
.run-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.run-steps { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; }
.run-steps li { display: flex; align-items: center; gap: 7px; }
.run-steps code { margin-left: auto; color: var(--muted); }
.step-dot { --av: #999; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--av); flex-shrink: 0; }
.step-done .step-dot { background: var(--av); }
.step-now .step-dot { animation: pulse 1.6s infinite; }
.step-now { font-weight: 600; }
.step-todo, .step-skip { color: var(--muted); }
.step-skip span { text-decoration: line-through; }

/* ---------- Thẻ duyệt ---------- */
.approval { border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); padding: 14px; display: flex; flex-direction: column; gap: 10px; max-width: 640px; }
.approval-pending { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); box-shadow: 0 0 0 3px var(--warn-bg); }
.approval-head { display: flex; align-items: center; gap: 10px; }
.approval-head .eyebrow { margin: 0; }
.approval-icon { width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); display: grid; place-items: center; }
.approval-title { font-size: 15px; }
.stages { display: flex; gap: 6px; flex-wrap: wrap; }
.stage { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--gray-bg); color: var(--muted); }
.stage.is-on { background: var(--accent); color: var(--accent-ink); }
.stage.is-bad { background: var(--bad-bg); color: var(--bad); }
.approval-content { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.approval-compact .approval-content pre { max-height: 130px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.approval-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 10px; }
.approval-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; }
.approval-list > div { display: flex; flex-direction: column; gap: 6px; }

/* ---------- Kết nối ---------- */
.conn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; margin-bottom: 16px; }
.conn-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.conn-card.is-off { opacity: 0.7; }
.conn-url { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; }
.switch-row, .key-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.switch-row span, .key-row span { display: flex; flex-direction: column; }
.switch { width: 38px; height: 22px; accent-color: var(--accent); cursor: pointer; }

/* ---------- Nhân viên ---------- */
.matrix td:not(:first-child), .matrix th:not(:first-child) { text-align: center; }
.yes { color: var(--good); font-weight: 700; }
.no { color: var(--muted); }

/* ---------- Thống kê ---------- */
.bars { display: flex; align-items: flex-end; gap: 2px; padding-top: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; cursor: default; }
.bar-track { width: 100%; display: flex; align-items: flex-end; justify-content: center; border-bottom: 1px solid var(--line-strong); }
.bar { width: min(70%, 26px); background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-col:hover .bar { background: var(--accent-2); }
.bar-label { font-size: 11px; color: var(--muted); height: 14px; white-space: nowrap; }
.hbar { display: grid; grid-template-columns: 130px minmax(0, 1fr) 48px; gap: 10px; align-items: center; }
.hbar-label { font-size: 13px; }
.hbar-track { height: 10px; background: var(--gray-bg); border-radius: 4px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.hbar-value { font-size: 13px; }

/* ---------- Màn hình nhỏ ---------- */
@media (max-width: 1200px) {
  .chat-layout { grid-template-columns: 220px minmax(0, 1fr); }
  .run-panel { display: none; }
  .agent-row { grid-template-columns: 220px minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .chat-layout { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .channels { display: flex; gap: 6px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .channels-group, .channel-text small, .channel-icon { display: none; }
  .channel { white-space: nowrap; padding: 6px 10px; border: 1px solid var(--line); }
  .hero { flex-direction: column; align-items: flex-start; }
  .hero-flow { justify-content: flex-start; }
  .agent-row { grid-template-columns: 1fr; }
  .approval-list { grid-template-columns: 1fr; }
  .hbar { grid-template-columns: 96px minmax(0, 1fr) 40px; }
  .samples { flex-wrap: nowrap; overflow-x: auto; }
  .samples .chip { white-space: nowrap; }
  #toast-root { bottom: 110px; }
}

/* ---------- Bảng việc đội bot (thẻ thật từ /api/tasks) ---------- */
.board { display: grid; grid-template-columns: repeat(7, minmax(160px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 8px; }
.board-col { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 160px; }
.board-col-head { font-size: 13px; margin: 0 0 2px; display: flex; justify-content: space-between; }
.board-card { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; font: inherit; color: inherit; }
.board-card:hover, .board-card.is-active { border-color: var(--accent); }
.board-card-title { font-weight: 600; font-size: 13px; }
.board-card-foot { display: flex; justify-content: space-between; gap: 6px; font-size: 11px; color: var(--muted); }
.board-empty { margin: 0; }
.board-error { color: var(--bad); background: var(--bad-bg); border-radius: 8px; padding: 8px 12px; }
.board-events { margin: 8px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
@media (max-width: 720px) { .board { grid-template-columns: repeat(7, 78vw); } }
.board-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.board-stats > div { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.board-stats strong { font-size: 18px; }
.board-stats span { font-size: 12px; color: var(--muted); }
.board-beats { grid-column: 1 / -1; flex-direction: row !important; flex-wrap: wrap; gap: 10px !important; align-items: center; }
.board-form { max-width: 380px; }
.board-form-inline { margin-top: 12px; }
.board-form-inline .input { width: auto; flex: 1 1 160px; }
.board-notice { color: var(--good); background: var(--good-bg); border-radius: 8px; padding: 8px 12px; }
.board-newkey { display: flex; flex-direction: column; gap: 6px; background: var(--warn-bg); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.board-newkey code { word-break: break-all; user-select: all; }
.board-decide { margin: 8px 0; }
details.card > summary { cursor: pointer; font-weight: 600; }
.board-steps { margin: 0; padding-left: 4px; list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 6px; }
.board-steps li { color: var(--muted); }
.board-steps li.is-done { color: var(--good); font-weight: 600; }
.board-roster { width: 100%; font-family: ui-monospace, monospace; font-size: 12px; margin: 8px 0; }

/* Kho tri thức: chọn nhiều tài liệu */
.kb-check { width: 32px; }
.kb-check input { width: 16px; height: 16px; cursor: pointer; }
.table tr.is-selected td { background: var(--accent-soft, rgba(37, 99, 235, 0.08)); }
.kb-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 10px; margin-bottom: 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface-2, var(--surface)); }
.kb-bulk select { padding: 4px 6px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: inherit; }
.kb-danger { color: #b42318; border-color: #f3b4ae; }
.kb-danger:hover { background: #fef3f2; }

/* Hướng dẫn sử dụng */
.guide-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; align-items: start; }
.guide-toc { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 32px); overflow-y: auto; }
.guide-toc-item { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 5px 8px; border-radius: 6px; cursor: pointer; color: var(--ink-2); font-size: 13.5px; }
.guide-toc-item:hover { background: var(--accent-soft); color: var(--accent); }
.guide-body { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.guide-part { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 10px 0 0; }
.guide-section { scroll-margin-top: 60px; }
.guide-section p { margin: 0 0 8px; line-height: 1.55; }
.guide-sub { font-size: 13px; margin: 12px 0 6px; color: var(--muted); font-weight: 600; }
.guide-steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; line-height: 1.55; }
.guide-table th { white-space: normal; width: 34%; color: var(--ink); font-size: 13.5px; vertical-align: top; }
.guide-table td { vertical-align: top; line-height: 1.5; }
.guide-tips { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border-left: 3px solid var(--accent); font-size: 13.5px; }
.guide-tips ul { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; line-height: 1.5; }
@media (max-width: 900px) {
  .guide-layout { grid-template-columns: 1fr; }
  .guide-toc { position: static; max-height: none; }
}
.kho-body { white-space: pre-wrap; word-break: break-word; font: inherit; margin: 0; max-height: 60vh; overflow: auto; }
