/* ============================================================
   Additions on top of the ported mockup CSS.
   Everything here covers a state the static mockup never had:
   login, empty work lists, live editing, popovers, streaming.
   ============================================================ */

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--bg-app); }
.login-card {
  width: 340px; display: flex; flex-direction: column; gap: 10px;
  background: var(--bg-panel); border: 1px solid var(--border-2);
  border-radius: var(--r-12); box-shadow: var(--sh-2); padding: 30px 28px 26px;
  text-align: center;
}
.login-logo {
  width: 34px; height: 34px; margin: 0 auto 4px; border-radius: var(--r-8);
  background: var(--accent); color: #fff; font-weight: 700; font-size: 17px;
  display: grid; place-items: center;
}
.login-card h1 { font-size: var(--fs-16); font-weight: 700; margin: 0; letter-spacing: -.3px; }
.login-card p { font-size: var(--fs-12); color: var(--text-3); margin: 0 0 8px; }
.login-card .inp { height: 34px; text-align: left; }
.login-card .btn { justify-content: center; height: 34px; }
.login-err {
  font-size: var(--fs-11); color: var(--danger);
  background: var(--danger-subtle); border-radius: var(--r-6); padding: 7px 10px;
}

/* ---------- work list ---------- */
.worklist { display: flex; flex-direction: column; gap: 4px; }
.workrow {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: var(--r-8); border: 1px solid transparent;
  background: var(--bg-panel);
}
.workrow:hover { border-color: var(--border-2); box-shadow: var(--sh-1); }
.workrow .wt { flex: 1; min-width: 0; }
.workrow .wt b { display: block; font-size: var(--fs-13); font-weight: 600; }
.workrow .wt small { display: block; font-size: var(--fs-11); color: var(--text-3); margin-top: 2px; }
.workrow .wt em { color: var(--accent); font-style: normal; font-weight: 600; }

