/* Основные стили */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
}

.container-fluid {
    height: 100vh;
}

/* Полностью убираем стандартную подсветку Bootstrap */
.form-control:focus,
.form-control:focus ~ .input-group-text {
    border-color: #ced4da !important; /* Оставляем серый цвет границы */
    box-shadow: none !important;
}

/* Общие стили для группы ввода */
.input-group.search-group,
.input-group.message-group {
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    background-color: white;
    transition: all 0.2s ease;
    padding: 2px;
    align-items: stretch;
}

/* Убираем границы у всех внутренних элементов */
.input-group.search-group > *,
.input-group.message-group > * {
    border: none !important;
    box-shadow: none !important;
    background: transparent;
}

/* Специальные стили для textarea */
.input-group.message-group #message-text {
    flex: 1;
    min-height: 25px;
    padding: 6px 10px;
    margin: 0;
}

/* Стили для кнопок внутри группы */
.input-group.search-group .btn,
.input-group.message-group .btn {
    padding: 0.375rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    transition: all 0.2s ease;
    border-radius: 0 !important;
    background: none !important;
}

/* Кнопка отмены редактирования (крестик) */
#cancel-edit-btn {
    color: #6c757d;
    padding: 0 0.5rem;
    margin: 0 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
}

#cancel-edit-btn:hover {
    color: #dc3545;
}

/* Кнопка отправки */
#send-btn {
    color: #0d6efd;
    padding: 0.0rem 1rem; /* Увеличиваем отступы */
    font-size: 1.2rem; /* Чуть увеличиваем размер иконки */
}

#send-btn:hover {
    color: #0b5ed7;
}

/* Кнопка смайлов */
#emoji-btn {
    padding: 0 0.75rem;
}

/* Фокус на всей группе */
.input-group.search-group:focus-within,
.input-group.message-group:focus-within {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Адаптация для мобильных устройств */
@media (max-width: 768px) {
    .input-group.search-group,
    .input-group.message-group {
        padding: 1px;
    }
    
    .input-group.message-group #message-text {
        padding: 6px 8px;
    }
    
    .input-group.search-group .btn,
    .input-group.message-group .btn {
        padding: 0.25rem 0.5rem;
    }
}

/* Список пользователей */
.bg-white {
    background-color: #ffffff !important;
}

.list-group {
    overflow-x: hidden !important; /* Запретить горизонтальный скролл */
}

.list-group-item .d-flex.flex-column.align-items-end {
    margin-left: auto;
    text-align: right;
}

.list-group-item .badge {
    margin-bottom: 2px;
}

.list-group-item {
    border-left: none;
    border-right: none;
    padding: 6px 15px;
    transition: all 0.2s ease;
}

/* Стили для активного чата */
.list-group-item.active {
    background: linear-gradient(250deg, #75c1ff, #9d4ff0) !important;
    color: white !important;
    border-color: transparent !important;
     border-radius: 4px;
    box-shadow: 0 4px 12px rgba(106, 17, 203, 0.3);
    transform: scale(1.02);
    z-index: 1;
    position: relative;
    transition: all 0.3s ease;
}

/* Иконки в активном чате */
.list-group-item.active .flex-shrink-0 i,
.list-group-item.active .text-muted {
    color: rgba(255, 255, 255, 0.9) !important;
}

/* Аватарки в активном чате */
.list-group-item.active .rounded-circle {
    box-shadow: 0 0 0 3px white, 0 0 0 6px rgba(106, 17, 203, 0.5);
}

/* Бейджи в активном чате */
.list-group-item.active .badge {
    background-color: white !important;
    color: #6a11cb !important;
}

.list-group-item:hover:not(.active) {
    background-color: #f8f9fa;
}

.list-group-item .flex-shrink-0 i {
    font-size: 1.2rem;
}

.list-group-item .position-relative {
    padding-right: 40px; /* Оставляем место для времени */
}

.list-group-item .position-absolute.end-0 {
    right: 15px; /* Отступ от правого края */
}

.list-group-item .badge {
    margin-left: 8px; /* Отступ от имени чата */
}

#chat-search-input {
    border-left: none;
}

