﻿/* chat.css */
/* ///////////////////////////////////////////////////////////////////////////////////////////////// */

/* --- Контейнер всего чата --- */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background-image: url('/images/chat-background.webp');
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    position: relative;
    transition: box-shadow 0.2s ease-in-out;
}

    .chat-container.is-active {
        cursor: text;
        /* Добавляем яркую тень, чтобы показать фокус */
        box-shadow: 0 0 0 4px rgba(88, 150, 49, 0.7);
        z-index: 10; /* Поднимаем его над другими неактивными элементами */
    }

/* --- Заголовок с названием чата --- */
.group-name-header {
    height: 35px;
    width: 100%;
    background-image: url('/images/chat-header-background.webp');
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    border-bottom: 1px solid grey;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    /* Добавляем отступы по бокам */
    padding: 5px 5px;
    gap: 8px;
}
/* <<< НОВЫЙ КЛАСС: Аватар в шапке >>> */
.group-header-avatar {
    width: 34px; /* Делаем его чуть меньше высоты шапки */
    height: 34px;
    border-radius: 50%; /* Круглый */
    flex-shrink: 0; /* Чтобы не сжимался */
    margin-right: 25px;
    /* Градиент по умолчанию */
    background-image: radial-gradient(circle at center, #C1D5C0, #D0F0C0);
    /* Свойства для отображения картинки, когда она будет */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.group-name-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    /* Для обрезки длинных названий */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 10px;
}

/* ======================================================= */
/* === СТИЛИ ДЛЯ КНОПОК В ШАПКЕ ЧАТА (React-версия) === */
/* ======================================================= */

/* 1. Базовый общий стиль для всех кнопок в шапке */
.chat-header-button {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid #ccc;
    background-color: transparent;
    border-radius: 20%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    /* transition должен быть объявлен здесь, чтобы работать для всех изменений */
    transition: all 0.3s ease;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.8), -2px -2px 5px rgba(255, 255, 255, 0.8);
    position: relative;
    overflow: visible;
}

    /* Настройка иконок внутри кнопок */
    .chat-header-button img {
        width: 100%;
        height: 100%;
        object-fit: contain;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }

    /* 2. КНОПКА "ДОБАВИТЬ В КОНТАКТЫ" (.js-add-contact-btn) */
    .chat-header-button.js-add-contact-btn {
        opacity: 1;
        visibility: visible;
        /* Удлиняем время для opacity, чтобы затухание было заметным */
        transition: opacity 0.5s ease-out, background-color 0.2s ease, transform 0.2s ease;
    }

        /* Эффект наведения (только если не идет процесс удаления) */
        .chat-header-button.js-add-contact-btn:not(.removing):hover {
            background-color: rgb(156, 200, 45); /* Зеленый */
            border: 1px solid grey;
            transform: scale(1.05);
        }

    /* 3. КНОПКА "УБРАТЬ СО СТОЛА" (.js-remove-from-table-btn) */
    .chat-header-button.js-remove-from-table-btn:hover {
        background-color: rgb(255, 127, 39); /* Оранжевый */
        border: 1px solid grey;
        transform: scale(1.05);
    }

    /* 4. СОСТОЯНИЯ АНИМАЦИИ ДЛЯ REACT */

    /* Состояние плавного исчезновения (когда React добавляет класс .removing) */
    .chat-header-button.js-add-contact-btn.removing {
        opacity: 0 !important; /* Принудительно уводим в ноль */
        pointer-events: none; /* Блокируем клики */
        transform: scale(0.8); /* Немного уменьшаем при исчезновении для красоты */
    }

    /* Если кнопка должна быть полностью скрыта ( display: none ) */
    .chat-header-button.js-add-contact-btn.is-hidden {
        display: none !important;
    }


/* ===================================================================== */
/* ===                   БЛОК СТИЛЕЙ ДЛЯ СООБЩЕНИЙ                   === */
/* ===================================================================== */

/* --- Главный контейнер для всех сообщений --- */
.chat-messages {
    display: flex;
    flex-direction: column-reverse;
    padding: 10px 12px;
    overflow-y: auto;
    flex-grow: 1;
    scrollbar-width: auto; /* или 'auto', или 'none' */
    scrollbar-color: #999 #e0e0e0; /* Цвет ползунка и цвет трека (фона) */
}

