/* ========================================================
 * Structural layout. Colors/glass/neon/borders live in
 * theme-cyberglass.css. Copied 1:1 from the vanilla index.html
 * inline <style> so the existing theme matches component output.
 * ======================================================== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #root { height: 100%; }
body { display: flex; flex-direction: column; }
#root { display: flex; flex-direction: column; min-height: 100%; }

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  min-height: 48px;
}
#topbar .logo { font-weight: 600; }
#topbar nav { display: flex; gap: 0.3rem; }
#topbar .right { display: flex; align-items: center; gap: 0.5rem; }

#main { flex: 1; overflow: hidden; display: flex; position: relative; }

/* --- Moderation Tab --- */
#moderation { flex: 1; display: flex; overflow: hidden; }
#queue-list { width: 40%; min-width: 280px; overflow-y: auto; display: flex; flex-direction: column; }
#queue-list .filter-bar { position: sticky; top: 0; padding: 0.5rem; display: flex; gap: 0.5rem; z-index: 2; flex-wrap: wrap; }
#queue-list .filter-bar input { flex: 1; min-width: 0; }
#queue-list #queue-items { flex: 1; }
#queue-list .item { padding: 0.75rem 1rem; cursor: pointer; display: flex; gap: 0.5rem; align-items: flex-start; }
#queue-list .item .chk { margin-top: 0.15rem; }
#queue-list .item .body { flex: 1; min-width: 0; }
#queue-list .item .headline { display: flex; justify-content: space-between; gap: 0.5rem; align-items: baseline; }
#queue-list .item .agent { font-size: 11px; padding: 1px 6px; border-radius: 3px; }
#queue-list .item .score { font-size: 11px; }
#queue-list .item .summary { margin-top: 0.25rem; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#queue-list .item .kind { margin-top: 0.2rem; font-size: 11px; }
#queue-list .empty { padding: 3rem 1rem; text-align: center; }
#queue-list .empty .crab { font-size: 48px; display: block; margin-bottom: 1rem; }

#bulk-bar { display: none; position: sticky; bottom: 0; padding: 0.5rem; gap: 0.5rem; align-items: center; }
#bulk-bar.visible { display: flex; }
#bulk-bar .count { font-size: 12px; flex: 1; }

#detail { flex: 1; overflow-y: auto; padding: 1.5rem 2rem; }
#detail .empty { text-align: center; padding: 4rem 2rem; }
#detail .header { display: flex; gap: 0.75rem; align-items: baseline; margin-bottom: 0.5rem; flex-wrap: wrap; }
#detail .header .agent-badge { padding: 2px 8px; border-radius: 4px; font-size: 11px; }
#detail .header .score { margin-left: auto; font-size: 13px; }
#detail h1.summary { margin-bottom: 1rem; line-height: 1.4; }
#detail .payload { padding: 1rem; margin-bottom: 1rem; }
#detail .payload-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
#detail .payload-row .k { min-width: 120px; }
#detail .payload-row .v { flex: 1; word-break: break-word; }
#detail .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
#detail .audit { margin-top: 1.5rem; padding-top: 1rem; }
#detail .audit h3 { margin-bottom: 0.5rem; }
#detail .audit .row { display: flex; gap: 0.75rem; padding: 0.25rem 0; }
#detail .audit .row .t { min-width: 160px; }