.search-group .input-group-text {
    background-color: white;
    border-right: none;
}

.search-group:focus-within {
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
    border-radius: 0.25rem;
}

/* Область чата */
#messages {
    background-color: #f8f9fa;
    padding: 20px;
    overflow-y: auto;
    padding-top: 0 !important;
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f8f9fa;
}

#messages::-webkit-scrollbar {
    width: 8px;
}

#messages::-webkit-scrollbar-track {
    background: #f0f2f5;
}

#messages::-webkit-scrollbar-thumb {
    background-color: #c1c1c1;
    border-radius: 4px;
}

/* Сообщения */
.message {
    max-width: 75%;
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease-out;
    transition: background-color 0.2s ease;
}

.message-edited {
    font-size: 0.8em;
    color: #6c757d;
    text-align: right;
    margin-top: 2px;
    font-style: italic;
}

.message-info small .text-muted {
    font-size: 1.0em;
    color: #6c757d;
    font-style: italic;
}

/* Свои сообщения - более мягкий синий */
.message.sent {
    background-color: #e3f2fd; /* Светло-голубой */
    color: #333; /* Темный текст */
    margin-left: auto;
    border-bottom-right-radius: 4px;
    border: 1px solid #bbdefb; /* Граница для выделения */
}

/* Сообщения других - белый с легкой тенью */
.message.received {
    background-color: white;
    color: #333; /* Темный текст */
    margin-right: auto;
    border-bottom-left-radius: 4px;
    border: 1px solid #e0e0e0; /* Граница для выделения */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Эффект при наведении - более заметный */
.message.sent:hover {
    background-color: #d0e3fa; /* Чуть темнее при наведении */
    color: #333; /* Текст остается видимым */
}

.message.received:hover {
    background-color: #f5f5f5;
}

/* Информация о сообщении */
.message-info {
    font-size: 0.75rem;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #666; /* Серый цвет для информации */
}

/* Файлы в сообщениях */
.message-files {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    max-width: 100%; /* Занимает всю доступную ширину */
}

.message-files a {
    background-color: rgba(255, 255, 255, 0.15);
    border: none;
    padding: 6px 12px;
    border-radius: 18px;
    color: inherit;
    text-decoration: none;
    transition: background-color 0.2s;
    max-width: 100%; /* Максимальная ширина */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Для сообщений от других пользователей */
.message.received .message-files a {
    background-color: rgba(0, 0, 0, 0.1);
    color: #495057;
    white-space: normal; /* Разрешаем перенос текста */
    word-break: break-word; /* Переносим длинные слова */
    text-align: left;
    max-width: 400px; /* Увеличиваем максимальную ширину */
}

/* Для своих сообщений */
.message.sent .message-files a {
    background-color: rgba(0, 0, 0, 0.05);
    color: #333;
    white-space: normal;
    word-break: break-word;
    text-align: left;
    max-width: 400px; /* Увеличиваем максимальную ширину */
}

.message.sent .message-files a:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.message.received .message-files a:hover {
    background-color: rgba(0, 0, 0, 0.15);
}

/* Стили для textarea сообщения */
#message-text {
    resize: none; /* Отключаем ручное изменение размера */
    overflow-y: hidden; /* Скрываем прокрутку по умолчанию */
    min-height: 30px; /* Минимальная высота (как у кнопки) */
    max-height: 150px; /* Максимальная высота перед появлением прокрутки */
    line-height: 1.1;
    transition: height 0.2s ease-out;
    padding: 10px 15px;
}

/* Показываем тонкую прокрутку только при необходимости */
#message-text.has-scroll {
    overflow-y: auto;
}

/* Стилизация полосы прокрутки */
#message-text::-webkit-scrollbar {
    width: 6px;
}

#message-text::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

/* Для Firefox */
@supports (scrollbar-width: thin) {
    #message-text.has-scroll {
        scrollbar-width: thin;
        scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
    }
}

/* Стили для бейджей непрочитанных */
.badge {
    font-size: 0.7rem;
    padding: 3px 6px;
    min-width: 20px;
    text-align: center;
}

