/* Team Chat dock (Phase 1) — styled to match AI chat panel */

:root {
    --team-chat-accent: #198754;
    --team-chat-accent-2: #20c997;
}

.chat-launcher {
    position: fixed;
    left: 20px;
    bottom: 36px;
    z-index: 1040;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--team-chat-accent) 0%, var(--team-chat-accent-2) 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform .2s, box-shadow .2s;
}
.chat-launcher:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.chat-launcher-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #dc3545;
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    border: 2px solid var(--chat-bg, #1a1a2e);
}

/* Discuss button (rendered by _DiscussButton.cshtml) — count badge + unread dot */
.discuss-btn { position: relative; }
.discuss-btn .discuss-count { font-weight: 600; }
.discuss-btn .discuss-unread-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #dc3545;
    margin-left: 6px;
    vertical-align: middle;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, .25);
    animation: bpc-discuss-pulse 1.6s ease-in-out infinite;
}
@keyframes bpc-discuss-pulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(220, 53, 69, .25); }
    50%      { box-shadow: 0 0 0 5px rgba(220, 53, 69, .05); }
}

/* Toolbar Discuss icon (injected by _injectDiscussBtn in Index.cshtml).
   The wrap matches sibling .screenshot-wrap / .fb-thumbs-wrap so the icon
   lines up with the rest of the content-actions-bar. */
