/* arbah-v3-chatpanel.css — Arbah v3 ChatPanel (per-project chat thread).
 * Restyle-only presentation for src/components/chatpanel/ChatPanelV3Surface.js.
 * Adapted from design/arbah-v3/project/chatpanel.css. The app chat is
 * project-scoped (one thread), so the mockup's two-pane .chat shell wraps a
 * single thread pane — the left conversation list is omitted (no fabricated
 * conversations; the mockup itself hides .chat-list on mobile). The
 * .thread-head (other-participant avatar + name + project id-chip + name) and
 * the composer attach button ARE rendered to match the mockup chrome.
 * Bubbles: own = navy-700 white on inline-end, others = surface + border on
 * inline-start. Mono timestamps. RTL mirrors the bubble sides + the send glyph.
 *
 * EVERY rule is scoped under `.av3` (this surface renders inside
 * ProjectDetail's chat tab). Reuses shipped primitives where possible
 * (.sk / .sk-line / .empty-state / .empty-ico / .empty-title); only the
 * thread/bubble/composer specifics live here. Tokens come from
 * arbah-v3-tokens.css — none are redefined. */

/* Page header spacing — the .phead/.page-title primitives provide the
 * type; this just adds breathing room above the chat card. */
.av3 .page > .phead { margin-bottom: 18px; }

/* Two-pane card shell (mockup .chat). The app chat is project-scoped — one
 * thread — so the mockup's left conversation list is omitted and the thread
 * pane fills the shell (the mockup itself hides .chat-list on mobile via a
 * container query). The shell owns the border / radius / height / shadow. */
.av3 .chat {
  display: flex;
  height: 564px;
  max-height: 80vh;
  border: 1px solid var(--arbah-border);
  border-radius: var(--r-12);
  overflow: hidden;
  background: var(--arbah-surface);
  box-shadow: var(--shadow-card);
}

/* Thread pane — fills the shell; no own border/radius (the shell owns it). */
.av3 .chat-thread,
.av3 .cp-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Thread head — other participant avatar + name + project id-chip + name.
 * (mockup .thread-head). .avatar-md / .id-chip come from the v3 primitives. */
.av3 .thread-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--arbah-border);
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
  background: var(--arbah-surface);
}
.av3 .thread-head .nm {
  font-size: 14px;
  font-weight: 600;
  color: var(--arbah-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.av3 .thread-head .pj {
  font-size: 12px;
  color: var(--arbah-ink-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.av3 .thread-head .pj .id-chip { font-size: 10px; padding: 1px 6px; }
.av3 .thread-head .pj-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.av3 .cp-error {
  margin: 12px;
  padding: 9px 12px;
  border-radius: var(--r-8);
  background: var(--arbah-danger-soft);
  border: 1px solid #F2C2C2;
  color: var(--arbah-danger);
  font-size: 13px;
  flex-shrink: 0;
}

/* Message scroll area */
.av3 .cp-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: var(--arbah-surface-sunken);
}

.av3 .cp-loading {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0;
}

.av3 .cp-empty { margin: auto 0; }

/* Date separators — TODAY / YESTERDAY / DD Mon */
.av3 .cp-daysep {
  align-self: center;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--arbah-ink-subtle);
  background: var(--arbah-surface-raised);
  padding: 3px 10px;
  border-radius: 999px;
  margin: 6px 0;
}

/* Unread divider */
.av3 .cp-divider {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 4px 0;
}
.av3 .cp-divider-line {
  flex: 1;
  height: 1px;
  background: var(--arbah-bronze-200);
}
.av3 .cp-divider-txt {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--arbah-bronze-700);
  white-space: nowrap;
}

/* Bubble rows */
.av3 .cp-msg {
  display: flex;
  flex-direction: column;
}
.av3 .cp-msg.own { align-items: flex-end; }
.av3 .cp-msg.other { align-items: flex-start; }

.av3 .cp-bubble {
  max-width: 72%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.45;
}
.av3 .cp-msg.own .cp-bubble {
  background: var(--arbah-navy-700);
  color: #fff;
  border-end-end-radius: 4px;
}
.av3 .cp-msg.other .cp-bubble {
  background: var(--arbah-surface);
  border: 1px solid var(--arbah-border);
  color: var(--arbah-ink);
  border-end-start-radius: 4px;
}

.av3 .cp-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 3px;
}
.av3 .cp-author {
  font-size: 11.5px;
  font-weight: 600;
}
.av3 .cp-msg.own .cp-author { color: rgba(255, 255, 255, .92); }
.av3 .cp-msg.other .cp-author { color: var(--arbah-navy-500); }
.av3 .cp-edited {
  font-size: 9.5px;
  opacity: .7;
}