/* Бейджи, добавленные через PHP */
.unread-count.php-added {
    display: inline-block !important;
}

/* Бейджи, добавленные через JavaScript */
.unread-count.js-added {
}

.unread-count {
    font-size: 0.75rem;
    padding: 0.25em 0.4em;
    min-width: 1.5em;
}


/* Для общего чата */
.general-chat .badge {
    position: absolute;
    top: 10px;
    right: 15px;
}

/* Стили для контекстного меню */
#message-context-menu {
    display: none;
    z-index: 1000;
    min-width: 200px;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 0.375rem;
}

#message-context-menu .dropdown-item {
    padding: 0.25rem 1rem;
    cursor: pointer;
}

#message-context-menu .dropdown-item:hover {
    background-color: #f8f9fa;
}

#message-context-menu .dropdown-divider {
    margin: 0.25rem 0;
}

/* Стиль для выбранного сообщения */
.message.selected {
    background-color: rgba(0, 123, 255, 0.1);
}

/* Запрещаем выделение текста при открытии контекстного меню */
.message {
    user-select: none;
    -webkit-user-select: none;
}

.message-text blockquote {
    border-left: 3px solid #ddd;
    margin: 0.5em 0;
    padding-left: 1em;
    color: #666;
    font-style: italic;
    background-color: #f9f9f9;
    border-radius: 4px;
    padding: 8px 12px;
}

.reply-preview-content {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background-color: #f5f5f5;
    padding: 5px;
    border-radius: 3px;
    border-left: 3px solid #6c757d;
}

.reply-preview-content blockquote {
    margin: 0;
    padding: 0;
    border-left: none;
    background: none;
    font-style: normal;
    color: inherit;
}

/* Контейнер с именами файлов */
#file-names {
    margin-top: 8px; /* Отступ от кнопки */
    display: flex;
    flex-wrap: wrap;
    gap: 8px; /* Отступ между файлами */
    align-items: center;
    max-width: 70%;
}

.file-list-container {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
    max-width: 100%;
    overflow: hidden;
}

.file-item {
    display: inline-flex;
    align-items: center;
    background: #f0f0f0;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.9em;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.remove-file {
    color: #dc3545;
    margin-left: 5px;
    text-decoration: none;
    font-size: 0.9em;
}

.remove-file:hover {
    color: #b02a37;
}

.text-muted {
    color: #6c757d;
}
/* Стили для иконки статуса */
.message-status {
    position: absolute;
    right: 10px;
    bottom: 5px;
    z-index: 2; /* Чтобы было поверх сообщения */
}

.status-icon {
    font-size: 0.8rem;
    color: #90a4ae; /* Серо-голубой */
    cursor: pointer;
    transition: color 0.2s;
}

.status-icon:hover {
    color: #546e7a; /* Темнее при наведении */
}



/* Стили для попапа */
.read-status-popover {
    position: absolute;
    right: 0;
    bottom: 100%;
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000; /* Выше других элементов */
    min-width: 300px;
    font-size: 0.8rem;
    display: none; /* По умолчанию скрыт */
}

.read-status-header {
    font-weight: bold;
    margin-bottom: 5px;
    border-bottom: 1px solid #eee;
    padding-bottom: 3px;
}

.read-status-item {
    display: flex;
    justify-content: space-between;
    margin: 3px 0;
}

.reader-name {
    color: #333;
}

.read-time {
    color: #666;
    font-style: italic;
}

.general-chat .message.sent .status-icon {
    /* Специфичные стили для общего чата */
}

/* Убираем курсор и подсветку со всего сообщения */
.message.sent {
    cursor: default;
}

.message.sent:hover {
    background-color: inherit;
}

/* Адаптивность */
@media (max-width: 768px) {
    .message {
        max-width: 85%;
    }
    
    #messages {
        padding: 15px;
    }
    
    .message-input {
        padding: 12px;
    }
}

/* Стили для модального окна редактирования */
.icon-option {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50% !important;
}

.icon-option.active {
    background-color: #0d6efd;
    color: white;
}