.discuss-wrap { display: inline-flex; }
.discuss-wrap .fb-thumb-btn { position: relative; }
/* Has-messages: there's chatter on this page but nothing unread for you. */
.discuss-wrap .fb-thumb-btn.has-messages { color: #10b981; }
.discuss-wrap .fb-thumb-btn.has-messages:hover { color: #34d399; }
/* Has-unread: stronger red signal so it stands out from the green/idle states. */
.discuss-wrap .fb-thumb-btn.has-unread { color: #dc3545; }
.discuss-wrap .fb-thumb-btn.has-unread:hover { color: #ef4444; }
/* Unread count pill on the toolbar trigger. */
.discuss-wrap .discuss-tb-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: #dc3545;
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--chat-bg, #1a1a2e);
    animation: bpc-discuss-pulse 1.6s ease-in-out infinite;
}
.discuss-wrap .discuss-tb-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #dc3545;
    box-shadow: 0 0 0 2px var(--chat-bg, #1a1a2e);
    animation: bpc-discuss-pulse 1.6s ease-in-out infinite;
}

/* Picker rows: count is calm gray, unread badge is red and only shows when > 0 */
.discuss-menu .discuss-row { padding: .5rem .75rem; }
.discuss-menu .discuss-row-count { font-size: .72rem; }
.discuss-menu .discuss-row-unread {
    font-size: .7rem;
    padding: .15rem .4rem;
    border-radius: 10px;
    line-height: 1;
}

.chat-panel {
    position: fixed;
    left: 20px;
    bottom: 86px;
    z-index: 1041;
    width: 640px;
    height: 560px;
    min-width: 320px;
    min-height: 360px;
    max-width: calc(100vw - 48px);
    max-height: calc(100vh - 120px);
    border-radius: 12px;
    box-shadow: 0 8px 32px var(--chat-shadow, rgba(0,0,0,.35));
    background: var(--chat-bg, #1a1a2e);
    color: var(--chat-text, #e2e8f0);
    border: 1px solid var(--chat-border, rgba(255,255,255,.10));
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-size: var(--chat-font-size, 0.84rem);
}
.chat-panel.open { display: flex; }

/* Resize handles (top, right, top-right corner) */
.chat-resize-handle {
    position: absolute;
    z-index: 2;
}
.chat-resize-handle.top      { top: 0; left: 12px; right: 12px; height: 6px; cursor: n-resize; }
.chat-resize-handle.right    { top: 12px; right: 0; bottom: 12px; width: 6px; cursor: e-resize; }
.chat-resize-handle.topright { top: 0; right: 0; width: 14px; height: 14px; cursor: ne-resize; }
.chat-resize-handle.topright::after {
    content: '';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 8px;
    height: 8px;
    border-top: 2px solid var(--chat-grip, rgba(255,255,255,.35));
    border-right: 2px solid var(--chat-grip, rgba(255,255,255,.35));
    border-radius: 0 2px 0 0;
    pointer-events: none;
    transition: border-color .15s;
}
.chat-resize-handle.topright:hover::after {
    border-color: var(--chat-grip-hover, rgba(255,255,255,.7));
}
.chat-panel.resizing { user-select: none; }

.chat-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: linear-gradient(135deg, var(--team-chat-accent) 0%, var(--team-chat-accent-2) 100%);
    color: #fff;
    font-weight: 600;
    font-size: 1em;
    flex-shrink: 0;
    gap: 4px;
}
.chat-panel-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; min-width: 0; }
#chat-panel-title-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-panel-actions { display: flex; gap: 2px; flex-shrink: 0; }
.chat-panel-actions .btn-link {
    background: none;
    border: none;
    color: #fff;
    font-size: .95rem;
    cursor: pointer;
    opacity: .8;
    padding: 2px 6px;
    border-radius: 4px;
    transition: opacity .15s, background .15s;
    text-decoration: none;
}
.chat-panel-actions .btn-link:hover { opacity: 1; background: rgba(255,255,255,.18); color: #fff; }
.chat-panel-actions .btn-link.active {
    opacity: 1;
    background: rgba(255,255,255,.22);
    color: #fff;
}
.chat-panel-actions .chat-actions-divider {
    width: 1px;
    align-self: stretch;
    background: rgba(255,255,255,.25);
    margin: 4px 4px;
}
.chat-back-btn {
    background: none;
    border: none;
    color: #fff;
    opacity: .9;
    padding: 2px 8px 2px 4px;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 4px;
    margin-right: 2px;
    transition: opacity .15s, background .15s;
}
.chat-back-btn:hover { opacity: 1; background: rgba(255,255,255,.18); }

/* Context bar — visual breadcrumb that shows the active filter / view
   right under the header, so the selected toolbar icon is unambiguous. */
.chat-context-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--chat-surface, rgba(255,255,255,.04));
    border-bottom: 1px solid var(--chat-border, rgba(255,255,255,.10));
    font-size: .8rem;
    color: var(--chat-text-secondary, #94a3b8);
    flex-shrink: 0;
}
.chat-context-icon {
    color: var(--team-chat-accent-2, #20c997);
    font-size: 1rem;
    flex-shrink: 0;
}
.chat-context-label {
    color: var(--chat-text, #e2e8f0);
    font-weight: 600;
    font-size: .85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-context-sub {
    color: var(--chat-text-secondary, #94a3b8);
    font-size: .75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1 1 auto;
    min-width: 0;
}

/* Highlight the currently selected filter icon with a subtle underline so
   it reads as a tab even before the user notices the context bar. */
.chat-panel-actions .chat-filter-icon { position: relative; }
.chat-panel-actions .chat-filter-icon.active::after {
    content: '';
    position: absolute;
    left: 6px; right: 6px; bottom: -6px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
}

/* "Active" filter toggle on the New Conversation panel.
   Off = outlined / muted dot, On = solid green pill / glowing dot.
   The label changes between "Active only" / "All people" via JS. */
.chat-active-toggle {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--chat-border, rgba(255,255,255,.20));
    background: transparent;
    color: var(--chat-text-secondary, #94a3b8);
    font-size: .8rem;
    padding: 4px 10px;
    border-radius: 999px;
    white-space: nowrap;
    transition: background .15s, color .15s, border-color .15s;
}
.chat-active-toggle .chat-presence-dot {
    /* Off-state: hollow ring so it's clearly NOT showing only-active. */
    background: transparent;
    border: 1.5px solid var(--chat-text-secondary, #94a3b8);
    box-shadow: none;
    width: 10px; height: 10px;
}
.chat-active-toggle:hover {
    color: var(--chat-text, #e2e8f0);
    border-color: rgba(34, 197, 94, .55);
}
.chat-active-toggle:hover .chat-presence-dot {
    border-color: rgba(34, 197, 94, .8);
}
.chat-active-toggle.active {
    background: rgba(34, 197, 94, .18);
    border-color: rgba(34, 197, 94, .75);
    color: #22c55e;
    font-weight: 600;
}
.chat-active-toggle.active .chat-presence-dot {
    background: #22c55e;
    border-color: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, .25);
}

/* New Conversation view: action bar pinned at top, scrollable body underneath
   so the Start chat / Cancel buttons stay visible no matter how long the
   results list grows. */
#chat-new-view { display: flex; flex-direction: column; min-height: 0; }
.chat-new-actions {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--chat-border, rgba(255,255,255,.10));
    background: var(--chat-surface, rgba(255,255,255,.04));
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 1;
}
.chat-new-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 12px 14px;
    min-height: 0;
}

.chat-view { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }

/* Body wraps the sidebar (list) + main (thread/new/channels) panes.
   Single-column by default; two-column kicks in on wider panels. */
.chat-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}
.chat-main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

/* Two-column mode: list becomes a fixed sidebar, main pane fills the rest.
   Toggled by JS via .chat-two-col on the panel when width >= ~620px. */
.chat-panel.chat-two-col .chat-body {
    flex-direction: row;
}
.chat-panel.chat-two-col .chat-sidebar {
    flex: 0 0 240px;
    width: 240px;
    border-right: 1px solid var(--chat-border, rgba(255,255,255,.10));
    display: flex !important; /* always visible in two-col */
    min-height: 0;
}
.chat-panel.chat-two-col .chat-main {
    border-left: none;
}
/* Active conversation row (only meaningful in two-col but harmless elsewhere) */
.chat-conv-item.active {
    background: rgba(32, 201, 151, .14);
    box-shadow: inset 3px 0 0 var(--team-chat-accent-2, #20c997);
}
.chat-conv-item.active:hover { background: rgba(32, 201, 151, .18); }

/* Empty state in the main pane (two-col mode, no conversation selected) */
.chat-empty-pane {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
    color: var(--chat-text-secondary, #94a3b8);
}
.chat-empty-pane .chat-empty-inner i.bi-chat-dots {
    font-size: 2.4rem;
    color: var(--team-chat-accent-2, #20c997);
    opacity: .65;
    display: block;
    margin-bottom: 10px;
}
.chat-empty-title { color: var(--chat-text, #e2e8f0); font-weight: 600; font-size: .95rem; }
.chat-empty-sub   { font-size: .8rem; margin-top: 4px; }

.chat-conv-list { flex: 1 1 auto; overflow-y: auto; }
.chat-conv-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--chat-border, rgba(255,255,255,.10));
    cursor: pointer;
    transition: background .15s ease;
}
.chat-conv-item:hover { background: var(--chat-hover, rgba(255,255,255,.06)); }
.chat-conv-icon {
    flex: 0 0 auto;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(25, 135, 84, .15);
    color: var(--team-chat-accent-2, #20c997);
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
}
.chat-conv-body { flex: 1 1 auto; min-width: 0; }
.chat-conv-title-row { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.chat-conv-title { font-weight: 600; font-size: .92rem; color: var(--chat-text, #e2e8f0); min-width: 0; overflow-wrap: anywhere; word-break: break-word; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.chat-conv-title-main { display: block; font-weight: 700; }
.chat-conv-title-sub { display: block; font-weight: 500; font-size: .82rem; color: var(--chat-text-secondary, #94a3b8); }
.chat-conv-time { font-size: .7rem; color: var(--chat-text-secondary, #94a3b8); flex: 0 0 auto; }
.chat-conv-preview { font-size: .8rem; color: var(--chat-text-secondary, #94a3b8); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.chat-conv-unread {
    flex: 0 0 auto;
    background: #dc3545; color: #fff;
    border-radius: 10px;
    min-width: 20px; height: 20px;
    font-size: .7rem; font-weight: 700;
    line-height: 20px; text-align: center;
    padding: 0 6px;
    align-self: center;
}

.chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.chat-msg {
    max-width: 88%;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 1em;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
    position: relative;
}
.chat-msg.mine {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--team-chat-accent) 0%, var(--team-chat-accent-2) 100%);
    color: #fff;
    border-bottom-right-radius: 2px;
}
.chat-msg.theirs {
    align-self: flex-start;
    background: var(--chat-bubble-assistant, rgba(255,255,255,.08));
    color: var(--chat-text, #e2e8f0);
    border-bottom-left-radius: 2px;
}
.chat-msg-meta {
    font-size: .68rem;
    margin-bottom: 3px;
    opacity: .7;
    font-weight: 500;
}
.chat-msg.mine .chat-msg-meta { text-align: right; }

.chat-msg.system {
    align-self: stretch;
    max-width: 100%;
    background: rgba(99, 102, 241, .08);
    border-left: 3px solid var(--team-chat-accent, #6366f1);
    color: var(--chat-text, #e2e8f0);
    border-radius: 6px;
}
.chat-msg.system .chat-msg-meta { opacity: .85; }
.chat-msg.system .chat-msg-system-body { font-size: .95em; }
.chat-msg.system .chat-msg-actions { margin-top: 6px; }

.chat-msg.announcement {
    align-self: stretch;
    max-width: 100%;
    background: rgba(245, 158, 11, .10);
    border-left: 3px solid #f59e0b;
    color: var(--chat-text, #e2e8f0);
    border-radius: 6px;
}

.chat-mention {
    color: var(--team-chat-accent, #6366f1);
    font-weight: 600;
}

.chat-ann-options {
    padding: 4px 14px 8px;
    font-size: .8rem;
    color: var(--chat-text-secondary, #94a3b8);
}

.chat-msg { position: relative; }
.chat-msg-delete-btn {
    background: transparent;
    border: 0;
    color: inherit;
    opacity: 0;
    margin-left: 6px;
    padding: 0 4px;
    font-size: .85em;
    line-height: 1;
    cursor: pointer;
    transition: opacity .15s ease, color .15s ease;
}
.chat-msg-delete-btn:hover {
    color: #ef4444;
}
.chat-msg:hover .chat-msg-delete-btn,
.chat-msg-delete-btn:focus {
    opacity: .75;
}
.chat-msg-delete-btn:focus { outline: none; }

.chat-conv-item { position: relative; }
.chat-conv-delete-btn {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    background: transparent;
    border: 0;
    color: var(--chat-text-secondary, #94a3b8);
    opacity: 0;
    padding: 4px 6px;
    font-size: .9em;
    line-height: 1;
    cursor: pointer;
    border-radius: 4px;
    transition: opacity .15s ease, color .15s ease, background .15s ease;
}
.chat-conv-delete-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, .1);
}
.chat-conv-item:hover .chat-conv-delete-btn,
.chat-conv-delete-btn:focus {
    opacity: 1;
}
.chat-conv-delete-btn:focus { outline: none; }

.chat-typing {
    padding: 0 14px 4px;
    font-size: .78rem;
    color: var(--chat-text-secondary, #94a3b8);
    min-height: 18px;
    font-style: italic;
    opacity: .7;
}

.chat-send-form {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-top: 1px solid var(--chat-border, rgba(255,255,255,.10));
    flex-shrink: 0;
}
.chat-send-form textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--chat-border, rgba(255,255,255,.10));
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 1em;
    background: var(--chat-input-bg, #2a2a3d);
    color: var(--chat-text, #e2e8f0);
    outline: none;
    max-height: 120px;
    line-height: 1.4;
    transition: border-color .15s;
}
.chat-send-form textarea:focus { border-color: var(--team-chat-accent-2, #20c997); }
.chat-send-form textarea::placeholder { color: var(--chat-text-secondary, #94a3b8); opacity: .7; }
.chat-send-form .btn-primary {
    background: linear-gradient(135deg, var(--team-chat-accent) 0%, var(--team-chat-accent-2) 100%);
    border: none;
    color: #fff;
    border-radius: 8px;
    padding: 6px 12px;
    transition: filter .15s;
}
.chat-send-form .btn-primary:hover { filter: brightness(1.1); }

#chat-new-view .form-control,
#chat-new-view .form-control-sm {
    background: var(--chat-input-bg, #2a2a3d);
    color: var(--chat-text, #e2e8f0);
    border: 1px solid var(--chat-border, rgba(255,255,255,.10));
}
#chat-new-view .form-control:focus,
#chat-new-view .form-control-sm:focus {
    border-color: var(--team-chat-accent-2, #20c997);
    box-shadow: 0 0 0 .15rem rgba(32, 201, 151, .15);
}
#chat-new-view .form-label { color: var(--chat-text-secondary, #94a3b8); }
#chat-new-view .text-muted { color: var(--chat-text-secondary, #94a3b8) !important; }

#chat-create-btn {
    background: linear-gradient(135deg, var(--team-chat-accent) 0%, var(--team-chat-accent-2) 100%);
    border: none;
    color: #fff;
}
#chat-create-btn:disabled { filter: grayscale(.7) brightness(.7); }
#chat-new-cancel-btn {
    background: var(--chat-hover, rgba(255,255,255,.06));
    color: var(--chat-text, #e2e8f0);
    border: 1px solid var(--chat-border, rgba(255,255,255,.10));
}

.chat-user-results {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--chat-border, rgba(255,255,255,.10));
    border-radius: 8px;
    background: var(--chat-surface, rgba(255,255,255,.05));
}
.chat-user-row {
    padding: 8px 12px; cursor: pointer;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--chat-border, rgba(255,255,255,.10));
    transition: background .15s;
}
.chat-user-row:last-child { border-bottom: none; }
.chat-user-row:hover { background: var(--chat-hover, rgba(255,255,255,.06)); }
.chat-user-row.selected { background: rgba(25, 135, 84, .12); }
.chat-user-row .chat-user-name { font-size: .9rem; color: var(--chat-text, #e2e8f0); }
.chat-user-row .chat-user-email { font-size: .75rem; color: var(--chat-text-secondary, #94a3b8); }

/* Presence indicator (used in active list + search results) */
.chat-presence-dot {
    display: inline-block;
    width: 9px; height: 9px;
    border-radius: 50%;
    margin-right: 8px;
    flex: 0 0 9px;
    background: var(--chat-text-secondary, #94a3b8);
    box-shadow: 0 0 0 2px rgba(0,0,0,.15);
}
.chat-presence-dot.online {
    background: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, .25);
}
.chat-presence-dot.offline { opacity: .45; }

/* Inline presence dot inside a conversation list title — slightly smaller,
   no surrounding ring so it doesn't crowd the text. */
.chat-conv-presence-dot {
    width: 8px; height: 8px;
    flex: 0 0 8px;
    margin-right: 6px;
    box-shadow: none;
    vertical-align: middle;
}

/* Thread header: shown above #chat-messages whenever a conversation is open.
   Mirrors the visual language of the conversation list rows. */
.chat-thread-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--chat-border, rgba(255,255,255,.10));
    background: var(--chat-bg-2, rgba(255,255,255,.02));
    flex: 0 0 auto;
}
.chat-thread-header-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
}
.chat-thread-header-icon {
    color: var(--chat-text-secondary, #94a3b8);
    font-size: 1rem;
    flex: 0 0 auto;
}
.chat-thread-header-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.chat-thread-header-title {
    font-weight: 600;
    color: var(--chat-text, #e2e8f0);
    font-size: .92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-thread-header-sub {
    font-size: .72rem;
    color: var(--chat-text-secondary, #94a3b8);
    line-height: 1.1;
}
.chat-thread-members-btn {
    background: transparent;
    border: none;
    color: var(--chat-text-secondary, #94a3b8);
    padding: 4px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    flex: 0 0 auto;
    font-size: .85rem;
}
.chat-thread-members-btn:hover {
    color: var(--chat-text, #e2e8f0);
    background: var(--chat-hover, rgba(255,255,255,.06));
}
.chat-thread-members-count {
    font-size: .72rem;
    font-weight: 600;
}

/* Members panel — slides in below the header inside the thread view. */
.chat-members-panel {
    border-bottom: 1px solid var(--chat-border, rgba(255,255,255,.10));
    background: var(--chat-bg-2, rgba(255,255,255,.03));
    max-height: 220px;
    overflow-y: auto;
    flex: 0 0 auto;
}
.chat-members-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--chat-text-secondary, #94a3b8);
    border-bottom: 1px solid var(--chat-border, rgba(255,255,255,.08));
}
.chat-members-close-btn {
    background: transparent;
    border: none;
    color: var(--chat-text-secondary, #94a3b8);
    padding: 2px 6px;
    cursor: pointer;
}
.chat-members-close-btn:hover { color: var(--chat-text, #e2e8f0); }
.chat-members-list {
    padding: 4px 0;
}
.chat-members-row {
    display: flex;
    align-items: center;
    padding: 4px 12px;
    font-size: .85rem;
    color: var(--chat-text, #e2e8f0);
}
.chat-members-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-members-you {
    color: var(--chat-text-secondary, #94a3b8);
    font-size: .75rem;
}

.chat-active-section .chat-active-header {
    display: flex; align-items: center;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 600;
}
.chat-active-results { max-height: 160px; }

/* Quick-DM "Active now" section at the bottom of the conversation sidebar.
   Lets users start a Direct chat in a single click without opening the New
   Conversation flow. */
.chat-quick-active {
    border-top: 1px solid var(--chat-border, rgba(255,255,255,.10));
    padding: 8px 0 6px;
    background: rgba(255,255,255,.02);
}
.chat-quick-active-header {
    padding: 4px 14px 6px;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 600;
    color: var(--chat-text-secondary, #94a3b8);
}
.chat-quick-user {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 14px;
    cursor: pointer;
    transition: background .15s ease;
    font-size: .85rem;
    color: var(--chat-text, #e2e8f0);
}
.chat-quick-user:hover { background: var(--chat-hover, rgba(255,255,255,.06)); }
.chat-quick-user-name {
    flex: 1 1 auto; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-quick-user .bi-chat-dots {
    color: var(--team-chat-accent-2, #20c997);
    opacity: 0; transition: opacity .15s ease;
    font-size: .9rem;
}
.chat-quick-user:hover .bi-chat-dots { opacity: 1; }
.chat-quick-empty {
    padding: 6px 14px 10px;
    font-size: .78rem;
    color: var(--chat-text-secondary, #94a3b8);
    font-style: italic;
}

.chat-chips { display: flex; flex-wrap: wrap; gap: 4px; min-height: 8px; }
.chat-chip {
    background: rgba(25, 135, 84, .18);
    color: var(--team-chat-accent-2, #20c997);
    border: 1px solid rgba(25, 135, 84, .3);
    border-radius: 14px;
    padding: 3px 10px;
    font-size: .8rem;
    display: flex; align-items: center; gap: 4px;
}
.chat-chip .chat-chip-x { cursor: pointer; opacity: .7; font-weight: bold; }
.chat-chip .chat-chip-x:hover { opacity: 1; }

@@media (max-width: 991.98px) {
    /* Stack above the "Menu" mobile-sidebar-toggle pill (which sits at
       bottom: calc(64px + safe-area), ~32px tall) so the team chat
       launcher mirrors the AI chat FAB on the right side. */
    .chat-launcher { left: 16px; bottom: calc(116px + env(safe-area-inset-bottom, 0px)); }
    .chat-panel { left: 12px; bottom: calc(176px + env(safe-area-inset-bottom, 0px)); }
    .chat-toast { left: 12px; bottom: calc(176px + env(safe-area-inset-bottom, 0px)); }
}
@@media (max-width: 767.98px) {
    .chat-panel {
        width: calc(100vw - 24px) !important;
        left: 12px !important; right: 12px !important;
        height: 55vh !important;
        max-height: 420px !important;
        min-height: 280px !important;
    }
}

/* Pulse animation when a new message arrives with panel closed */
@@keyframes chatLauncherPulse {
    0%   { box-shadow: 0 0 0 0 rgba(25, 135, 84, .55); }
    70%  { box-shadow: 0 0 0 14px rgba(25, 135, 84, 0); }
    100% { box-shadow: 0 0 0 0 rgba(25, 135, 84, 0); }
}
.chat-launcher-pulse { animation: chatLauncherPulse 1.4s ease-out 2; }

/* Incoming message toast (shown when panel closed) */
.chat-toast {
    position: fixed;
    left: 90px;
    bottom: 36px;
    z-index: 1042;
    max-width: 320px;
    min-width: 240px;
    background: var(--chat-bg, #1a1a2e);
    color: var(--chat-text, #e2e8f0);
    border: 1px solid var(--chat-border, rgba(255,255,255,.10));
    border-left: 3px solid var(--team-chat-accent-2, #20c997);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.5);
    padding: 10px 12px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    animation: chatToastIn .25s ease-out;
}
.chat-toast.chat-toast-leaving { animation: chatToastOut .25s ease-in forwards; }
@@keyframes chatToastIn  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@@keyframes chatToastOut { to   { opacity: 0; transform: translateY(8px); } }
.chat-toast-icon { color: var(--team-chat-accent-2, #20c997); font-size: 1.1rem; flex: 0 0 auto; line-height: 1.2; }
.chat-toast-body { flex: 1 1 auto; min-width: 0; }
.chat-toast-title { font-weight: 600; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--chat-text, #e2e8f0); }
.chat-toast-preview { font-size: .8rem; color: var(--chat-text-secondary, #94a3b8); margin-top: 2px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chat-toast-close {
    background: transparent; border: none; color: var(--chat-text-secondary, #94a3b8);
    font-size: 1.1rem; line-height: 1; padding: 0 2px; cursor: pointer; flex: 0 0 auto;
}
.chat-toast-close:hover { color: var(--chat-text, #fff); }
@@media (max-width: 575.98px) {
    .chat-toast { left: 8px; right: 8px; bottom: calc(170px + env(safe-area-inset-bottom, 0px)); max-width: none; }
}

/* Phase 3 — Channels browse view */
.chat-channel-list { max-height: 360px; overflow-y: auto; border: 1px solid var(--chat-border, rgba(255,255,255,.10)); border-radius: 6px; }
.chat-channel-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--chat-border, rgba(255,255,255,.10));
}
.chat-channel-row:last-child { border-bottom: none; }
.chat-channel-row:hover { background: var(--chat-hover, rgba(255,255,255,.06)); }
.chat-channel-row-body { flex: 1 1 auto; min-width: 0; }
.chat-channel-name { font-weight: 600; color: var(--chat-text, #e2e8f0); font-size: .92rem; }
.chat-channel-name .bi-hash { color: var(--team-chat-accent-2, #20c997); margin-right: 2px; }
.chat-channel-title-extra { font-weight: 400; color: var(--chat-text-secondary, #94a3b8); font-size: .85rem; margin-left: 4px; }
.chat-channel-desc { font-size: .8rem; color: var(--chat-text-secondary, #94a3b8); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-channel-meta { font-size: .7rem; color: var(--chat-text-secondary, #94a3b8); margin-top: 2px; }
.chat-channel-actions { flex: 0 0 auto; }
.chat-channel-create {
    background: var(--chat-hover, rgba(255,255,255,.04));
    border: 1px solid var(--chat-border, rgba(255,255,255,.10));
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 10px;
}
.chat-channel-create .form-control,
.chat-channel-create .form-control-sm {
    background: var(--chat-input-bg, #2a2a3d);
    color: var(--chat-text, #e2e8f0);
    border: 1px solid var(--chat-border, rgba(255,255,255,.10));
}
#chat-channels-view .form-control,
#chat-channels-view .form-control-sm {
    background: var(--chat-input-bg, #2a2a3d);
    color: var(--chat-text, #e2e8f0);
    border: 1px solid var(--chat-border, rgba(255,255,255,.10));
}