/* --- Обертка для ОДНОЙ строки (аватар + пузырь) --- */
.message-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 8px; /* Отступ между аватаром и пузырем */
    width: 100%;
    margin-top: 2px; /* Большой отступ по умолчанию */
    transition: opacity 0.3s ease, transform 0.3s ease, max-height 0.3s ease, padding 0.3s ease, margin 0.3s ease;
}

.message-wrapper:not(.is-continuation) {
    margin-top: 12px;
}

    .message-wrapper.is-continuation .sender-avatar {
        visibility: hidden;
    }

    .message-wrapper.is-continuation .sender-name {
        display: none;
    }

/* --- Аватар отправителя --- */
.sender-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-image: radial-gradient(circle at center, #C1D5C0, #D0F0C0);
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
.table-chat-area .sender-avatar {
    width: 50px;
    height: 50px;
}

/* --- "Пузырь" с контентом сообщения --- */
.chat-message {
    padding-top: 5px; /* <-- Верхний отступ */
    padding-bottom: 3px; /* <-- Нижний отступ */
    padding-left: 8px; /* <-- Левый отступ */
    padding-right: 8px; /* <-- Правый отступ */
    background: rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-width: 0;
    align-self: flex-start; /* Чтобы пузырь не растягивался по высоте без причины */
}

/* --- Имя отправителя внутри пузыря  --- */
.message-header {
    margin-bottom: 0px;
}

.sender-name {
    color: #004d00;
    font-weight: 600;
    font-size: 14px;
}
.table-chat-area .sender-name {
    /* И увеличь ему шрифт */
    font-size: 18px; /* Размер для чата на столе */
}
/* ===================================================================== */
/* ===         НОВЫЕ СТИЛИ ДЛЯ ВСЕХ СОСТОЯНИЙ СООБЩЕНИЙ            === */
/* ===================================================================== */

/* --- 1. ОБЩИЙ СТИЛЬ ДЛЯ ИКОНКИ СТАТУСА --- */
.message-status-icon {
    font-style: normal;
    margin-right: 3px; /* Отступ от текста времени */
    font-size: 1em; /* Делаем иконки чуть крупнее */
    color: #28a745; /* Цвет по умолчанию  */
    font-weight: 700;
    text-shadow: none;
    font-family: "SF Mono", "Consolas", "Menlo", "Monaco", "Liberation Mono", "Courier New", monospace;
}


/* --- 2. СТИЛИ ДЛЯ КОНКРЕТНЫХ СОСТОЯНИЙ --- */

/* Состояние "Отправляется" */
.chat-message.is-pending {
    opacity: 0.6;
}
    /* Для часиков можно задать отдельный стиль, если нужно */
    .chat-message.is-pending .message-status-icon {
        font-weight: normal; /* Часики лучше выглядят нежирными */
        font-size: 0.9em;
        vertical-align: middle;
        color: gray;
    }

/* Состояние "Ошибка отправки" */
.chat-message.is-failed {
    background: rgba(255, 224, 224, 0.7);
}

    .chat-message.is-failed .sender-name,
    .chat-message.is-failed .chat-message-text {
        color: #b71c1c;
    }
    /* Для иконки ошибки мы можем использовать псевдо-элемент,
       так как у нее нет своего текста, либо задать его в JS.
       Этот подход с CSS чище. */
    .chat-message.is-failed .message-timestamp::before {
        content: '❗ ';
        color: #d32f2f;
        font-weight: bold;
    }

/* ===================================================================== */
/* ===        <<< НАЧАЛО ИЗМЕНЕНИЙ: НОВЫЕ СТИЛИ ДЛЯ КОНТЕНТА >>>       === */
/* ===================================================================== */

/* Общий контейнер для всего контента (картинок и текста) */
.message-content-wrapper {
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: 15px;
}

/* Контейнер для картинок (если их несколько) */
.message-image-container {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px; /* Отступ между картинками */
    justify-content: center;
}

/* Обертка для ОДНОЙ картинки и ее времени */
.image-wrapper {
    position: relative; /* Для позиционирования времени */
    align-self: flex-start; /* Чтобы картинка не растягивалась по ширине, если она узкая */
    max-width: 100%; /* Но и не вылезала за пределы */
}

/* Сама картинка */
.chat-message-image {
    display: block;
    border-radius: 8px;
    max-width: 100%; /* Страховка, чтобы не вылезал за пузырь */
    align-self: flex-start; /* Чтобы узкая картинка не растягивалась */
    object-fit: contain; /* Гарантирует, что картинка впишется, а не обрежется */
}

/* Элемент с текстом (общие стили) */
.chat-message-text, .chat-message-text-with-image {
    font-size: 14px;
    color: #222;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Дополнительный отступ для текста под картинками */
.chat-message-text-with-image {
    margin-top: 6px;
}

/* 
   Этот селектор означает: 
   "Найди .chat-message-text, который находится где-то внутри .table-chat-area"
*/
.table-chat-area .chat-message-text,
.table-chat-area .chat-message-text-with-image {
    /* И увеличь ему шрифт */
    font-size: 18px;
}

/* Время (общие стили) */
.message-timestamp {
    position: absolute; /* <<< Вырываем из потока */
    bottom: -2px; /* <<< Прижимаем к нижнему краю родителя */
    right: 0; /* <<< Прижимаем к правому краю родителя */

    font-size: 0.75rem;
    color: #999;
    white-space: nowrap;
    display: flex;
    align-items: center;
}

/* Стилизация времени, когда оно находится ПОВЕРХ картинки */
.image-wrapper .message-timestamp {
    position: absolute;
    bottom: 5px;
    right: 7px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.6rem;
    pointer-events: none; /* Чтобы не мешало кликам по картинке */
}

/* ===================================================================== */
/* ===                      <<< КОНЕЦ ИЗМЕНЕНИЙ >>>                    === */
/* ===================================================================== */


/* ===================================================================== */
/* ===                ФОРМА ВВОДА И МЕНЮ ПРИКРЕПЛЕНИЯ                === */
/* ===================================================================== */

.chat-input-form {
    display: flex;
    align-items: stretch;
    padding: 3px;
    border-top: 1px solid #ccc;
    background: #fafafa;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
}

.attach-file-btn {
    border: none;
    background: url('/images/clipart-file.webp') no-repeat center center;
    background-size: contain;
    width: 25px;
    height: 25px;
    border-radius: 30%;
    cursor: pointer;
    background-color: transparent;
    flex-shrink: 0;
    align-self: flex-end;
}
.table-chat-area .attach-file-btn {
    /* И увеличь ему размеры */
    width: 36px;
    height: 36px;
}

.chat-input {
    flex: 1;
    resize: none;
    border: none;
    background: transparent;
    border-radius: 0px;
    padding: 3px 10px;
    font-size: 14px;
    min-height: 20px;
    max-height: 100px;
    overflow-y: auto;
    margin: 0;
    box-sizing: border-box;
    outline: none;
    box-shadow: none;
}
.table-chat-area .chat-input {
    font-size: 18px;
}

.chat-send {
    border: none;
    background: url('/images/Send1.webp') no-repeat center center;
    background-size: contain;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    align-self: flex-end;
}
.table-chat-area .chat-send {
    
    width: 36px;
    height: 36px;
}

.attach-menu {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 8px;
    width: 150px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10;
    padding: 5px;
}

.photo-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 5px;
    text-align: left;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.15s ease;
    box-sizing: border-box;
}

    .photo-btn:hover {
        background-color: #f0f0f0;
    }

.photo-icon {
    content: url('/images/image-icon.webp');
    width: 24px;
    height: 24px;
    border-radius: 10%;
    flex-shrink: 0;
}


/* ===================================================================== */
/* ===                ПРЕДПРОСМОТР ИЗОБРАЖЕНИЙ ПЕРЕД ОТПРАВКОЙ         === */
/* ===================================================================== */

.photo-modal-in-chat {
    display: none;
    padding: 5px;
    background-color: rgba(245, 245, 245, 0.98);
    border-top: 1px solid #ddd;
    z-index: 10;
    box-sizing: border-box;
    width: 100%;
    /* Включаем горизонтальный скролл */
    overflow-x: auto;
    overflow-y: hidden;
    /* Настройка скроллбара (опционально для красоты) */
    scrollbar-width: thin;
    scrollbar-color: #999 #eee;
    min-height: 120px;
}

.modal-content-in-chat {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
    /* КЛЮЧЕВОЕ: Запрещаем перенос на новую строку */
    flex-wrap: nowrap;
    /* Контейнер должен растягиваться по ширине контента */
    width: max-content;
    min-width: 100%;
    box-sizing: border-box;
}

.preview-image-wrapper {
    position: relative;
    display: flex;
    flex-shrink: 0;
    box-sizing: border-box;
}

.remove-photo-btn {
    position: absolute;
    top: 0;
    right: 0;
    width: 25px;
    height: 25px;
    font-size: 24px;
    background-color: rgba(100,100,100,0.6);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s ease;
    z-index: 20;
    box-sizing: border-box;
    padding-bottom: 3px;
}

    .remove-photo-btn:hover {
        background-color: rgba(255,0,0,0.8);
    }

    .remove-photo-btn svg {
        width: 16px;
        height: 16px;
    }

.preview-image-in-chat {
    display: block;
    height: 100px; /* Фиксированная высота */
    width: auto; /* Ширина подстраивается автоматически */
    object-fit: contain;
    border-radius: 4px;
    border: 1px solid #ccc;
    background-color: #fff;
}


/* ===================================================================== */
/* ===                      ВСПОМОГАТЕЛЬНЫЕ СТИЛИ                    === */
/* ===================================================================== */

/* --- Контекстное меню сообщения (глобальное) --- */
.message-context-menu {
    display: none;
    position: fixed;
    transform-origin: top left;
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 9000;
    min-width: 180px;
    overflow: hidden;
    padding: 0;
}

.context-menu-button {
    width: 100%;
    padding: 10px 12px;
    border: none;
    background-color: rgb(240 240 240);
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    color: black;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 0;
}

    .context-menu-button:hover {
        background-color: rgb(210 210 210);
    }

.context-menu-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
    flex-shrink: 0;
}