/* Стили для заголовка чата */
#chat-with {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    min-height: 50px;
    font-size: 1.25rem;
}

/* Стили для кнопки редактирования в заголовке */
#chat-with .edit-group-btn {
    color: #6c757d;
    padding: 0.0rem;
    font-size: 1rem;
    border: none;
    background: none;
    transition: color 0.2s;
}

#chat-with .edit-group-btn:hover {
    color: #0d6efd;
}

/* Стили для списка участников с чекбоксами */
#edit-members-list {
    padding: 6px;
    background-color: #f8f9fa;
    border-radius: 5px;
    font-size: 0.9rem;
}

#edit-members-list .d-flex {
    padding: 8px;
    background-color: white;
    border-radius: 4px;
    margin-bottom: 5px;
}

/* Стили для переключателя модератора */
.form-switch .form-check-input {
    width: 2.0em;
    margin-left: 0px;
    margin-right: 8px;
    cursor: pointer;
}

.form-switch .form-check-label {
    cursor: pointer;
    font-size: 0.85rem;
    color: #6c757d;
}

.edit-group-btn, .view-members-btn {
    font-size: 0.875rem;
    padding: 0.0rem 0.0rem;
    color: #6c757d;
}
.edit-group-btn:hover, .view-members-btn:hover {
    color: #0d6efd;
}

/* Стиль для выбранного сообщения */
.message.selected {
    background-color: rgba(0, 123, 255, 0.1);
    border-left: 3px solid #0d6efd;
}

/* Стиль для превью ответа */
#reply-preview {
    border-left: 3px solid #0d6efd;
    font-size: 0.9em;
}

.reply-preview-content {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.message-text a {
    color: #0066cc;
    text-decoration: underline;
    cursor: pointer;
}

.message-text a:hover {
    text-decoration: none;
}

/* Стили для цитаты в сообщениях */
.message-text .quote {
    display: block;
    border-left: 3px solid #6c757d;
    padding: 8px 12px;
    margin: 8px 0;
    background-color: #f8f9fa;
    border-radius: 4px 4px 4px 4px;
    color: #555;
    font-style: italic;
    position: relative;
    overflow: hidden;
}

.message-text .quote::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: #6c757d;
}

.message.sent .message-text .quote {
    background-color: #e3f2fd;
    border-left-color: #0d6efd;
}

.message.sent .message-text .quote::before {
    background-color: #0d6efd;
}

.message.received .message-text .quote {
    background-color: #f8f9fa;
    border-left-color: #6c757d;
}

.message.received .message-text .quote::before {
    background-color: #6c757d;
}

/* Стиль для заголовка цитаты */
.quote-header {
    font-size: 0.8em;
    color: #6c757d;
    margin-bottom: 4px;
    font-weight: bold;
    display: flex;
    align-items: center;
}

.quote-header i {
    margin-right: 5px;
}

/* Стиль для содержимого цитаты */
.quote-content {
    color: #495057;
    font-size: 0.9em;
    line-height: 1.4;
}

/* Стиль для основного текста сообщения с цитатой */
.message-with-quote .message-content {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #dee2e6;
}

/* Стили для превью цитаты */
#reply-preview {
    background-color: #f8f9fa;
    border-left: 3px solid #0d6efd;
    padding: 6px 10px;
    margin-bottom: 8px;
    border-radius: 4px;
    position: relative;
}

.reply-preview-content {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #555;
    font-style: normal;
}

/* Стиль для цитирования в сообщениях */
.message-text blockquote {
    border-left: 2px solid #ddd;
    margin: 0.5em 0;
    padding-left: 1em;
    color: #777;
    font-style: italic;
}

.message-text .quote {
    display: block;
    border-left: 3px solid #6c757d;
    padding-left: 10px;
    margin: 5px 0;
    color: #6c757d;
    font-style: italic;
}

/* Превью цитаты */
#reply-preview {
    background-color: #f8f9fa;
    border-left: 3px solid #0d6efd;
    padding: 5px 10px;
    margin-bottom: 5px;
}

