/* chat-v2.css — entity-first chat rail (Phase 1). Scoped under .cv2-* so it
   never collides with the legacy chat panel styles. */

.cv2-root { display:flex; flex-direction:column; height:100%; min-height:0; background:var(--panel,#fff);
  font-family:var(--font, inherit); color:var(--ink,#0d1b2a); }

/* pinned entity context card */
.cv2-ctx { display:flex; align-items:center; gap:8px; padding:10px 12px; border-bottom:1px solid var(--line,#e3e8ef);
  background:var(--bg,#f6f8fb); flex-wrap:wrap; }
.cv2-ctx-type { font-size:10px; font-weight:800; letter-spacing:.06em; text-transform:uppercase; color:#fff;
  background:var(--brand,#0a3d62); border-radius:5px; padding:2px 7px; }
.cv2-ctx-id { font-weight:700; font-size:13px; }
.cv2-ctx-status, .cv2-ctx-agent { font-size:11px; color:var(--muted,#7a8aa0); background:var(--panel,#fff);
  border:1px solid var(--line,#e3e8ef); border-radius:20px; padding:1px 9px; }

/* conversation tabs */
.cv2-tabs { display:flex; gap:6px; padding:8px 10px; overflow-x:auto; border-bottom:1px solid var(--line,#e3e8ef);
  scrollbar-width:thin; }
.cv2-tab { flex:0 0 auto; border:1px solid var(--line,#e3e8ef); background:var(--panel,#fff); color:var(--ink-soft,#3d4f63);
  border-radius:18px; padding:5px 12px; font-size:12.5px; cursor:pointer; white-space:nowrap; position:relative; }
.cv2-tab:hover { border-color:var(--brand-2,#1a6fb0); }
.cv2-tab.on { background:var(--brand,#0a3d62); color:#fff; border-color:var(--brand,#0a3d62); }
.cv2-tab-add { color:var(--brand-2,#1a6fb0); font-weight:600; border-style:dashed; }
.cv2-badge { display:inline-block; margin-left:6px; min-width:16px; height:16px; line-height:16px; text-align:center;
  font-size:10px; font-weight:700; color:#fff; background:var(--accent,#e8772e); border-radius:9px; padding:0 4px; }

/* thread */
.cv2-thread { flex:1 1 auto; min-height:0; overflow-y:auto; padding:12px; display:flex; flex-direction:column; gap:10px; }
.cv2-loading, .cv2-empty { color:var(--muted,#7a8aa0); text-align:center; padding:24px 12px; font-size:13px; }
.cv2-more { align-self:center; border:1px solid var(--line,#e3e8ef); background:var(--bg,#f6f8fb); color:var(--brand-2,#1a6fb0);
  border-radius:16px; padding:4px 14px; font-size:12px; cursor:pointer; }

.cv2-msg { position:relative; max-width:88%; align-self:flex-start; background:var(--bg,#f6f8fb);
  border:1px solid var(--line-soft,#eef2f7); border-radius:12px; padding:8px 11px; }
.cv2-msg.mine { align-self:flex-end; background:var(--brand-50,#eef2ff); border-color:var(--brand-100,#dbe4ff); }
.cv2-msg.cv2-reply { max-width:100%; background:transparent; border:none; border-left:2px solid var(--line,#e3e8ef);
  border-radius:0; padding:4px 0 4px 10px; margin-left:6px; }
.cv2-deleted { opacity:.6; }
.cv2-msg-head { display:flex; gap:8px; align-items:baseline; margin-bottom:2px; }
.cv2-msg-author { font-weight:700; font-size:12.5px; }
.cv2-msg-time { font-size:10.5px; color:var(--muted,#7a8aa0); }
.cv2-msg-body { font-size:13px; line-height:1.45; word-wrap:break-word; white-space:normal; }
.cv2-mention { color:var(--brand-2,#1a6fb0); font-weight:600; background:var(--brand-50,#eef2ff); border-radius:4px; padding:0 3px; }
.cv2-ref { color:var(--accent,#e8772e); font-weight:600; }

.cv2-msg-actions { position:absolute; top:-10px; right:8px; display:none; gap:2px; background:var(--panel,#fff);
  border:1px solid var(--line,#e3e8ef); border-radius:8px; padding:1px 3px; box-shadow:0 2px 8px rgba(0,0,0,.08); }
.cv2-msg:hover .cv2-msg-actions { display:flex; }
.cv2-msg-actions button { border:none; background:none; cursor:pointer; font-size:13px; padding:2px 4px; border-radius:5px; }
.cv2-msg-actions button:hover { background:var(--bg,#f6f8fb); }

/* attachments */
.cv2-atts { display:flex; flex-wrap:wrap; gap:6px; margin-top:6px; }
.cv2-att { font-size:12px; color:var(--brand-2,#1a6fb0); text-decoration:none; border:1px solid var(--line,#e3e8ef);
  background:var(--panel,#fff); border-radius:8px; padding:3px 8px; }
.cv2-att-img { padding:0; overflow:hidden; }
.cv2-att-img img { max-width:160px; max-height:140px; display:block; }

/* unfurls — entity-color left border */
.cv2-unfurls { display:flex; flex-direction:column; gap:6px; margin-top:7px; }
.cv2-unfurl { display:flex; align-items:center; gap:8px; cursor:pointer; border:1px solid var(--line,#e3e8ef);
  border-left:3px solid var(--muted,#7a8aa0); border-radius:8px; padding:6px 10px; background:var(--panel,#fff); font-size:12px; }
.cv2-unfurl:hover { background:var(--bg,#f6f8fb); }
.cv2-unfurl-deal { border-left-color:#2563eb; }
.cv2-unfurl-tcf  { border-left-color:#7c3aed; }
.cv2-unfurl-eft  { border-left-color:#059669; }
.cv2-unfurl-trs  { border-left-color:#e8772e; }
.cv2-unfurl-type { font-weight:800; font-size:10px; letter-spacing:.05em; color:var(--muted,#7a8aa0); }
.cv2-unfurl-ref { font-weight:600; }
.cv2-unfurl-go { margin-left:auto; color:var(--brand-2,#1a6fb0); font-weight:600; }

/* reactions */
.cv2-reacts { display:flex; flex-wrap:wrap; gap:4px; margin-top:6px; }
.cv2-react-chip { font-size:11.5px; border:1px solid var(--line,#e3e8ef); background:var(--panel,#fff); border-radius:12px;
  padding:1px 7px; cursor:pointer; }
.cv2-react-chip.mine { background:var(--brand-50,#eef2ff); border-color:var(--brand-2,#1a6fb0); }

/* threaded replies */
.cv2-thread-toggle { margin-top:5px; border:none; background:none; color:var(--brand-2,#1a6fb0); font-size:11.5px;
  cursor:pointer; padding:0; font-weight:600; }
.cv2-replies { margin-top:6px; display:flex; flex-direction:column; gap:6px; }

/* compose */
.cv2-compose { border-top:1px solid var(--line,#e3e8ef); padding:8px 10px; background:var(--panel,#fff); }
.cv2-replychip { display:flex; align-items:center; justify-content:space-between; font-size:11.5px; color:var(--muted,#7a8aa0);
  background:var(--bg,#f6f8fb); border-radius:6px; padding:3px 8px; margin-bottom:6px; }
.cv2-replychip button { border:none; background:none; cursor:pointer; color:var(--muted,#7a8aa0); }
.cv2-staged { display:flex; flex-wrap:wrap; gap:5px; margin-bottom:6px; }
.cv2-staged-chip { font-size:11px; background:var(--bg,#f6f8fb); border:1px solid var(--line,#e3e8ef); border-radius:6px; padding:2px 6px; }
.cv2-staged-chip button { border:none; background:none; cursor:pointer; margin-left:4px; color:var(--muted,#7a8aa0); }
.cv2-input-row { display:flex; align-items:flex-end; gap:4px; }
.cv2-ibtn { border:none; background:none; font-size:17px; cursor:pointer; padding:4px; border-radius:6px; line-height:1; }
.cv2-ibtn:hover { background:var(--bg,#f6f8fb); }
.cv2-input-row textarea { flex:1; resize:none; border:1px solid var(--line,#e3e8ef); border-radius:10px; padding:8px 11px;
  font-size:13px; font-family:inherit; max-height:120px; background:var(--bg,#f6f8fb); color:var(--ink,#0d1b2a); }
.cv2-send { border:none; background:var(--brand,#0a3d62); color:#fff; width:34px; height:34px; border-radius:9px;
  cursor:pointer; font-size:15px; flex:0 0 auto; }
.cv2-send:disabled { opacity:.5; cursor:default; }

/* floating popovers (emoji + mention) */
.cv2-float { position:fixed; z-index:9999; background:var(--panel,#fff); border:1px solid var(--line,#e3e8ef);
  border-radius:10px; box-shadow:0 6px 24px rgba(0,0,0,.14); padding:6px; }
.cv2-emoji-pop { display:grid; grid-template-columns:repeat(4,1fr); gap:2px; }
.cv2-emoji-pop button { border:none; background:none; font-size:18px; cursor:pointer; padding:4px; border-radius:6px; }
.cv2-emoji-pop button:hover { background:var(--bg,#f6f8fb); }
.cv2-mention-pop { min-width:220px; max-height:220px; overflow-y:auto; padding:4px; }
.cv2-mention-pop button { display:flex; gap:8px; align-items:baseline; width:100%; text-align:left; border:none;
  background:none; cursor:pointer; padding:6px 8px; border-radius:7px; font-size:12.5px; }
.cv2-mention-pop button.on, .cv2-mention-pop button:hover { background:var(--brand-50,#eef2ff); }
.cv2-mention-pop button span { color:var(--muted,#7a8aa0); font-size:11px; }

/* deal-modal Chat tab panel: give the rail a usable height inside the modal */
#dmPanel-chat.dm-panel { padding:0; }
#dmPanel-chat .cv2-root { height:62vh; max-height:62vh; border:1px solid var(--line,#e3e8ef); border-radius:10px; overflow:hidden; }

/* launcher button injected into other entity-modal headers */
.cv2-launch { border:1px solid var(--brand-2,#1a6fb0); background:var(--brand-50,#eef2ff); color:var(--brand,#0a3d62);
  border-radius:8px; padding:5px 11px; font-size:12.5px; font-weight:600; cursor:pointer; margin-left:6px; }
.cv2-launch:hover { background:var(--brand-100,#dbe4ff); }

/* shared slide-in rail */
.cv2-rail-scrim { position:fixed; inset:0; background:rgba(13,27,42,.34); z-index:240; opacity:0; transition:opacity .18s; }
.cv2-rail-scrim.open { opacity:1; }
.cv2-rail { position:absolute; top:0; right:0; height:100%; width:min(420px,94vw); background:var(--panel,#fff);
  display:flex; flex-direction:column; box-shadow:-8px 0 28px rgba(0,0,0,.18); transform:translateX(100%); transition:transform .2s; }
.cv2-rail-scrim.open .cv2-rail { transform:translateX(0); }
.cv2-rail-head { display:flex; align-items:center; justify-content:space-between; padding:12px 14px;
  border-bottom:1px solid var(--line,#e3e8ef); font-size:14px; }
.cv2-rail-head button { border:none; background:none; font-size:16px; cursor:pointer; color:var(--muted,#7a8aa0); }
.cv2-rail-body { flex:1; min-height:0; }

/* start-private-group 3-step sheet */
.cv2-sheet-scrim { position:fixed; inset:0; background:rgba(13,27,42,.4); z-index:260; display:flex;
  align-items:center; justify-content:center; padding:16px; }
.cv2-sheet { width:min(460px,96vw); max-height:88vh; background:var(--panel,#fff); border-radius:14px; display:flex;
  flex-direction:column; overflow:hidden; box-shadow:0 18px 50px rgba(0,0,0,.28); }
.cv2-sheet-head { display:flex; align-items:center; justify-content:space-between; padding:14px 16px; border-bottom:1px solid var(--line,#e3e8ef); }
.cv2-sheet-head button { border:none; background:none; font-size:16px; cursor:pointer; color:var(--muted,#7a8aa0); }
.cv2-sheet-steps { display:flex; gap:6px; padding:10px 16px; font-size:11.5px; }
.cv2-sheet-steps span { color:var(--muted,#7a8aa0); }
.cv2-sheet-steps span.on { color:var(--brand,#0a3d62); font-weight:700; }
.cv2-sheet-body { padding:14px 16px; overflow-y:auto; }
.cv2-sheet-label { display:block; font-size:12px; font-weight:600; margin-bottom:6px; }
.cv2-sheet-hint, .cv2-sheet-search ~ p { font-size:11.5px; color:var(--muted,#7a8aa0); margin-top:8px; }
.cv2-sheet-search { width:100%; border:1px solid var(--line,#e3e8ef); border-radius:9px; padding:8px 11px; font-size:13px;
  font-family:inherit; background:var(--bg,#f6f8fb); color:var(--ink,#0d1b2a); box-sizing:border-box; }
.cv2-sheet-pills { display:flex; flex-wrap:wrap; gap:5px; margin:10px 0; }
.cv2-pill { font-size:12px; background:var(--brand-50,#eef2ff); border:1px solid var(--brand-100,#dbe4ff); border-radius:14px; padding:2px 9px; }
.cv2-pill button { border:none; background:none; cursor:pointer; margin-left:4px; color:var(--brand,#0a3d62); }
.cv2-sheet-list { max-height:40vh; overflow-y:auto; display:flex; flex-direction:column; gap:2px; }
.cv2-sheet-row { display:flex; gap:8px; align-items:baseline; text-align:left; border:1px solid transparent; background:var(--bg,#f6f8fb);
  border-radius:8px; padding:7px 10px; cursor:pointer; font-size:12.5px; }
.cv2-sheet-row:hover { border-color:var(--line,#e3e8ef); }
.cv2-sheet-row.on { background:var(--brand-50,#eef2ff); border-color:var(--brand-2,#1a6fb0); }
.cv2-sheet-row span { color:var(--muted,#7a8aa0); font-size:11px; }
.cv2-sheet-foot { display:flex; justify-content:space-between; gap:8px; padding:12px 16px; border-top:1px solid var(--line,#e3e8ef); }
.cv2-confirm { display:flex; flex-direction:column; gap:8px; font-size:13px; }

/* ---- responsive: desktop split 65/35, tablet stacked, mobile bottom sheet ---- */
@media (max-width:1100px) {
  #dmPanel-chat .cv2-root { height:56vh; max-height:56vh; }
}
@media (max-width:760px) {
  .cv2-rail { width:100vw; height:80vh; top:auto; bottom:0; transform:translateY(100%);
    border-radius:16px 16px 0 0; }
  .cv2-rail-scrim.open .cv2-rail { transform:translateY(0); }
  .cv2-msg { max-width:94%; }
  #dmPanel-chat .cv2-root { height:64vh; max-height:64vh; }
}