.av3 .cp-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.av3 .cp-text span { font-weight: 600; }
.av3 .cp-msg.own .cp-text span { color: #DCE6F3; }
.av3 .cp-msg.other .cp-text span { color: var(--arbah-navy-500); }

.av3 .cp-bt {
  font-family: var(--font-mono);
  font-size: 10px;
  margin-top: 5px;
  opacity: .68;
  font-variant-numeric: tabular-nums;
}

/* Soft-delete tombstone */
.av3 .cp-bubble.cp-tomb {
  background: transparent;
  border: 1px dashed var(--arbah-border-strong);
  color: var(--arbah-ink-subtle);
}
.av3 .cp-tomb-txt { font-style: italic; font-size: 12px; }

/* Per-row action links (reply / edit / delete) */
.av3 .cp-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 4px;
  font-size: 11.5px;
}
.av3 .cp-act {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  color: var(--arbah-ink-muted);
  font-family: var(--font-sans);
  font-size: 11.5px;
}
.av3 .cp-act:hover { color: var(--arbah-ink); }
.av3 .cp-act.danger { color: var(--arbah-danger); }
.av3 .cp-act.danger:hover { color: #7F1212; }
.av3 .cp-act-sep { color: var(--arbah-border-strong); }
[dir="rtl"] .av3 .cp-act { font-family: var(--font-sans-ar); }

/* Inline edit form inside an own bubble */
.av3 .cp-bubble.cp-edit {
  width: 100%;
  max-width: 72%;
  background: var(--arbah-navy-700);
}
.av3 .cp-edit-head {
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(255, 255, 255, .82);
  margin-bottom: 5px;
}
.av3 .cp-edit-input {
  width: 100%;
  resize: none;
  border: none;
  border-radius: var(--r-6);
  padding: 7px 10px;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--arbah-ink);
  background: var(--arbah-surface);
  outline: none;
  min-height: 34px;
  max-height: 120px;
}
[dir="rtl"] .av3 .cp-edit-input { font-family: var(--font-sans-ar); }
.av3 .cp-edit-actions {
  display: flex;
  gap: 12px;
  margin-top: 7px;
}
.av3 .cp-link {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}
.av3 .cp-link.muted { color: rgba(255, 255, 255, .7); font-weight: 500; }
[dir="rtl"] .av3 .cp-link { font-family: var(--font-sans-ar); }

/* Inline reply composer (sits below the parent bubble) */
.av3 .cp-reply {
  position: relative;
  align-self: stretch;
  margin: 2px 0 4px;
  padding-inline-start: 24px;
}
.av3 .cp-reply-to {
  font-size: 11.5px;
  color: var(--arbah-ink-muted);
  margin-bottom: 5px;
}
.av3 .cp-reply-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

/* Shared rounded input (reply + composer) */
.av3 .cp-input,
.av3 .cp-composer-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--arbah-border);
  border-radius: 999px;
  padding: 11px 16px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  outline: none;
  background: var(--arbah-surface-sunken);
  color: var(--arbah-ink);
}
.av3 .cp-input::placeholder,
.av3 .cp-composer-input::placeholder { color: var(--arbah-ink-subtle); }
.av3 .cp-input:focus,
.av3 .cp-composer-input:focus {
  background: var(--arbah-surface);
  border-color: var(--arbah-navy-500);
  box-shadow: var(--ring);
}
[dir="rtl"] .av3 .cp-input,
[dir="rtl"] .av3 .cp-composer-input { font-family: var(--font-sans-ar); }
.av3 .cp-input {
  resize: none;
  min-height: 40px;
  max-height: 120px;
  line-height: 1.4;
}

/* Composer bar */
.av3 .cp-composer {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--arbah-border);
  flex-shrink: 0;
  background: var(--arbah-surface);
}

/* Attach button — square ghost (matches mockup .composer .attach). The
 * affordance is non-functional (no photo-capture wired); rendered disabled
 * so it reads as present-but-unavailable rather than faked. */
.av3 .cp-attach {
  width: 40px;
  height: 40px;
  border-radius: var(--r-8);
  border: 1px solid var(--arbah-border);
  background: var(--arbah-surface);
  color: var(--arbah-ink-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: not-allowed;
}

/* Send button — round navy (matches design .composer .send) */
.av3 .cp-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--arbah-navy-700);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.av3 .cp-send:hover { background: var(--arbah-navy-900); }
.av3 .cp-send:disabled {
  background: var(--arbah-border-strong);
  cursor: not-allowed;
}
.av3 .cp-send-sm { width: 38px; height: 38px; }
[dir="rtl"] .av3 .cp-send svg { transform: scaleX(-1); }

/* Mention dropdown — neutralize the inline Tailwind utility classes the
 * shared MentionDropdown renders so it reads as a v3 popover. The component
 * uses Tailwind class names; under .av3 we re-skin via the structural
 * selectors it produces (absolute-positioned panel + buttons). */
.av3 .cp-composer .absolute,
.av3 .cp-reply .absolute {
  font-family: var(--font-sans);
}
[dir="rtl"] .av3 .cp-composer .absolute,
[dir="rtl"] .av3 .cp-reply .absolute {
  font-family: var(--font-sans-ar);
}

/* Mobile: shrink the thread height (mirrors the design container query) */
@media (max-width: 760px) {
  .av3 .chat { height: 540px; }
  .av3 .cp-bubble { max-width: 84%; }
}