#reply-preview .reply-preview-content {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #6c757d;
}

/* Стили для списка участников */
.members-list {
    padding: 0.2rem;
}

.members-list .d-flex {
    padding: 0.2rem;
    border-radius: 0.25rem;
}

.members-list .d-flex:hover {
    background-color: #f8f9fa;
}

/* Иконки участников */
.members-list .bi-person-fill {
    font-size: 1.25rem;
    color: #6c757d;
}

/* Роли участников */
.members-list small.text-muted {
    font-size: 0.75rem;
}

/* Страницы входа/регистрации */
.auth-container {
    max-width: 400px;
}

.auth-card {
    border: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
}

.auth-card .card-body {
    padding: 2rem;
}

/* Аватарки */
.avatar-img {
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.2s;
}

.avatar-img:hover {
    transform: scale(1.05);
}

/* Превью аватарки в модальном окне */
#avatarPreview {
    object-fit: cover;
    cursor: pointer;
    border: 2px solid #dee2e6;
    margin: 10px 40px 10px 20px;
}

/* Кнопки управления аватаркой */
#changeAvatarBtn, #removeAvatarBtn {
    transition: all 0.2s;
}

#changeAvatarBtn:hover {
    background-color: #0d6efd;
    color: white;
}

#removeAvatarBtn:hover {
    background-color: #dc3545;
    color: white;
}    

/* Аватарки групп */
#groupAvatarPreview {
    object-fit: cover;
    border: 2px solid #dee2e6;
    margin: 10px 40px 10px 20px;
}

/* Кнопки управления аватаркой группы */
#changeGroupAvatarBtn, #removeGroupAvatarBtn {
    transition: all 0.2s;
}

#changeGroupAvatarBtn:hover {
    background-color: #0d6efd;
    color: white;
}

#removeGroupAvatarBtn:hover {
    background-color: #dc3545;
    color: white;
}

/* Общие стили для тонких полос прокрутки */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}
    
/* Стили для Emoji Picker Element */
.message-group {
    position: relative; /* Это создаст контекст для позиционирования emoji-picker */
}

#emoji-picker {
    position: absolute;
    left: 0;
    z-index: 1000;
    display: none;
    border-radius: 5px;
    margin-bottom: -85px;
    margin-left: -3px;
    background: #f5f5f5;
}

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


/* Контейнер с эмодзи */
.emoji-container {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    height: 100%;
    align-items: center;
    gap: 8px;
    padding-bottom: 5px; /* Для скроллбара */
}

/* Стили для отдельных эмодзи */
.emoji-item {
    flex: 0 0 auto;
    
    align-items: center;
    justify-content: center;
    font-size: 28px;
    min-width: 40px;
    height: 40px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    user-select: none;
}

.emoji-item:hover {
    background: #f0f0f0;
    transform: scale(1.1);
}

.emoji-item:active {
    transform: scale(0.95);
}

.emoji {
    font-size: 4.5em;
    vertical-align: middle;
    margin: 0 1px;
}

/* Подсветка найденного текста */
.highlight {
    background-color: #ffeb3b;
    padding: 0 0px;
    border-radius: 2px;
}

/* Подсветка сообщения при переходе */
.highlight-message {
    position: relative;
    z-index: 1;
    transition: all 0.5s ease;
}

.highlight-message::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(76, 175, 80, 0.15);
    border-radius: 8px;
    z-index: -1;
    animation: highlight-fade 5s ease-out forwards;
}

@keyframes highlight-fade {
    0% {
        background-color: rgba(76, 175, 80, 0.3);
        box-shadow: 0 0 10px rgba(76, 175, 80, 0.4);
    }
    100% {
        background-color: transparent;
        box-shadow: none;
    }
}

/* Для сообщений в режиме поиска */
.search-results-container .highlight-message::before {
    border-radius: 8px;
}

.search-results-container {
    border-bottom: 1px solid #eee;
    margin-bottom: 8px;
    }

/* Подсветка совпадений */
.bg-warning {
    background-color: #ffc107;
    padding: 0 2px;
    border-radius: 3px;
}

