/* chat.css — внутренний чат (двухпанельный вид) */

#chat-view {
    height: calc(100vh - 120px);
}

.chat-layout {
    display: flex;
    height: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-primary);
    overflow: hidden;
}

/* ============ Левая панель: список чатов ============ */

.chat-list-pane {
    width: 320px;
    min-width: 260px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
}

.chat-list-header {
    padding: var(--sp-2);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.chat-search-input {
    width: 100%;
    padding: var(--sp-1) var(--sp-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text);
    font: inherit;
    font-size: var(--fs-sm, 13px);
}

.chat-new-actions {
    display: flex;
    gap: var(--sp-1);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-list-empty {
    padding: var(--sp-4);
    color: var(--text-muted);
    text-align: center;
    font-size: var(--fs-sm, 13px);
}

.chat-list-item {
    display: flex;
    gap: var(--sp-2);
    padding: var(--sp-2);
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}

.chat-list-item:hover { background: var(--bg-primary); }
.chat-list-item.active { background: var(--bg-primary); box-shadow: inset 2px 0 0 var(--primary); }

.chat-item-icon {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.chat-item-body { flex: 1; min-width: 0; }

.chat-item-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--sp-1);
}

.chat-item-title {
    font-weight: 600;
    font-size: var(--fs-sm, 13px);
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-time {
    flex: 0 0 auto;
    font-size: var(--fs-xs, 11px);
    color: var(--text-muted);
}

.chat-item-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-1);
}

.chat-item-preview {
    font-size: var(--fs-xs, 12px);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-unread-pill,
.chat-nav-badge {
    flex: 0 0 auto;
    background: var(--primary);
    color: #fff;
    border-radius: 999px;
    font-size: var(--fs-xs, 11px);
    line-height: 1;
    padding: 3px 7px;
    font-weight: 600;
}

.chat-nav-badge { margin-left: 6px; }

/* ============ Панель нового чата / поиска ============ */

.chat-new-panel,
.chat-manage-panel {
    padding: var(--sp-2);
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.chat-manage-panel {
    position: absolute;
    top: 52px;
    right: var(--sp-2);
    width: 280px;
    max-height: 60%;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 30;
}

.chat-new-title {
    font-size: var(--fs-xs, 11px);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.chat-new-users {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 220px;
    overflow-y: auto;
}

.chat-new-user,
.chat-new-user-check {
    text-align: left;
    padding: var(--sp-1) var(--sp-2);
    border: none;
    background: none;
    color: var(--text);
    cursor: pointer;
    border-radius: var(--radius);
    font: inherit;
    font-size: var(--fs-sm, 13px);
    display: flex;
    gap: var(--sp-1);
    align-items: center;
}

.chat-new-user:hover, .chat-new-user-check:hover { background: var(--bg-secondary); }

/* Перебиваем глобальное input { width: 100%; height: var(--size-md) } —
   паттерн как у .multi-select-options input[type="checkbox"]. */
.chat-new-user-check input[type="checkbox"] {
    width: var(--checkbox-size);
    height: var(--checkbox-size);
    margin: 0;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

.chat-new-user-email {
    color: var(--text-muted);
    font-size: var(--fs-xs, 11px);
}

.chat-search-results { flex: 1; overflow-y: auto; }

.chat-search-result {
    padding: var(--sp-2);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.chat-search-result:hover { background: var(--bg-primary); }
.chat-search-snippet {
    font-size: var(--fs-xs, 12px);
    color: var(--text-secondary);
    margin-top: 2px;
}
.chat-search-snippet mark {
    background: color-mix(in srgb, var(--primary) 30%, transparent);
    color: var(--text);
    border-radius: 2px;
}

/* ============ Правая панель: диалог ============ */

.chat-conversation-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

.chat-conv-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.chat-conv-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    border-bottom: 1px solid var(--border);
}

.chat-conv-title { font-weight: 600; }
.chat-conv-members {
    margin-left: var(--sp-2);
    font-size: var(--fs-xs, 12px);
    color: var(--text-muted);
}
.chat-conv-actions { display: flex; gap: var(--sp-1); }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-3);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.chat-load-older { align-self: center; }

.chat-msg {
    position: relative;
    max-width: 78%;
    align-self: flex-start;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--sp-2);
}

.chat-msg.own {
    align-self: flex-end;
    background: color-mix(in srgb, var(--primary) 8%, var(--bg-secondary));
}

.chat-msg.ai { border-style: dashed; }

.chat-msg-highlight { box-shadow: 0 0 0 2px var(--primary); }

.chat-msg-header {
    display: flex;
    align-items: baseline;
    gap: var(--sp-1);
    margin-bottom: 4px;
}

.chat-msg-author { font-weight: 600; font-size: var(--fs-sm, 13px); }
.chat-msg-time { font-size: var(--fs-xs, 11px); color: var(--text-muted); }

.chat-msg-content {
    font-size: var(--fs-sm, 14px);
    word-break: break-word;
}
.chat-msg-content img { max-width: 320px; border-radius: var(--radius); }

.chat-msg-actions {
    position: absolute;
    top: 4px;
    right: 4px;
    display: none;
    gap: 2px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2px;
}
.chat-msg:hover .chat-msg-actions { display: flex; }

.chat-msg-action {
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 12px;
}
.chat-msg-action:hover { background: var(--bg-secondary); color: var(--text); }

/* ============ Инпут ============ */

.chat-input-footer {
    border-top: 1px solid var(--border);
    padding: var(--sp-2);
    display: flex;
    gap: var(--sp-2);
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    resize: none;
    padding: var(--sp-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text);
    font: inherit;
    font-size: var(--fs-sm, 14px);
}

.chat-input-actions {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

/* ============ @-автокомплит ============ */

.chat-mention-dropdown {
    position: absolute;
    bottom: 70px;
    left: var(--sp-3);
    width: 280px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 40;
    overflow: hidden;
}

.chat-mention-item {
    padding: var(--sp-1) var(--sp-2);
    cursor: pointer;
    font-size: var(--fs-sm, 13px);
    display: flex;
    gap: var(--sp-1);
    align-items: baseline;
}
.chat-mention-item.active, .chat-mention-item:hover { background: var(--bg-secondary); }

.chat-manage-member {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--sp-1) var(--sp-2);
    font-size: var(--fs-sm, 13px);
}
.chat-member-remove {
    border: none;
    background: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 16px;
}

/* ============ Мобайл ============ */

@media (max-width: 768px) {
    .chat-layout { flex-direction: column; }
    .chat-list-pane {
        width: 100%;
        max-height: 40%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .chat-msg { max-width: 95%; }
}