/* ---------- embedded app frame ---------- */
.app-frame { flex: 1; width: 100%; border: 0; background: #fff; }
.embed-note {
  display: flex; align-items: center; gap: 6px; justify-content: center;
  padding: 6px; font-size: var(--fs-11); color: var(--text-3);
  background: var(--bg-panel); border-top: 1px solid var(--border-1);
}
.embed-note svg { width: 12px; height: 12px; }

/* ---------- dashboard extras ---------- */
.deptrow { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: var(--fs-11); }
.deptrow .nm { width: 96px; flex: none; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deptrow .bar { flex: 1; height: 6px; border-radius: 3px; background: var(--bg-subtle); overflow: hidden; }
.deptrow .bar i { display: block; height: 100%; border-radius: 3px; }
.deptrow .vl { width: 58px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.tbl th.num, .tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
.kpi .dl.flat { color: var(--text-3); }

/* ---------- popovers anchored to panel chrome ---------- */
.canvas-menu {
  position: absolute; z-index: 60; top: 40px; left: 12px; min-width: 220px;
  background: var(--bg-panel); border: 1px solid var(--border-2);
  border-radius: var(--r-8); box-shadow: var(--sh-3); padding: 5px;
  display: flex; flex-direction: column; gap: 2px;
}
.canvas-menu.type { top: 24px; left: 0; min-width: 0; flex-direction: row; flex-wrap: wrap; width: 148px; }
.canvas-menu.dark {
  top: 30px; right: 0; left: auto; background: #22222c; border-color: #34343f;
  max-height: 320px; overflow: auto;
}
.canvas-menu button {
  display: flex; align-items: center; gap: 7px; height: 28px; padding: 0 8px;
  border-radius: var(--r-6); font-size: var(--fs-12); color: var(--text-1);
  text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.canvas-menu button:hover { background: var(--bg-hover); }
.canvas-menu button.on { background: var(--accent-subtle); color: var(--accent); font-weight: 600; }
.canvas-menu button .muted { margin-left: auto; font-size: var(--fs-10); }
.canvas-menu.dark button { color: #d9d9e3; }
.canvas-menu.dark button:hover { background: #34343f; }
.canvas-menu.dark button.on { background: #34343f; color: #6ad6c4; }

/* ---------- popover menus ---------- */
.menu { position: relative; display: flex; align-items: center; flex: none; }
.rowmenu-btn {
  width: 22px; height: 22px; border-radius: var(--r-6); display: grid; place-items: center;
  color: var(--text-3); opacity: 0; transition: opacity .12s;
}
.rowmenu-btn svg { width: 14px; height: 14px; }
.rowmenu-btn:hover { background: var(--bg-hover); color: var(--text-1); }
.rowmenu-btn.on { opacity: 1; background: var(--bg-active); color: var(--text-1); }
/* Revealed on row hover, but always reachable by keyboard. */
.nav-row:hover .rowmenu-btn,
.workrow:hover .rowmenu-btn,
.rowmenu-btn:focus-visible { opacity: 1; }
.menu-pop {
  position: absolute; z-index: 70; top: 24px; min-width: 152px;
  background: var(--bg-panel); border: 1px solid var(--border-2);
  border-radius: var(--r-8); box-shadow: var(--sh-3); padding: 4px;
  display: flex; flex-direction: column; gap: 1px;
}
.menu-pop.right { right: 0; }
.menu-pop.left { left: 0; }
.menu-pop button {
  display: flex; align-items: center; height: 28px; padding: 0 9px;
  border-radius: var(--r-6); font-size: var(--fs-12); color: var(--text-1);
  text-align: left; white-space: nowrap;
}
.menu-pop button.two {
  flex-direction: column; align-items: flex-start; justify-content: center;
  height: auto; padding: 6px 9px; gap: 1px;
}
.menu-pop button.two .lb { font-weight: 600; }
.menu-pop button .ht { font-size: var(--fs-11); color: var(--text-3); }
.menu-pop button:hover { background: var(--bg-hover); }
.menu-pop button:hover .ht { color: var(--text-2); }
.menu-pop button.danger { color: var(--danger); }
.menu-pop button.danger:hover { background: var(--danger-subtle); }

/* The ported .switch sets width/height but no display. In the mockup every
   switch sat inside a `display:flex` wrapper, so `flex: none` gave it a box;
   in a table cell or a bare div it stays inline and collapses to nothing. */
.switch { display: inline-block; cursor: pointer; vertical-align: middle; }
.switch:focus-visible { outline: 0; box-shadow: var(--ring); }

/* Marks a sidebar person who already has a conversation, so the list reads as
   "these three, and the rest are new" rather than as 10 identical names. */
.dm-dot {
  width: 5px; height: 5px; border-radius: 50%; flex: none;
  background: var(--accent);
}

.btn.danger { color: var(--danger); border-color: var(--danger-border); }
.btn.danger:hover { background: var(--danger-subtle); }
.pill.danger { background: var(--danger-subtle); color: var(--danger); }

/* A sidebar work row: the nav-item keeps its own click target, the menu sits
   beside it because a button cannot nest inside a button. */
.nav-row { display: flex; align-items: center; border-radius: var(--r-6); }
.nav-row > .nav-item { flex: 1; min-width: 0; }
.nav-row:hover { background: var(--bg-hover); }
.nav-row:hover > .nav-item { background: transparent; }
.nav-row > .menu { margin-right: 6px; }
.nav-rename {
  flex: 1; min-width: 0; height: 26px; margin: 0 6px;
  border: 1px solid var(--accent-border); border-radius: var(--r-6);
  background: var(--bg-panel); color: var(--text-1);
  font-size: var(--fs-12); padding: 0 8px;
}
.nav-rename:focus { outline: 0; box-shadow: 0 0 0 2px var(--accent-subtle); }

/* ---------- @mention autocomplete ---------- */
.mention-pop {
  position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 60; min-width: 250px;
  background: var(--bg-panel); border: 1px solid var(--border-2);
  border-radius: var(--r-8); box-shadow: var(--sh-3); padding: 5px;
  display: flex; flex-direction: column; gap: 2px;
}
.mention-pop button {
  display: flex; align-items: center; gap: 7px; height: 30px; padding: 0 8px;
  border-radius: var(--r-6); font-size: var(--fs-12); text-align: left;
}
.mention-pop button:hover, .mention-pop button:first-child { background: var(--bg-hover); }
.mention-pop .muted { margin-left: auto; font-size: var(--fs-10); }
.composer-box { position: relative; }

/* ---------- streaming indicator ---------- */
.typing-dots { display: inline-flex; align-items: center; gap: 3px; height: 14px; }
.typing-dots.inline { margin-left: 4px; vertical-align: middle; }
.typing-dots i {
  width: 4px; height: 4px; border-radius: 50%; background: var(--text-3);
  animation: blink 1.2s infinite ease-in-out;
}
.typing-dots i:nth-child(2) { animation-delay: .18s; }
.typing-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* ---------- people picker rows ---------- */
.pickrow { border-radius: var(--r-8); border: 1px solid transparent; margin-bottom: 2px; }
.pickrow.on { border-color: var(--accent-border); background: var(--accent-subtle); }
.pickmain {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border-radius: var(--r-8);
}
.pickmain:hover { background: var(--bg-hover); }
.pickrow.on .pickmain:hover { background: transparent; }
.pickopts { display: flex; gap: 8px; align-items: center; padding: 0 10px 9px 40px; flex-wrap: wrap; }
.pickopts .sel { height: 24px; font-size: var(--fs-11); max-width: 240px; }

/* ---------- command palette rows ---------- */
.cmd-item {
  display: flex; align-items: center; gap: 9px; width: 100%; height: 34px;
  padding: 0 10px; border-radius: var(--r-6); font-size: var(--fs-12); text-align: left;
}
.cmd-item:hover { background: var(--bg-hover); }
.cmd-item .ic { width: 16px; text-align: center; color: var(--text-3); }
.cmd-item .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmd-item .g { font-size: var(--fs-10); color: var(--text-3); }

/* ---------- editable code view ---------- */
.code-view.code-edit { display: flex; align-items: stretch; padding: 14px 0; }
.code-edit .gutter {
  flex: none; padding: 0 12px 0 14px; text-align: right; color: #4b4b60;
  user-select: none; font-variant-numeric: tabular-nums;
}
.code-edit .code-area { position: relative; flex: 1; min-width: 0; padding-right: 16px; }
.code-edit pre, .code-edit textarea {
  margin: 0; font: inherit; line-height: inherit;
  white-space: pre-wrap; word-break: break-word;
}
.code-edit pre { pointer-events: none; }
.code-edit textarea {
  position: absolute; inset: 0; width: 100%; height: 100%;
  padding: 0 16px 0 0; border: 0; resize: none; overflow: hidden;
  background: transparent; color: transparent; caret-color: #d6d6e0;
}
.code-edit textarea:focus { outline: 0; }
.code-edit textarea::selection { background: #3a3a55; }

/* ---------- rich message bodies ----------
   The mockup only ever had paragraphs in a message; real model output brings
   tables, lists, quotes and code along with it. */
.msg-text table, .crow-text table {
  width: 100%; border-collapse: collapse; margin: 6px 0 10px; font-size: var(--fs-12);
}
.msg-text th, .msg-text td, .crow-text th, .crow-text td {
  border: 1px solid var(--border-2); padding: 5px 9px; text-align: left;
}
.msg-text th, .crow-text th { background: var(--bg-subtle); font-weight: 650; }
.msg-text ul, .msg-text ol, .crow-text ul, .crow-text ol { margin: 4px 0 10px; padding-left: 20px; }
.msg-text li, .crow-text li { margin: 2px 0; line-height: 1.7; }
.msg-text h1, .crow-text h1 { font-size: var(--fs-15); font-weight: 700; margin: 12px 0 6px; }
.msg-text h2, .crow-text h2 { font-size: var(--fs-14); font-weight: 650; margin: 12px 0 5px; }
.msg-text h3, .crow-text h3 { font-size: var(--fs-13); font-weight: 650; margin: 10px 0 4px; }
.msg-text blockquote, .crow-text blockquote {
  margin: 0 0 10px; padding: 6px 12px; border-left: 3px solid var(--accent-border);
  background: var(--accent-subtle); border-radius: 0 var(--r-6) var(--r-6) 0; color: var(--text-2);
}
.msg-text .codeblock, .crow-text .codeblock, .canvas-doc .codeblock {
  background: #16161d; color: #d6d6e0; border-radius: var(--r-8);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; line-height: 1.7; margin: 8px 0 10px;
  padding: 12px 14px; overflow-x: auto;
}
.msg-text .codeblock code, .crow-text .codeblock code, .canvas-doc .codeblock code {
  background: none; padding: 0; border-radius: 0; color: inherit;
  font-size: inherit; white-space: pre-wrap; word-break: break-word;
}
.msg-text code, .crow-text code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em;
  background: var(--bg-subtle); border-radius: var(--r-4); padding: 1px 4px;
}
.msg-text hr, .crow-text hr { border: 0; border-top: 1px solid var(--border-1); margin: 14px 0; }
.msg-text > div > *:last-child, .crow-text > div > *:last-child { margin-bottom: 0; }

/* ---------- misc ---------- */
.toast .err { color: #ff8f8f; }
.btn:disabled, .send:disabled { opacity: .45; pointer-events: none; }
.chip.sel { background: var(--accent-subtle); color: var(--accent); border-color: var(--accent-border); }
.mention { color: var(--accent); font-weight: 600; background: var(--accent-subtle); border-radius: var(--r-4); padding: 0 3px; }
.msg-text .steps, .crow-text + * { margin-top: 4px; }