/* --- Локальное модальное окно подтверждения (внутри чата) --- */
.confirm-overlay-local {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(30, 30, 30, 0.75);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9000;
}

.confirm-modal-local {
    background-color: #ffffff;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.confirm-modal-local p {
    margin: 0 0 20px 0;
    font-size: 1.1rem;
    color: #333;
    line-height: 1.5;
}

.confirm-modal-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.confirm-btn {
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.confirm-no-btn {
    background-color: #f0f0f0;
    color: #555;
}

    .confirm-no-btn:hover {
        background-color: #e0e0e0;
    }

.confirm-yes-btn {
    background-color: #e74c3c;
    color: #ffffff;
}

    .confirm-yes-btn:hover {
        background-color: #c0392b;
    }

/* Контейнер для экземпляра чата в списке контактов (остался от старого кода) */
.chat-instance-container {
    overflow-y: auto;
    margin-top: 0px;
    border: 1px solid grey;
    border-top: none;
    border-radius: 5px;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    display: flex;
    flex-direction: column;

    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    /* Плавный переход для этих свойств */
    transition: opacity 0.5s ease, transform 0.5s ease, visibility 0s 0.5s;
}
    .chat-instance-container.visible {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        transition: opacity 0.5s ease, transform 0.5s ease, visibility 0s;
    }

/* Скрытый инпут для файлов (был у тебя, добавил в конец) */
.hidden-file-input {
    display: none;
}

/* Стили для спинера загрузки новых сообщений в чате */
.chat-loading-spinner {
    /* === ГЛАВНЫЕ ИЗМЕНЕНИЯ === */
    position: absolute; /* Вырываем из потока документа */
    top: 10%; /* Небольшой отступ сверху */
    left: 50%; /* Центрируем по горизонтали */
    transform: translateX(-50%); /* Точная центровка */
    z-index: 15; /* Убеждаемся, что он поверх сообщений */
    /* === СТИЛИ ДЛЯ КРАСОТЫ === */
    background-color: rgba(255, 255, 255, 0.8); /* Полупрозрачный фон */
    border-radius: 20px; /* Скругляем углы */
    padding: 5px 10px; /* Внутренние отступы */
    box-shadow: 0 2px 8px rgba(0,0,0,0.15); /* Небольшая тень */
    /* === ТВОИ СТАРЫЕ СТИЛИ (ОСТАЮТСЯ) === */
    display: flex;
    justify-content: center;
    align-items: center;
    height: 30px; /* Можно сделать чуть компактнее */
}

    /* Анимация самого кружочка остается без изменений */
    .chat-loading-spinner::after {
        content: '';
        width: 20px; 
        height: 20px;
        border: 2px solid rgba(0, 0, 0, 0.2);
        border-top-color: #333;
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- Блок стилей для редактирования сообщения --- */
/* Панель режима редактирования */
.edit-mode-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #fff;
    border-top: 1px solid #ccc; /* Отделяем от сообщений */
    border-left: 4px solid #004d00; /* Зеленая полоска слева */
    padding: 5px 10px;
    font-size: 0.9rem;
    color: #333;
    animation: slideUp 0.2s ease-out;
}

.edit-mode-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.edit-mode-title {
    color: #004d00;
    font-weight: 600;
    font-size: 0.8rem;
    margin-bottom: 2px;
}

.edit-mode-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #666;
    font-size: 0.85rem;
}

