:root {
    --bg-dark: #0f111a;
    --bg-sidebar: #ffffff;
    --chat-received: #f1f3f9;
    --chat-sent: #0d6efd;
    --top-nav-height: 60px;
    --sidebar-width: 320px;
}

body {
    background: #f8f9fa;
    height: 100vh;
    overflow: hidden;
    font-family: 'Inter', -apple-system, sans-serif;
}

.app-wrapper {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Топ-меню в темном стиле для контраста */
.top-nav {
    height: var(--top-nav-height);
    background: var(--bg-dark);
    z-index: 1000;
}

.bg-dark-soft {
    background: #232735 !important;
}

.logo-circle {
    width: 35px;
    height: 35px;
    background: #0d6efd;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

/* Основной контент */
.main-content {
    display: flex;
    flex-grow: 1;
    height: calc(100vh - var(--top-nav-height));
}

/* Сайдбар */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    display: flex;
    flex-direction: column;
}

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

.chat-item {
    transition: 0.2s;
    cursor: pointer;
    border-radius: 12px;
    margin: 0 8px;
}

.chat-item:hover {
    background: #f8f9fa;
}

.chat-item.active {
    background: #eef2ff;
    color: #0d6efd;
}

/* Аватары */
.avatar,
.avatar-sm {
    background: #ddd;
    border-radius: 12px;
    flex-shrink: 0;
}

.avatar {
    width: 45px;
    height: 45px;
    position: relative;
}

.avatar-sm {
    width: 32px;
    height: 32px;
}

.online::after {
    content: '';
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border: 2px solid white;
    border-radius: 50%;
}

/* Окно чата */
.chat-window {
    flex-grow: 1;
    background: white;
}

.chat-header {
    height: 64px;
}

.chat-body {
    background: #fdfdfd;
    overflow-y: auto;
}

/* Сообщения */
.msg-bubble {
    max-width: 70%;
    border-radius: 18px;
    font-size: .95rem;
    padding: 8px 16px;
    /* Добавляем отступы: 8px сверху/снизу, 16px по бокам */
    word-wrap: break-word;
    /* Чтобы длинные слова не вылезали за край */
}

.msg-received .msg-bubble {
    background: var(--chat-received);
    border-bottom-left-radius: 4px;
}

.msg-sent .msg-bubble {
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.2);
}

/* Поле ввода */
.input-wrapper {
    background: #f8f9fa;
    border-radius: 20px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    /* Центрирует иконки, инпут и кнопку по вертикали */
}

/* Тест */
.msg-sent,
.msg-received {
    display: flex;
    width: 100%;
    margin-bottom: 15px;
    /* Отступ между сообщениями */
}

.msg-sent {
    justify-content: flex-end;
}

.msg-received {
    justify-content: flex-start;
}

/* Исправленный пузырек */
.msg-bubble {
    max-width: 70%;
    min-width: 40px;
    /* Чтобы короткие сообщения (ок, ❤️) не были слишком мелкими */
    border-radius: 18px;
    font-size: .95rem;
    padding: 8px 16px;
    word-wrap: break-word;
    position: relative;
    /* Убираем лишние флекс-свойства, если они были */
    flex-grow: 0;
    flex-shrink: 0;
}

.msg-sent .msg-bubble {
    background: var(--chat-sent);
    color: white;
    /* Текст на синем фоне должен быть белым */
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.2);
}

.msg-received .msg-bubble {
    background: var(--chat-received);
    color: inherit;
    border-bottom-left-radius: 4px;
}

/* Конец */

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    /* ЗАПРЕЩАЕТ кнопке сжиматься или растягиваться */
}

.cursor-pointer {
    cursor: pointer;
}

.smaller {
    font-size: 0.8rem;
}

/* Скроллбар */
.custom-scrollbar::-webkit-scrollbar {
    width: 5px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #eee;
    border-radius: 10px;
}

