/* 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; }
}