.edit-mode-close {
    /* --- Копируем стиль из contacts-modal-close --- */
    width: 30px;
    height: 30px;
    background-color: transparent;
    border: none;
    border-radius: 4px; /* Добавим небольшое скругление, чтобы вписывалось в чат */
    cursor: pointer;
    color: black;
    /* Размер шрифта чуть меньше, чем в контактах (там 40px), 
       чтобы не разрывать узкую панель редактирования */
    font-size: 36px;
    font-weight: normal;
    /* Центрирование крестика */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    padding-bottom: 6px; /* Визуальная поправка, чтобы крестик был по центру */
    flex-shrink: 0;
    transition: color 0.2s ease, background-color 0.2s ease;
    margin-left: 10px; /* Отступ от текста */
}

    .edit-mode-close:hover {
        background-color: red;
        color: white;
    }

@keyframes slideUp {
    from {
        transform: translateY(10px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Метка (изм.) */
.edited-mark {
    font-size: 0.85em;
    color: #888;
    margin-right: 4px;
    font-style: italic;
    vertical-align: baseline;
}

/* --- Блок стилей для ответа на сообщение --- */
/* --- Панель режима ОТВЕТА (над инпутом) --- */
.reply-mode-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #fff;
    border-top: 1px solid #ccc;
    border-left: 4px solid rgb(160 206 52); /* полоска слева */
    padding: 5px 10px;
    font-size: 0.9rem;
    color: #333;
    animation: slideUp 0.2s ease-out;
    z-index: 5; /* Чтобы не перекрывалось чем-то случайно */
}

.reply-mode-title {
    color: rgb(70 134 50);
    font-weight: bold;
    font-size: 0.8rem;
    margin-bottom: 2px;
}

/* --- Цитата внутри сообщения (пузыря) --- */
.message-reply-preview {
    display: block;
    margin-bottom: 5px;
    padding: 4px 8px;
    border-left: 3px solid rgb(160 206 52); /* черта */
    background-color: rgba(228 243 226); /* Легкий фон */
    border-radius: 4px;
    cursor: pointer; /* Чтобы можно было кликнуть и перейти */
    font-size: 0.85rem;
    max-width: 100%;
    overflow: hidden;
}

    .message-reply-preview:hover {
        background-color: rgba(191 226 186);
    }

.reply-preview-name {
    font-weight: bold;
    color: rgb(108 140 34);
    font-size: 0.8rem;
    margin-bottom: 2px;
}

.reply-preview-text {
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Эффект подсветки сообщения при переходе к нему */
.highlight-message {
    animation: highlightPulse 2s ease-out;
}

@keyframes highlightPulse {
    0% {
        background-color: rgba(255, 255, 0, 0.5);
        transform: scale(1.02);
    }

    100% {
        background-color: rgba(255, 255, 255, 0.4);
        transform: scale(1);
    }
}

/* --- Стили для окна выбора чатов для пересылки сообщения --- */
/* --- Оверлей пересылки сообщения (локальный для чата) --- */
.forward-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6); /* Чуть светлее, чем удаление */
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9000;
    animation: fadeIn 0.2s ease-out;
}

.forward-modal {
    background-color: #ffffff;
    width: 300px; /* Фиксированная ширина */
    max-width: 90%;
    max-height: 80%; /* Чтобы не вылезало за высоту чата */
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Чтобы скругления не обрезались */
}

.forward-header {
    padding: 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8f9fa;
}

.forward-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
}

