/* ---------------------------------- */
/* СПИСОК ЧАТОВ                       */
/* ---------------------------------- */

.chats-list {
    flex: 1;
    min-height: 0;
    overflow: hidden;             /* убрали auto, т.к. скролл внутри Virtuoso */
    padding: 8px 8px 16px 8px;
    touch-action: pan-y;
}

/* ДОБАВЛЯЕМ СТИЛИ ДЛЯ КОНТЕЙНЕРА ВНУТРИ Chats.js */
.chats-list-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.empty-chats {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
    font-size: 14px;
}


.chat-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 6px;
    position: relative;
    background: transparent;
}

.chat-item:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 60px;
    right: 12px;
    height: 1px;
    background: var(--border);
    opacity: 0.5;
}

.chat-item:hover {
    background: var(--bg-hover);
    transform: translateX(2px);
}

.chat-item.active {
    background: var(--primary-glow);
    box-shadow: var(--shadow-sm);
}

.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
    background-size: cover;
    box-shadow: var(--shadow-sm);
    position: relative;
    flex-shrink: 0;
}

.chat-avatar.online::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: var(--success);
    border-radius: 50%;
    border: 2px solid var(--bg-surface);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

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

.chat-name {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}

.chat-name-text {
    font-weight: 600;
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

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

.chat-time {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: 8px;
    align-self: flex-start;
    margin-top: 2px;
}

.unread-badge {
    background: var(--primary);
    color: white;
    border-radius: var(--radius-full);
    padding: 0 8px;
    font-size: 11px;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
    line-height: 20px;
    box-shadow: 0 0 4px var(--primary-glow);
    flex-shrink: 0;
}

/* Индикатор печати в списке чатов */
.chat-preview.typing {
    color: var(--primary);
    font-style: italic;
    animation: pulse 1.2s infinite;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .chats-list {
        padding: 6px 6px 12px 6px;
    }
    .chat-item {
        padding: 10px 10px;
        gap: 10px;
    }
    .chat-avatar {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }
    .chat-name-text {
        font-size: 14px;
    }
    .chat-preview {
        font-size: 11px;
    }
    .chat-time {
        font-size: 10px;
        margin-left: 4px;
    }
    .unread-badge {
        font-size: 10px;
        min-width: 18px;
        line-height: 18px;
        padding: 0 6px;
    }
}

/* Уважение prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .chat-item,
    .chat-preview.typing {
        animation: none;
        transition: none;
    }
    .chat-item:hover {
        transform: none;
    }
}

/* ================================== */
/* КОНТЕКСТНОЕ МЕНЮ ДЛЯ ЧАТОВ (ПКМ)   */
/* ================================== */

.chat-context-menu {
    position: fixed;
    min-width: 200px;
    max-width: calc(100vw - 20px); /* не вылезает за правый край */
    background: var(--bg-surface);
    backdrop-filter: blur(24px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    z-index: calc(var(--z-modal) + 2000);
    animation: contextMenuFadeIn 0.15s ease-out;
    transform-origin: top left;
}

.chat-context-menu ul {
    list-style: none;
    margin: 8px 0;
    padding: 0;
}

.chat-context-menu li {
    padding: 10px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text);
    transition: background var(--transition-fast);
}

.chat-context-menu li i {
    width: 20px;
    font-size: 16px;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.chat-context-menu li:hover {
    background: var(--bg-hover);
}

.chat-context-menu li:hover i {
    color: var(--primary);
}

/* Разделитель */
.chat-context-menu .divider {
    height: 1px;
    background: var(--border);
    margin: 6px 12px;
    padding: 0;
    cursor: default;
}

/* Анимация появления */
@keyframes contextMenuFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Светлая тема */
body.light-theme .chat-context-menu {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 0, 0, 0.12);
    box-shadow: var(--shadow-md);
}

body.light-theme .chat-context-menu li {
    color: #1e2a3a;
}

body.light-theme .chat-context-menu li i {
    color: #5f6c7a;
}

body.light-theme .chat-context-menu li:hover {
    background: rgba(0, 0, 0, 0.05);
}

body.light-theme .chat-context-menu li:hover i {
    color: var(--primary);
}

/* Уважение prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .chat-context-menu {
        animation: none;
    }
}


/* Стили для элемента приглашения в группу */
.chat-item.invite-item .invite-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--primary);
    flex-shrink: 0;
    overflow: hidden;
}

.chat-item.invite-item .group-avatar {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
}

.chat-item.invite-item .chat-name-text i {
    margin-right: 6px;
    font-size: 14px;
}