/* Адаптивность для мобильных устройств (ширина меньше 768px) */
@media (max-width: 767.98px) {
    .sidebar {
        width: 100% !important;
        /* Список чатов на весь экран */
        display: flex;
    }

    .chat-window {
        display: none !important;
        /* Прячем окно чата по умолчанию */
        position: fixed;
        top: var(--top-nav-height);
        left: 0;
        width: 100%;
        height: calc(100vh - var(--top-nav-height));
        z-index: 1050;
        background: white;
    }

    /* Когда чат открыт, добавляем этот класс через JS */
    .chat-window.mobile-active {
        display: flex !important;
    }

    /* Скрываем поиск в топ-баре на мобилках, чтобы влез логотип */
    .search-bar {
        display: none !important;
    }
}

body,
.app-wrapper {
    /* dvh подстраивается под появление/скрытие клавиатуры и панелей */
    height: 100dvh;
    overflow: hidden;
}

/* Безопасная зона снизу (для iPhone X и новее) */
.chat-footer {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom)) !important;
    background: white;
}

/* Чтобы контент не прыгал при появлении клавиатуры */
@media (max-height: 500px) {
    .top-nav {
        display: none;
    }

    /* Скрываем топ-бар если мало места */
}

.logo-circle {
    width: 40px;
    /* Настройте размер под вашу навигацию */
    height: 40px;
    background-color: #fff;
    /* Или любой другой фоновый цвет круга */
    border-radius: 30%;
    /* Делает контейнер идеально круглым */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    /* Обрезает всё, что выходит за границы круга */
}

.nav-logo-img {
    width: 130%;
    /* Занимает 80% ширины круга */
    height: 130%;
    /* Занимает 80% высоты круга */
    object-fit: contain;
    /* Сохраняет пропорции логотипа без искажений */
}

.logo-squircle {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f5ece4;
    /* Цвет фона под логотипом */

    /* Магия сквиркла через маску */
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://w3.org' width='80' height='80' viewBox='0 0 80 80'%3E%3Cpath d='M0 40C0 12.7 12.7 0 40 0s40 12.7 40 40-12.7 40-40 40S0 67.3 0 40z'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://w3.org' width='80' height='80' viewBox='0 0 80 80'%3E%3Cpath d='M0 40C0 12.7 12.7 0 40 0s40 12.7 40 40-12.7 40-40 40S0 67.3 0 40z'/%3E%3C/svg%3E");
    mask-size: contain;
    mask-repeat: no-repeat;
    -webkit-mask-size: contain;
    -webkit-mask-repeat: no-repeat;
}

/* Жирный текст для новых сообщений */
.chat-item.unread-chat .text-truncate {
    color: var(--chat-sent) !important;
    font-weight: 600 !important;
}

/* Синяя точка-индикатор */
.unread-dot {
    width: 8px;
    height: 8px;
    background-color: #007bff;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Эффект для времени */
.unread-chat .smaller {
    color: #007bff !important;
}

#search-results {
    max-height: 400px;
    /* Фиксированная высота */
    overflow-y: auto;
    /* Прокрутка внутри */
    scrollbar-width: thin;
}

/* Улучшаем вид элементов списка */
.hover-bg:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.1);
}

.cursor-pointer {
    cursor: pointer;
}

/* Контейнер кнопки "Вниз" */
.scroll-down-btn {
    position: absolute;
    right: 20px;
    bottom: 80px;
    /* Чуть выше футера с вводом сообщения */
    width: 40px;
    height: 40px;
    background-color: white;
    color: #007bff;
    /* Основной цвет вашей темы */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s ease;
    opacity: 1;
}

/* Эффект при наведении */
.scroll-down-btn:hover {
    background-color: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* Класс для скрытия кнопки */
.scroll-down-btn.d-none {
    display: none !important;
}

/* Иконка внутри */
.scroll-down-btn i {
    font-size: 1.2rem;
    line-height: 0;
}