.forward-close-btn {
    /* --- Копируем стиль из contacts-modal-close --- */
    width: 30px;
    height: 30px;
    background-color: transparent;
    border: none;
    border-radius: 4px; /* Добавим небольшое скругление, чтобы вписывалось в чат */
    cursor: pointer;
    color: black;
    /* Размер шрифта чуть меньше, чем в контактах (там 40px), 
       чтобы не разрывать узкую панель редактирования */
    font-size: 36px;
    font-weight: normal;
    /* Центрирование крестика */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    padding-bottom: 6px; /* Визуальная поправка, чтобы крестик был по центру */
    flex-shrink: 0;
    transition: color 0.2s ease, background-color 0.2s ease;
    margin-left: 10px; /* Отступ от текста */
}

    .forward-close-btn:hover {
        background-color: red;
        color: white;
    }

/* Контейнер списка контактов */
.forward-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 5px 0;
    background-color: #fff;
}

/* Упрощенный элемент контакта */
.forward-contact-item {
    display: flex;
    align-items: center;
    padding: 8px 15px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid #f0f0f0;
}

    .forward-contact-item:last-child {
        border-bottom: none;
    }

    .forward-contact-item:hover {
        background-color: #e9ecef;
    }

.forward-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-image: radial-gradient(circle at center, #C1D5C0, #D0F0C0);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    margin-right: 12px;
    flex-shrink: 0;
}