/* Стиль для имени файла */
.file-name {
    color: #6c757d;
    font-size: 0.9em;
    word-break: break-all;
}

.file-name i {
    margin-right: 5px;
}

/* Добавьте в файл style.css */
.chat-icon-container {
    cursor: pointer;
    transition: transform 0.2s;
}

.chat-icon-container:hover {
    transform: scale(1.1);
}

/* Адаптация для мобильных устройств */
@media (max-width: 768px) {
    .chat-header {
        flex-wrap: wrap;
    }
    .chat-header .input-group {
        width: 100%;
        margin-top: 10px;
    }
}

.user-info-btn {
    color: #6c757d;
    padding: 0.0rem;
    font-size: 1rem;
    transition: color 0.2s;
}

.user-info-btn:hover {
    color: #0d6efd;
}

#userInfoModal .avatar-lg {
    width: 100px;
    height: 100px;
    object-fit: cover;
}

.highlight-match {
    background-color: #ffeb3b;
    padding: 0 2px;
    border-radius: 3px;
    box-shadow: 0 0 2px rgba(0,0,0,0.3);
}

.message-text a {
    color: #0066cc;
    text-decoration: underline;
}

.message-text a:hover {
    text-decoration: none;
}

/* Стили для цитат в сообщениях */
.message-reply {
    border-left: 3px solid #6c757d;
    padding-left: 12px;
    margin: 8px 0;
}

.message-quote {
    background-color: #f8f9fa;
    padding: 6px;
    border-radius: 4px;
    margin-bottom: 8px;
    position: relative;
}

.quote-icon {
    position: absolute;
    left: 2px;
    
    color: #6c757d;
    background: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #dee2e6;
}

.quote-content {
    color: #6c757d;
    font-size: 0.9em;
    padding-left: 10px;
}

.message-answer {
    padding: 8px 0;
}

.highlight-match {
    background-color: #fff3cd;
    padding: 0 2px;
    border-radius: 3px;
}

.message-text a {
    color: #007bff;
    text-decoration: underline;
    word-break: break-all;
}