/* --- Tasks Rows --- */
.tasks-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; padding: 0.5rem 0.25rem; border-bottom: 1px solid rgba(0,0,0,0.05); }
.tasks-row .col-agent { width: 160px; }
.tasks-row .col-kind  { width: 180px; }
.tasks-row .col-summary { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.tasks-row .col-time { width: 140px; text-align: right; }
.confidence-bar { display: inline-block; width: 80px; height: 4px; overflow: hidden; vertical-align: middle; background: rgba(0,0,0,0.08); border-radius: 2px; }
.confidence-fill { height: 100%; background: var(--accent-violet, #7c3aed); }

/* --- Chat --- */
#chat { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.chat-toolbar { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; padding: 0.5rem; }
.chat-toolbar .spacer { flex: 1; }
#chat-stream { flex: 1; overflow-y: auto; padding: 0.5rem; }
.turn { margin-bottom: 0.75rem; }
.turn-head { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.35rem; font-size: 11px; }
.turn-body { white-space: pre-wrap; word-break: break-word; }
.chat-composer { display: flex; gap: 0.5rem; align-items: flex-end; padding: 0.5rem; }
.chat-composer textarea { flex: 1; min-height: 60px; padding: 0.5rem; font-family: inherit; }

/* --- Session Inspector --- */
#session-inspector { margin-top: 1.5rem; padding-top: 1rem; }
#session-inspector h3 { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
#session-inspector table { width: 100%; border-collapse: collapse; font-size: 12px; }
#session-inspector th, #session-inspector td { padding: 0.25rem 0.5rem; text-align: left; border-bottom: 1px solid rgba(0,0,0,0.05); }

/* --- Tasks / Roadmap / Projects tabs --- */
#tasks, #roadmap, #projects { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#tasks .filter-bar, #roadmap .filter-bar, #projects .filter-bar { padding: 0.5rem 1rem; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
#tasks-list { flex: 1; overflow-y: auto; padding: 0.5rem 1rem; }
#roadmap-content { flex: 1; overflow: auto; padding: 1rem; }
#projects-grid { flex: 1; overflow-y: auto; padding: 1rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.project-card { padding: 1rem; border-radius: 6px; cursor: pointer; position: relative; overflow: hidden; }
.project-card .stripe { position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.project-card .title { font-weight: 600; margin-bottom: 0.25rem; }
.project-card .meta { font-size: 12px; opacity: 0.7; }

/* --- Roadmap rows --- */
.roadmap-agent { margin-bottom: 1.5rem; }
.roadmap-agent h3 { margin-bottom: 0.5rem; }
.roadmap-task { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.35rem; }
.roadmap-task .title { width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roadmap-task .bar { flex: 1; height: 10px; position: relative; background: rgba(0,0,0,0.05); border-radius: 5px; overflow: hidden; }
.roadmap-task .bar-fill { height: 100%; }
.roadmap-task .dates { width: 180px; text-align: right; font-size: 11px; }

/* --- Auth gate --- */
#auth-gate { display: flex; flex: 1; align-items: center; justify-content: center; padding: 2rem; }
#auth-gate .card { padding: 2rem; min-width: 300px; max-width: 420px; }
#auth-gate h2 { margin-bottom: 0.5rem; }
#auth-gate p { margin-bottom: 1rem; }
#auth-gate input { width: 100%; margin-bottom: 0.75rem; padding: 0.5rem; }
#auth-gate .msg { margin-top: 0.75rem; font-size: 13px; }

/* --- Toasts --- */
#toasts { position: fixed; bottom: 1rem; right: 1rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 100; }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
#toasts .toast { animation: slideIn 0.2s ease-out; padding: 0.5rem 1rem; background: #222; color: #fff; border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
#toasts .toast.error { background: #c0392b; }
#toasts .toast.success { background: #27ae60; }

/* --- Dialog --- */
.dialog-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 50; }
.dialog { background: #fff; padding: 1.5rem; border-radius: 8px; min-width: 320px; max-width: 520px; box-shadow: 0 8px 32px rgba(0,0,0,0.2); }
.dialog h3 { margin-bottom: 1rem; }
.dialog textarea, .dialog select, .dialog input { width: 100%; margin-bottom: 0.75rem; padding: 0.4rem; }
.dialog textarea { min-height: 80px; }
.dialog .actions { display: flex; gap: 0.5rem; justify-content: flex-end; }

/* --- Realtime pill --- */
.realtime-pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(0,0,0,0.08); }
.realtime-pill[data-state="live"] { background: #27ae60; color: #fff; }
.realtime-pill[data-state="connecting"], .realtime-pill[data-state="reconnecting"] { background: #f39c12; color: #fff; }
.realtime-pill[data-state="error"] { background: #c0392b; color: #fff; }

/* --- Mobile (<900px): show chat tab button, hide split --- */
@media (max-width: 899px) {
  #moderation { flex-direction: column; }
  #queue-list { width: 100%; min-width: 0; }
}
@media (min-width: 900px) {
  .nav-chat-only-mobile { display: none !important; }
}

/* Error boundary */
.error-boundary { padding: 2rem; text-align: center; }
.error-boundary pre { text-align: left; background: #eee; padding: 1rem; border-radius: 4px; max-height: 200px; overflow: auto; font-size: 11px; }

/* Small inline helpers */
.inline-link { background: none; border: none; color: inherit; text-decoration: underline; cursor: pointer; font-size: 12px; padding: 2px 4px; }
.badge { padding: 1px 6px; border-radius: 3px; font-size: 11px; display: inline-block; }
.impact-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.impact-dot.high { background: #c0392b; }
.impact-dot.med { background: #f39c12; }
.impact-dot.low { background: #27ae60; }