.forward-name {
    font-size: 0.95rem;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
}

/* Сообщение "Загрузка..." или "Нет контактов" */
.forward-message-placeholder {
    text-align: center;
    padding: 20px;
    color: #888;
    font-size: 0.9rem;
}

/* --- Панель режима ПЕРЕСЫЛКИ (над инпутом) --- */
.forward-mode-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #fff;
    border-top: 1px solid #ccc;
    border-left: 4px solid #ff9800; /* Оранжевая полоска */
    padding: 5px 10px;
    font-size: 0.9rem;
    color: #333;
    animation: slideUp 0.2s ease-out;
    z-index: 5;
}

.forward-mode-title {
    color: #ff9800; /* Оранжевый заголовок */
    font-weight: bold;
    font-size: 0.8rem;
    margin-bottom: 2px;
}

/* --- Стили для ПЕРЕСЛАННОГО сообщения --- */

    /* 3. Стилизуем пузырь */
    .message-wrapper.is-forwarded .chat-message {
        border-left: 4px solid #ff9800; /* Оранжевая полоска для акцента */
    }
/* Подзаголовок "Переслано от..." */
.forwarded-subheader {
    font-size: 0.8rem;
    color: rgb(255 127 39); /* Оранжевый, чтобы выделялось */
    font-style: italic;
    margin-bottom: 4px; /* Отступ до текста сообщения */
    display: flex;
    align-items: center;
    gap: 5px;
}

    /* Иконка стрелочки (картинка) перед текстом пересылки */
    .forwarded-subheader::before {
        content: ''; /* Очищаем текстовый контент */
        display: inline-block; /* Делаем блочным, чтобы задать размеры */
        /* Размеры иконки */
        width: 18px;
        height: 18px;
        /* Настройка фона */
        background-image: url('/images/forward.webp');
        background-size: contain; /* Вписываем картинку полностью */
        background-repeat: no-repeat;
        background-position: center;
        /* Выравнивание */
        vertical-align: text-bottom; /* Выравниваем относительно текста */
        opacity: 0.8; /* Можно слегка приглушить, если картинка слишком яркая */
    }

/* --- Блок "Пользователь заблокирован" --- */
.chat-blocked-message {
    padding: 15px;
    text-align: center;
    color: black;
    font-size: 0.95rem;
    font-weight: 500;
    background-color: #f8f9fa;
    border-top: 1px solid #ccc;
    flex-shrink: 0;
    user-select: none;
    /* Чтобы выглядело как системное сообщение */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 50px;
}

/* Контейнер для кнопки разблокировки (заменяет инпут) */
.chat-unblock-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    background-color: #f8f9fa;
    border-top: 1px solid #ccc;
    flex-shrink: 0;
}

.chat-unblock-btn {
    width: 100%;
    padding: 10px;
    background-color: white;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

    .chat-unblock-btn:hover {
        background-color: rgb(119 189 67);
        color: black;
        border-color: #333;
    }

/* Анимация подсветки сообщения при переходе по ссылке-ответу */
.message-wrapper.highlight-message {
    animation: highlightPulse 2s ease-out;
}

/* === СТИЛИ КНОПКИ НАЗАД В ОВЕРЛЕЕ ЛИМИТА === */
.quota-back-btn {
    width: 100%;
    height: 35px;
    padding: 0 10px;
    border: 1px solid #ccc !important;
    background-color: #e9ecef !important; /* Слегка серый фон */
    color: black !important;
    border-radius: 5px !important;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

/* Эффект наведения, полностью аналогичный кнопке "Создать" */
.quota-back-btn:hover {
    background-color: rgb(119 189 67) !important; /* Зеленый на ховер */
    border-color: #333 !important;
    color: white !important;
}

@keyframes highlightPulse {
    0% {
        background-color: rgba(255, 255, 0, 0.4); /* Светло-желтый */
        transform: scale(1.02); /* Легкое увеличение */
    }

    100% {
        background-color: transparent;
        transform: scale(1);
    }
}