/* Общие стили для всех вложений */
.message-attachments {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Контейнер для всех типов вложений */
.attachment-container {
    position: relative;
    width: 250px; /* Фиксированная ширина */
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.attachment-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Общие стили для изображений и видео */
.attachment-thumbnail,
.attachment-image img,
.video-thumbnail {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
    cursor: pointer;
    background: #f5f5f5;
}

/* Специфичные стили для изображений */
.attachment-image img {
    object-fit: contain;
    max-height: 250px;
    background: #fff;
}

/* Специфичные стили для видео */
.video-container {
    position: relative;
    background: #000;
}

.video-thumbnail {
    height: 140px; /* Базовая высота для горизонтальных видео */
    object-fit: cover;
}

/* Вертикальные видео (9:16) */
.video-container.vertical {
    height: 250px;
    width: 140px;
}

.video-container.vertical .video-thumbnail {
    height: 100%;
    width: 100%;
}

/* Иконка воспроизведения */
.video-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 40px;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    transition: all 0.3s;
    opacity: 0.9;
}

.video-container:hover .video-play-icon {
    color: #fff;
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 1;
}

/* Стили для файлов (не изображения/видео) */
.attachment-file {
    width: 250px;
    background: #f5f5f5;
    padding: 10px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
}

.attachment-file:hover {
    background: #e9e9e9;
}

.attachment-file a {
    color: #333;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.file-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.file-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Иконки для разных типов файлов */
.file-icon[data-ext="pdf"] { background-image: url('icons/pdf-icon.svg'); }
.file-icon[data-ext="doc"] { background-image: url('icons/doc-icon.svg'); }
.file-icon[data-ext="docx"] { background-image: url('icons/docx-icon.svg'); }
/* и так далее для других типов файлов */

/* Адаптивность */
@media (max-width: 768px) {
    .attachment-container,
    .attachment-file {
        width: 200px;
    }
    
    .video-thumbnail {
        height: 112px; /* Сохраняем пропорции */
    }
    
    .video-container.vertical {
        height: 200px;
        width: 112px;
    }
}

.quoted-file {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    padding: 4px 8px;
    background: rgba(0,0,0,0.05);
    border-radius: 4px;
    font-size: 0.85em;
}

.quoted-file i {
    font-size: 1.1em;
}

.message-with-quote .quote {
    border-left: 3px solid #ddd;
    padding-left: 10px;
    margin-bottom: 8px;
    color: #666;
}

.message-with-quote .quote-header {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: bold;
    margin-bottom: 4px;
}

.btn-close-preview {
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 0.75rem;
}

.reply-files {
    font-size: 0.85rem;
    color: #6c757d;
}

.files-preview {
    font-size: 0.85rem;
    color: #6c757d;
}

.file-preview-item {
    margin-bottom: 0.25rem;
    padding: 0.25rem;
    background-color: #f8f9fa;
    border-radius: 3px;
    display: inline-block;
    margin-right: 0.5rem;
}

.file-preview-item i {
    margin-right: 0.25rem;
}

.message-loader {
    text-align: center;
    padding: 10px;
    background: rgba(255,255,255,0.8);
    position: sticky;
    top: 0;
    z-index: 10;
}

#messages {
    overflow-y: auto;
    height: calc(100vh - 200px); /* Подстройте под ваш интерфейс */
    position: relative;
}

.message {
    padding: 8px 12px;
    margin: 10px 0;
    border-radius: 8px;
    word-break: break-word;
}

/* Общие стили для обоих полей поиска */
.input-group.search-group,
.input-group.search-message-group {
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    background-color: white;
    transition: all 0.2s ease;
    align-items: stretch;
}

/* Специфичные стили для поля поиска чатов (слева) */
.input-group.search-group {
    height: 33px; /* Фиксированная высота как у поля поиска сообщений */
}

/* Специфичные стили для поля поиска сообщений (справа) */
.input-group.search-message-group {
    height: 33px;
}

/* Убираем границы у всех внутренних элементов */
.input-group.search-group > *,
.input-group.search-message-group > * {
    border: none !important;
    box-shadow: none !important;
    background: transparent;
}

/* Стили для input в обоих полях поиска */
.input-group.search-group input,
.input-group.search-message-group input {
    padding: 0.375rem 0.75rem;
    height: 100%;
}

/* Стили для иконки поиска */
.input-group.search-group .input-group-text,
.input-group.search-message-group .input-group-text {
    padding: 0 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
}

/* Фокус на всей группе */
.input-group.search-group:focus-within,
.input-group.search-message-group:focus-within {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Убираем стандартные стили Bootstrap для input-group */
.input-group.search-group .form-control,
.input-group.search-message-group .form-control {
    border-radius: 0;
}

.highlight-message {
    animation: highlight 2s;
    border-left: 3px solid #0d6efd;
    padding-left: 10px;
}

@keyframes highlight {
    0% { background-color: rgba(13, 110, 253, 0.2); }
    100% { background-color: transparent; }
}

.message-jump-btn {
    opacity: 0;
    transition: opacity 0.2s;
}

.message:hover .message-jump-btn {
    opacity: 1;
}

.search-mode {
    overflow-y: auto;
}

.search-results-header {
    position: sticky;
    top: 0px;
    z-index: 1000;
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    color: white;
    padding: 6px 16px;
    border-radius: 0px 0px 8px 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    
    
}

.search-results-header span {
    font-weight: 500;
    font-size: 15px;
}

.cancel-search-btn {
    color: white !important;
    padding: 3px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    background-color: rgba(255, 255, 255, 0.2);
    border: none;
}

.cancel-search-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.cancel-search-btn i {
    margin-right: 4px;
}


.message.search-result {
    margin: 10px;
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.search-result .jump-to-message-btn {
    opacity: 1 !important;
}

#search-results {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 1000;
    overflow-y: auto;
}

#search-results.show {
    display: block !important;
}

#messages.hidden {
    display: none;
}

#mailing-toggle.active {
    color: #fff;
    background-color: red;
    border-color: #ffc107;
}
