/* Запрет выделения текста во всем интерфейсе */
* {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Разрешаем выделение только в текстовых полях ввода */
textarea,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
.message-text,
.message-bubble,
.user-name,
.category-name,
.modal-body * {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Для сообщений разрешаем выделение, но только внутри бабла */
.message-bubble {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Запрещаем выделение в кнопках и интерактивных элементах */
button,
.btn,
.user-item,
.category-header,
.modal-user-item,
.forward-preview,
.reply-preview,
.file-item,
.user-info-modal-content,
.chat-user-info {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Предотвращаем выделение при двойном клике */
* {
    -webkit-tap-highlight-color: transparent;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    overflow: hidden;
}

/* Предотвращаем мигание кнопок при загрузке */
.forward-btn,
.reply-btn,
.like-btn {
    opacity: 0 !important;
    visibility: visible;
    animation: none !important;
}

.message:hover .forward-btn,
.message:hover .reply-btn,
.message:hover .like-btn {
    opacity: 1 !important;
}

/* Страница входа */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: white;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.login-box h1 {
    text-align: center;
    color: #667eea;
    margin-bottom: 10px;
}

.login-box h2 {
    text-align: center;
    font-size: 18px;
    color: #666;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.login-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s;
}

.login-btn:hover {
    transform: translateY(-2px);
}

.error-message {
    background: #fee;
    color: #c33;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
}

.test-users {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
    text-align: center;
}

.test-users p {
    color: #666;
    font-size: 12px;
    margin-bottom: 10px;
}

.test-users ul {
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 20px;
}

.test-users li {
    color: #667eea;
    font-size: 14px;
}

/* Чат */
.chat-container {
    display: flex;
    height: 100vh;
    background: #f5f5f5;
    position: relative;
}

/* Левая колонка - изменяемая ширина */
.users-sidebar {
    width: 300px;
    min-width: 200px;
    max-width: 500px;
    background: white;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 5px rgba(0,0,0,0.05);
    position: relative;
    transition: none;
}

/* Ползунок для изменения размера */
.resize-handle {
    position: absolute;
    right: -4px;
    top: 0;
    width: 8px;
    height: 100%;
    background: transparent;
    cursor: col-resize;
    z-index: 10;
    transition: background 0.2s;
}

.resize-handle:hover {
    background: rgba(102, 126, 234, 0.3);
}

.resize-handle.active {
    background: rgba(102, 126, 234, 0.5);
}

/* Правая область чата */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
    min-width: 0;
}

.user-info {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    gap: 15px;
}

.avatar {
    width: 50px;
    height: 50px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
}

.user-details {
    flex: 1;
}

.username {
    font-size: 18px;
    font-weight: bold;
}

.logout-link {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 12px;
}

.logout-link:hover {
    color: white;
}

.users-list-title {
    padding: 15px 20px;
    background: #f8f9fa;
    font-weight: bold;
    color: #666;
    border-bottom: 1px solid #e0e0e0;
}

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

/* ========== УМЕНЬШЕННЫЕ ЭЛЕМЕНТЫ СПИСКА ПОЛЬЗОВАТЕЛЕЙ ========== */
.user-item {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
    animation: slideIn 0.3s ease-out;
    min-height: 52px;
}

.user-item .user-info-container {
    position: relative;
    padding-right: 0;
}

.user-item:hover {
    background: #f8f9fa;
    transform: translateX(2px);
}

.user-item.active {
    background: linear-gradient(90deg, #e3f2fd 0%, #f3e5f5 100%);
}

.user-item.active .user-name {
    color: #667eea;
}

.user-item.active .user-last-message {
    color: #764ba2;
}

.user-avatar {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    flex-shrink: 0;
    position: relative;
    font-size: 14px;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.user-avatar .avatar-text {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.user-info-container {
    flex: 1;
    position: relative;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding-right: 60px;
}

.user-name {
    font-weight: 600;
    font-size: 13px;
    color: #333;
    margin-bottom: 2px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-last-message {
    font-size: 11px;
    color: #999;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    padding-right: 0;
}

.user-last-message.no-messages {
    color: #ccc;
    font-style: italic;
}

.last-message-icon {
    font-size: 11px;
    flex-shrink: 0;
}

.last-message-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.last-message-time {
    position: absolute;
    right: 0;
    top: 0;
    font-size: 10px;
    color: #999;
    white-space: nowrap;
}

.unread-badge {
    position: relative;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #f44336 0%, #e91e63 100%);
    color: white;
    border-radius: 12px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: 10px;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Статус на аватаре */
.status-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    border: 1px solid white;
}

.status-indicator.status-online {
    color: #4caf50;
}

.status-indicator.status-away {
    color: #ff9800;
}

.status-indicator.status-offline {
    color: #9e9e9e;
}

/* Правая область чата */
.chat-header {
    padding: 14px 20px;
    background: white;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.chat-header h3 {
    color: #333;
    margin: 0;
    font-size: 16px;
}

.chat-header-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.chat-user-info {
    flex: 1;
    cursor: pointer;
    transition: opacity 0.2s;
}

.chat-user-info:hover {
    opacity: 0.8;
}

.chat-user-info:hover h3 {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 5px;
}

.chat-user-status {
    font-size: 12px;
    color: #666;
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.chat-user-status .status-icon {
    font-size: 10px;
}

.chat-user-status.status-online {
    color: #4caf50;
}

.chat-user-status.status-away {
    color: #ff9800;
}

.chat-user-status.status-offline {
    color: #9e9e9e;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    will-change: transform;
    backface-visibility: hidden;

    /* Первый слой — белая полупрозрачная вуаль.
       Второй слой — картинка.
       Оба растянутся на всю высоту контента синхронно. */
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0.75)),
        url('/img/chat-bg.png');
    background-size: cover, cover;
    background-position: center, center;
    background-repeat: no-repeat, no-repeat;

    position: relative;
    z-index: 0;
}


.empty-chat {
    text-align: center;
    color: #999;
    margin-top: 50px;
}

/* ========== РАЗДЕЛИТЕЛИ ДАТ ========== */
.message-date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 10px 0;
    gap: 10px;
}

.date-separator-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, #e0e0e0, transparent);
}

.date-separator-text {
    font-size: 10px;
    color: #999;
    background: #f5f5f5;
    padding: 2px 10px;
    border-radius: 20px;
    font-weight: 500;
    letter-spacing: 0.2px;
}

/* ========== УМЕНЬШЕННЫЕ СООБЩЕНИЯ ========== */
.message {
    display: flex;
    margin-bottom: 4px;
    animation: fadeIn 0.2s ease-out;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    position: relative;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

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

/* ========== ОБНОВЛЕННЫЙ БЛОК СООБЩЕНИЯ ========== */
.message-bubble {
    max-width: 65%;
    padding: 6px 10px;
    border-radius: 14px;
    position: relative;
    word-wrap: break-word;
    font-size: 13px;
    line-height: 1.3;
}

.message.sent .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received .message-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.message.received .message-bubble.unread {
    background: #fff3cd;
    border: 1px solid #ffc107;
}

/* Контейнер для содержимого сообщения (текст + файлы) */
.message-content {
    position: relative;
}

/* ========== НИЖНЯЯ ЧАСТЬ СООБЩЕНИЯ (кнопки + время/статус) ========== */
.message-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
    padding-top: 3px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    min-height: 28px;
}

.message.sent .message-footer {
    border-top-color: rgba(255, 255, 255, 0.15);
}

.message.received .message-footer {
    border-top-color: rgba(0, 0, 0, 0.06);
}

/* ========== КНОПКИ ДЕЙСТВИЙ ========== */
.message-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.message:hover .message-actions {
    opacity: 1;
}

.forward-btn,
.reply-btn,
.like-btn,
.reaction-btn,
.edit-btn {
    background: transparent;
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
    color: #888;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: none;
    position: relative;
}

.message.sent .forward-btn,
.message.sent .reply-btn,
.message.sent .like-btn,
.message.sent .reaction-btn,
.message.sent .edit-btn {
    color: rgba(255, 255, 255, 0.5);
}

.message.sent .forward-btn:hover,
.message.sent .reply-btn:hover,
.message.sent .like-btn:hover,
.message.sent .reaction-btn:hover,
.message.sent .edit-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.message.received .forward-btn,
.message.received .reply-btn,
.message.received .like-btn,
.message.received .reaction-btn,
.message.received .edit-btn {
    color: #999;
}

.message.received .forward-btn:hover,
.message.received .reply-btn:hover,
.message.received .like-btn:hover,
.message.received .reaction-btn:hover,
.message.received .edit-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #333;
}

.like-btn.liked {
    color: #e91e63 !important;
}

.like-count {
    font-size: 10px;
    font-weight: 600;
    margin-left: 2px;
}

/* ========== ВРЕМЯ И СТАТУС ПРОЧТЕНИЯ (всегда видны) ========== */
.message-meta-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.message-time {
    font-size: 10px;
    color: #999;
}

.message.sent .message-time {
    color: rgba(255, 255, 255, 0.7);
}

.read-status-container {
    display: inline-flex;
    align-items: center;
    animation: statusFadeIn 0.2s ease;
}

.read-status {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: -1px;
}

.read-status.read {
    color: #4caf50;
}

.message.sent .read-status.read {
    color: #81c784;
}

.read-status.unread {
    color: rgba(255, 255, 255, 0.5);
}

.message.received .read-status.unread {
    color: #aaa;
}

@keyframes statusFadeIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* ========== ИНФОРМАЦИЯ О ЛАЙКАХ ========== */
.likes-info {
    font-size: 11px;
    color: #e91e63;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid rgb(255 255 255 / 0%);
    cursor: pointer;
    display: inline-block;
}

.message.sent .likes-info {
    color: #ff80ab;
}

.message-text {
    font-size: 13px;
    line-height: 1.3;
}

/* ========== УМЕНЬШЕННОЕ ПОЛЕ ВВОДА ========== */
.message-input-area {
    padding: 8px 15px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 8px;
}

.message-input-area textarea {
    flex: 1;
    padding: 8px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    resize: none;
    font-family: inherit;
    font-size: 13px;
    transition: border-color 0.3s;
    min-height: 36px;
    max-height: 80px;
}

.message-input-area textarea:focus {
    outline: none;
    border-color: #667eea;
}

.send-btn {
    padding: 0 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    font-size: 13px;
    transition: transform 0.2s;
}

.send-btn:hover {
    transform: translateY(-2px);
}


/* ========== УМЕНЬШЕННЫЕ ФАЙЛЫ ========== */
.message-file {
    margin-top: 4px;
    padding: 6px;
    background: rgba(0,0,0,0.05);
    border-radius: 6px;
    transition: background 0.2s;
}

.message-file:hover {
    background: rgba(0,0,0,0.1);
}

.message.sent .message-file {
    background: rgba(255,255,255,0.15);
}

.message.sent .message-file .file-name {
    color: white;
}

.message.sent .message-file .file-size {
    color: rgba(255,255,255,0.7);
}

.file-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.file-icon-left {
    flex-shrink: 0;
}

.file-icon-left .file-type-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.file-details {
    flex: 1;
    min-width: 0;
}

.file-details .file-name {
    font-size: 12px;
    font-weight: 500;
    word-break: break-all;
    margin-bottom: 2px;
    color: #333;
}

.file-details .file-size {
    font-size: 10px;
    color: #666;
    margin-bottom: 4px;
}

.file-actions-bottom {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.file-actions-bottom .file-open-btn,
.file-actions-bottom .file-save-btn {
    padding: 2px 8px;
    font-size: 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.file-actions-bottom .file-open-btn {
    background: #4caf50;
    color: white;
}

.file-actions-bottom .file-open-btn:hover {
    background: #45a049;
    transform: translateY(-1px);
}

.file-actions-bottom .file-save-btn {
    background: #2196f3;
    color: white;
}

.file-actions-bottom .file-save-btn:hover {
    background: #0b7dda;
    transform: translateY(-1px);
}

.file-image-preview {
    max-width: 150px;
    max-height: 120px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 3px;
}

.file-image-preview:hover {
    transform: scale(1.02);
}

.file-download-btn {
    display: inline-block;
    margin-top: 3px;
    font-size: 11px;
    color: #667eea;
    text-decoration: none;
}

/* ========== УМЕНЬШЕННЫЕ КНОПКИ ДЕЙСТВИЙ (старые стили для совместимости) ========== */
.message-actions-old {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 2px;
    margin-top: 1px;
    padding-top: 1px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.message:hover .message-actions-old {
    opacity: 1;
}

.message.sent .message-actions-old {
    border-top-color: rgba(255, 255, 255, 0.15);
}

.message.received .message-actions-old {
    border-top-color: rgba(0, 0, 0, 0.06);
}

.forward-btn::after,
.reply-btn::after,
.like-btn::after,
.reaction-btn::after,
.edit-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 10px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 1000;
}

.forward-btn:hover::after,
.reply-btn:hover::after,
.like-btn:hover::after,
.reaction-btn:hover::after,
.edit-btn:hover::after {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}
.reply-btn:hover::after,
.like-btn:hover::after {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

.forward-btn::before,
.reply-btn::before,
.like-btn::before {
    display: none;
}

/* ========== УМЕНЬШЕННЫЕ ОТВЕТЫ И ПЕРЕСЫЛКИ ========== */
.message-reply-preview {
    background: rgba(0, 0, 0, 0.08);
    border-left: 3px solid #667eea;
    border-radius: 6px;
    padding: 4px 8px;
    margin-bottom: 4px;
    transition: all 0.2s;
    cursor: pointer;
}

.message-reply-preview:hover {
    background: rgba(0, 0, 0, 0.12);
    transform: translateX(2px);
}

.message.sent .message-reply-preview {
    background: rgba(255, 255, 255, 0.15);
}

.message.sent .message-reply-preview:hover {
    background: rgba(255, 255, 255, 0.22);
}

.reply-preview-header-text {
    font-size: 10px;
    color: #667eea;
    margin-bottom: 2px;
    font-weight: 500;
}

.message.sent .reply-preview-header-text {
    color: #bb86fc;
}

.reply-preview-content-text {
    font-size: 11px;
    color: #666;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message.sent .reply-preview-content-text {
    color: rgba(255, 255, 255, 0.8);
}

/* Информация о лайках */
.likes-info {
    font-size: 11px;
    color: #e91e63;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid rgb(255 255 255 / 0%);
    cursor: pointer;
    display: inline-block;
}

.message.sent .likes-info {
    text-align: right;
    color: #ff80ab;
}

.likes-info:hover {
    text-decoration: underline;
}

/* Список лайкнувших пользователей */
.likes-users-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.likes-user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 8px;
    transition: background 0.2s;
}

.likes-user-item:hover {
    background: #e3f2fd;
}

.likes-user-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 16px;
}

.likes-user-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

/* Превью загрузки файла */
.file-preview {
    opacity: 0.8;
    animation: fadeIn 0.3s;
}

.file-preview-content {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 200px;
}

.file-icon {
    flex-shrink: 0;
}

.file-icon .file-type-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.upload-progress {
    margin-top: 8px;
    height: 4px;
    background: rgba(0,0,0,0.1);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4caf50, #8bc34a);
    width: 0%;
    transition: width 0.3s ease;
}

/* Загрузка сообщений */
.loading-messages {
    text-align: center;
    color: #999;
    padding: 20px;
    font-style: italic;
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    transition: background 0.2s;
}

.modal-close:hover {
    background: rgba(255,255,255,0.2);
}

.modal-body {
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.modal-user-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-user-item {
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-user-item:hover {
    background: #e3f2fd;
    transform: translateX(5px);
}

.modal-user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.modal-user-name {
    flex: 1;
    font-weight: 500;
}

.modal-user-list-title {
    margin-bottom: 10px;
    font-weight: bold;
    color: #666;
}

.select-user-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.select-user-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.no-users {
    text-align: center;
    color: #999;
    padding: 20px;
}

/* Превью пересылки */
.forward-preview {
    background: #f8f9fa;
    border-radius: 12px;
    margin: 0 15px 8px 15px;
    border: 1px solid #e0e0e0;
    overflow: hidden;
    animation: slideDown 0.3s ease;
    flex-shrink: 0;
}

.reply-preview {
    background: #f8f9fa;
    border-radius: 12px;
    margin: 0 15px 8px 15px;
    border: 1px solid #e0e0e0;
    overflow: hidden;
    animation: slideDown 0.3s ease;
    flex-shrink: 0;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.forward-preview-header,
.reply-preview-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.forward-preview-icon,
.reply-preview-icon {
    font-size: 14px;
}

.forward-preview-title,
.reply-preview-title {
    flex: 1;
    font-size: 12px;
    font-weight: 500;
}

.forward-preview-cancel,
.reply-preview-cancel {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.forward-preview-cancel:hover,
.reply-preview-cancel:hover {
    background: rgba(255,255,255,0.4);
    transform: scale(1.1);
}

.forward-preview-content,
.reply-preview-content {
    padding: 10px 12px;
}

.forward-preview-text,
.reply-preview-text {
    font-size: 12px;
    color: #555;
    line-height: 1.4;
    margin-bottom: 6px;
    background: white;
    padding: 6px;
    border-radius: 6px;
    border-left: 3px solid #667eea;
}

.forward-preview-files,
.reply-preview-files {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.forward-preview-file,
.reply-preview-file {
    font-size: 11px;
    padding: 4px 6px;
    background: white;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #666;
}

.forward-file-icon .file-type-icon,
.reply-file-icon .file-type-icon {
    width: 18px;
    height: 18px;
    vertical-align: middle;
}

.forward-file-name,
.reply-file-name {
    flex: 1;
    font-size: 11px;
}

/* Индикаторы режимов */
.forward-mode-indicator,
.reply-mode-indicator {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    margin-top: 6px;
    animation: fadeIn 0.3s;
}

.cancel-forward-mode,
.cancel-reply-mode {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 2px 8px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 10px;
    transition: all 0.2s;
}

.cancel-forward-mode:hover,
.cancel-reply-mode:hover {
    background: rgba(255,255,255,0.4);
    transform: scale(1.05);
}

/* Подсветка сообщения */
.highlight-message .message-bubble {
    animation: highlightPulse 0.5s ease 3;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.5);
}

@keyframes highlightPulse {
    0% { box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(102, 126, 234, 0); }
    100% { box-shadow: 0 0 0 0 rgba(102, 126, 234, 0); }
}

/* Уведомления */
.notifications-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    position: relative;
    margin-left: auto;
}

.notifications-btn:hover {
    background: rgba(0,0,0,0.05);
    transform: scale(1.1);
}

.notifications-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: #f44336;
    color: white;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.notifications-panel {
    position: absolute;
    top: 60px;
    right: 20px;
    width: 320px;
    max-height: 400px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    z-index: 1000;
    overflow: hidden;
    transform: translateY(-20px);
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.notifications-panel.active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.notifications-header {
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notifications-header h4 {
    margin: 0;
    font-size: 16px;
}

.notifications-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
}

.notifications-list {
    max-height: 350px;
    overflow-y: auto;
}

.notification-item {
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

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

.notification-icon {
    font-size: 20px;
}

.notification-content {
    flex: 1;
}

.notification-text {
    font-size: 13px;
    color: #333;
    margin-bottom: 4px;
}

.notification-time {
    font-size: 10px;
    color: #999;
}

.notifications-empty {
    padding: 30px;
    text-align: center;
    color: #999;
}

/* Drag & Drop */
.chat-area.drag-over {
    position: relative;
    background: rgba(33, 150, 243, 0.1);
}

.chat-area.drag-over::after {
    content: "📎 Перетащите файлы сюда для отправки";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(33, 150, 243, 0.9);
    color: white;
    padding: 20px 40px;
    border-radius: 10px;
    font-size: 18px;
    font-weight: bold;
    z-index: 1000;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.message-input-area.drag-over-input {
    border: 2px dashed #2196F3;
    background: rgba(33, 150, 243, 0.1);
    border-radius: 8px;
}

/* Тост-уведомления */
.custom-toast-notification,
.file-notification,
.drag-notification {
    animation: toastFadeOut 2.5s forwards;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    pointer-events: none;
    z-index: 10001;
}

@keyframes toastFadeOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(20px); }
    15% { opacity: 1; transform: translateX(-50%) translateY(0); }
    85% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-20px); visibility: hidden; }
}

/* Анимация лайка */
@keyframes likeFly {
    0% {
        opacity: 1;
        transform: scale(0.5) translateY(0);
    }
    50% {
        opacity: 1;
        transform: scale(1.2) translateY(-30px);
    }
    100% {
        opacity: 0;
        transform: scale(0.8) translateY(-80px);
    }
}

/* Информация о пользователе */
.user-info-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1001;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.user-info-modal.active {
    display: flex;
}

.user-info-modal-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.user-info-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
    position: relative;
}

.user-info-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.2s;
}

.user-info-close:hover {
    background: rgba(255,255,255,0.4);
    transform: scale(1.1);
}

.user-info-avatar {
    text-align: center;
    padding: 20px;
}

.user-info-avatar img {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid white;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: transform 0.2s;
}

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

.user-info-avatar .default-avatar {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
    color: white;
    margin: 0 auto;
    border: 4px solid white;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
}

.user-info-details {
    padding: 20px;
}

.user-info-detail-item {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.user-info-detail-item label {
    display: block;
    font-size: 11px;
    color: #999;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-info-detail-item .value {
    font-size: 16px;
    color: #333;
    font-weight: 500;
}

.user-info-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 13px;
}

.user-info-status.status-online {
    background: #e8f5e9;
    color: #4caf50;
}

.user-info-status.status-away {
    background: #fff3e0;
    color: #ff9800;
}

.user-info-status.status-offline {
    background: #f5f5f5;
    color: #9e9e9e;
}

.avatar-zoom-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 1002;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.avatar-zoom-modal.active {
    display: flex;
}

.avatar-zoom-modal img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.current-user-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.current-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.current-user-avatar .avatar-text {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.2);
    font-size: 24px;
    font-weight: bold;
    color: white;
}

/* ========== ОСТАЛЬНЫЕ СТИЛИ (СОХРАНЕНЫ) ========== */
.users-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.users-list-title {
    font-weight: bold;
    color: #666;
    margin: 0;
    padding: 0;
    font-size: 13px;
}

.toggle-contacts-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    white-space: nowrap;
}

.toggle-contacts-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.toggle-contacts-btn.active {
    background: linear-gradient(135deg, #ff0000 0%, #ff9191 100%);
}

/* Стили для категорий */
.category-container {
    margin: 0;
    border-bottom: 1px solid #f0f0f0;
}

.category-header {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    background: #fafafa;
    transition: background 0.2s;
}

.category-header:hover {
    background: #f0f0f0;
}

.category-toggle {
    font-size: 12px;
    color: #667eea;
    width: 20px;
    text-align: center;
}

.category-name {
    flex: 1;
    font-weight: 600;
    font-size: 13px;
    color: #333;
}

.category-count {
    font-size: 11px;
    color: #999;
}

.category-content {
    background: #fff;
}

.category-user-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #f5f5f5;
}

.category-user-item:hover {
    background: #f8f9fa;
}

.small-avatar {
    width: 30px;
    height: 30px;
    font-size: 12px;
}

.category-user-name {
    font-size: 13px;
    color: #333;
}

/* Индикатор набора текста */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #667eea;
    padding: 3px 0;
    animation: fadeIn 0.3s ease;
}

.typing-indicator .typing-dots {
    display: flex;
    gap: 3px;
    align-items: center;
}

.typing-indicator .typing-dot {
    width: 6px;
    height: 6px;
    background: #667eea;
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out;
}

.typing-indicator .typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.typing-indicator .typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator .typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

.chat-user-status .typing-indicator {
    margin-left: 8px;
    display: inline-flex;
}

.typing-text {
    font-size: 12px;
    color: #667eea;
    font-style: italic;
}

/* Статус прочтения */
.read-status-container {
    margin-left: 6px;
    display: inline-flex;
    align-items: center;
}

.read-status {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: -1px;
}

.read-status.read {
    color: #4caf50;
}

.read-status.unread {
    color: rgba(255, 255, 255, 0.6);
}

.message.received .read-status.unread {
    color: #999;
}

@keyframes statusFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.read-status-container {
    animation: statusFadeIn 0.2s ease;
}

@keyframes checkmarkAppear {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.read-status-container {
    animation: checkmarkAppear 0.2s ease-out;
    display: inline-flex;
    align-items: center;
}

.read-status.read {
    color: #FFFFFF;
    font-weight: 500;
    letter-spacing: -1px;
}

.read-status.unread {
    color: #999;
    opacity: 0.7;
    font-weight: normal;
}

@media (prefers-color-scheme: dark) {
    .read-status.read {
        color: #81c784;
    }
    
    .read-status.unread {
        color: #aaa;
    }
}

.user-files-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    margin-left: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    letter-spacing: 0.3px;
}

.user-files-btn:hover {
    background: linear-gradient(135deg, #7b8ff7 0%, #8b5ec7 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(102, 126, 234, 0.4);
}

.user-files-btn:active {
    transform: translateY(0px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* Обёртка для кнопок в шапке */
.chat-header-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-left: auto;
}

/* Модальное окно файлов */
.files-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.files-modal.active {
    display: flex;
}

.files-modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.3s ease;
}

.files-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid #e0e0e0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px 16px 0 0;
    color: white;
}

.files-modal-header h3 {
    margin: 0;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.files-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.files-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.files-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.files-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 10px;
    transition: all 0.2s ease;
    border: 1px solid #e9ecef;
}

.file-item:hover {
    background: #fff;
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.file-item-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
}

.file-item-icon img {
    width: 34px;
    height: 34px;
    object-fit: contain;
}

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

.file-item-name {
    font-weight: 500;
    color: #333;
    margin-bottom: 3px;
    word-break: break-all;
    font-size: 13px;
}

.file-item-meta {
    display: flex;
    gap: 14px;
    font-size: 11px;
    color: #888;
}

.file-item-size, .file-item-date {
    display: flex;
    align-items: center;
    gap: 4px;
}

.file-item-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.file-item-actions button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.file-item-open {
    color: #667eea;
}

.file-item-open:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: scale(1.05);
}

.file-item-download {
    color: #4caf50;
}

.file-item-download:hover {
    background: rgba(76, 175, 80, 0.1);
    transform: scale(1.05);
}

.file-item-show-message {
    color: #ff9800;
}

.file-item-show-message:hover {
    background: rgba(255, 152, 0, 0.12);
    transform: scale(1.1);
}

.files-empty {
    text-align: center;
    padding: 30px;
    color: #888;
}

.files-empty span {
    font-size: 40px;
    display: block;
    margin-bottom: 12px;
}

.files-loading {
    text-align: center;
    padding: 30px;
    color: #667eea;
}

.files-count-badge {
    background: rgba(102, 126, 234, 0.2);
    border-radius: 20px;
    padding: 2px 8px;
    font-size: 11px;
    margin-left: 8px;
}

/* Кнопка скрытия чата */
.user-name-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 6px;
    position: relative;
    z-index: 1;
}

.hide-chat-btn {
    background: none;
    border: none;
    color: #ccc;
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    transition: all 0.2s;
    opacity: 0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
    line-height: 1;
    transform: translateY(14px);
}

.user-item:hover .hide-chat-btn {
    opacity: 1;
}

.hide-chat-btn:hover {
    background: #ff4444;
    color: white;
    transform: translateY(14px) scale(1.1);
}

/* Тост-уведомления */
.custom-toast-notification {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #4caf50;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    z-index: 10000;
    font-size: 13px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    animation: slideUp 0.3s ease, fadeOut 0.5s ease 2s forwards;
    white-space: nowrap;
}

.custom-toast-notification.error {
    background: #f44336;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes fadeOut {
    to { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* ========== АДАПТАЦИЯ ДЛЯ МОБИЛЬНЫХ ========== */
@media (max-width: 768px) {
    .users-sidebar {
        min-width: 150px;
        max-width: 350px;
    }
    
    .user-last-message {
        max-width: 120px;
    }
    
    .last-message-text {
        font-size: 10px;
    }
    
    .last-message-time {
        font-size: 9px;
    }
    
    .file-image-preview {
        max-width: 120px;
        max-height: 100px;
    }
    
    .attach-btn {
        padding: 0 10px;
        font-size: 15px;
    }
    
    .file-icon-left .file-type-icon {
        width: 28px;
        height: 28px;
    }
    
    .forward-btn,
    .reply-btn,
    .like-btn {
        width: 22px;
        height: 22px;
        font-size: 10px;
    }
    
    .message-actions {
        gap: 2px;
    }
    
    .notifications-panel {
        width: 280px;
        right: 10px;
    }
    
    .message-reply-preview {
        padding: 4px 8px;
    }
    
    .reply-preview-header-text {
        font-size: 10px;
    }
    
    .reply-preview-content-text {
        font-size: 11px;
    }
    
    .message-bubble {
        max-width: 75%;
        font-size: 12px;
        padding: 5px 8px;
    }
    
    .message-text {
        font-size: 12px;
    }
    
    .messages-container {
        padding: 6px 8px;
        gap: 4px;
    }
    
    .message {
        margin-bottom: 3px;
    }
    
    .date-separator-text {
        font-size: 9px;
        padding: 2px 8px;
    }
    
    .message-date-separator {
        margin: 8px 0;
        gap: 8px;
    }
    
    .user-item {
        padding: 6px 10px;
        min-height: 44px;
    }
    
    .user-avatar {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }
    
    .user-name {
        font-size: 12px;
    }
    
    .user-last-message {
        font-size: 10px;
    }
    
    .chat-header {
        padding: 10px 14px;
    }
    
    .chat-header h3 {
        font-size: 14px;
    }
    
    .message-input-area {
        padding: 6px 10px;
        gap: 6px;
    }
    
    .message-input-area textarea {
        font-size: 12px;
        padding: 6px 8px;
        min-height: 32px;
        max-height: 60px;
    }
    
    .send-btn {
        padding: 0 12px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .forward-btn,
    .reply-btn,
    .like-btn {
        width: 20px;
        height: 20px;
        font-size: 9px;
    }
    
    .like-count {
        font-size: 8px;
        margin-left: 1px;
    }
    
    .message-bubble {
        max-width: 80%;
        padding: 4px 8px;
        font-size: 11px;
    }
    
    .message-text {
        font-size: 11px;
    }
    
    .message-meta {
        font-size: 9px;
    }
    
    .read-status {
        font-size: 9px;
    }
}

@media (max-width: 250px) {
    .last-message-icon {
        display: none;
    }
}

/* Темная тема */
@media (prefers-color-scheme: dark) {
    .date-separator-text {
        background: #2d2d2d;
        color: #aaa;
    }
    
    .date-separator-line {
        background: linear-gradient(90deg, transparent, #444, transparent);
    }
}

/* Кнопка смайликов */
.emoji-btn {
    padding: 0 05px;
    background: #f0f0f0;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.emoji-btn:hover {
    background: #e0e0e0;
    transform: scale(1.05);
}

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

/* Адаптация для мобильных */
@media (max-width: 480px) {
    .emoji-btn {
        padding: 0 5px;
        font-size: 16px;
    }
}

.search-container input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}
.search-container #searchClearBtn {
    color: #999;
    transition: color 0.2s;
}
.search-container #searchClearBtn:hover {
    color: #333;
}

.delete-btn {
    background: transparent;
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
    color: #888;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: none;
    position: relative;
}

.message.sent .delete-btn {
    color: rgba(255, 255, 255, 0.5);
}

.message.sent .delete-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ff4444;
}

.message.received .delete-btn {
    color: #999;
}

.message.received .delete-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #ff4444;
}

.chat-header-avatar[title]:hover {
    transform: scale(1.05);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.chat-header-avatar img {
    transition: filter 0.15s ease;
}

.chat-header-avatar[title]:hover img {
    filter: brightness(1.05);
}

.chat-header-avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
    font-weight: bold;
    /* Сглаживание изображения при масштабировании */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: auto;
    /* Устраняем проблемы с рендерингом в некоторых браузерах */
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .chat-header-avatar {
        width: 40px;
        height: 40px;
    }
}

.chat-header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
    /* Максимально мягкое сглаживание */
    image-rendering: auto;
    image-rendering: smooth;
    image-rendering: high-quality;
    /* Микроразмытие убирает «лестницу» на мелких исходниках */
    filter: blur(0.2px);
    /* Округление через GPU — лучше сглаживает границы */
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Модалка загрузки файлов */
.upload-modal .modal-content {
    max-width: 550px;
}
.upload-file-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 10px;
}
.upload-file-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 6px;
    border: 1px solid #eee;
    transition: background 0.2s;
}
.upload-file-item:hover {
    background: #f1f3f5;
}
.upload-file-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
}
.upload-file-icon img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}
.upload-file-info {
    flex: 1;
    min-width: 0;
}
.upload-file-name {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.upload-file-size {
    font-size: 11px;
    color: #888;
}
.upload-file-status {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}
.upload-file-progress {
    margin-top: 4px;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
}
.upload-file-progress-bar {
    height: 100%;
    width: 0%;
    background: #4caf50;
    border-radius: 2px;
    transition: width 0.2s;
}
.upload-file-remove {
    background: transparent;
    border: none;
    color: #999;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}
.upload-file-remove:hover {
    background: #ffebee;
    color: #f44336;
}
.btn-secondary {
    background: #e0e0e0;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}
.btn-secondary:hover {
    background: #d0d0d0;
}
.btn-primary {
    background: #4caf50;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}
.btn-primary:hover {
    background: #43a047;
}
.btn-primary:disabled {
    opacity: 0.6;
    cursor: default;
}
#uploadStatusMessage {
    margin-top: 8px;
    font-size: 13px;
    color: #333;
    text-align: center;
}

.modal.drag-over-modal {
    border: 2px dashed #4caf50;
    background: rgba(76, 175, 80, 0.1);
}

/* Drag & Drop на модальное окно загрузки */
.upload-modal.drag-over-modal {
    border: 2px dashed #4caf50;
    background: rgba(76, 175, 80, 0.05);
}
.upload-modal.drag-over-modal .modal-content {
    border: 2px dashed #4caf50;
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.3);
}
/* Анимация для индикатора загрузки */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Анимация для появления новых сообщений при подгрузке */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Стиль для индикатора загрузки */
.loading-messages {
    text-align: center;
    padding: 15px;
    color: #999;
    font-size: 13px;
    font-style: italic;
    animation: fadeIn 0.3s ease;
}

/* Анимация для новых сообщений при подгрузке */
.message.loading-new {
    animation: slideInUp 0.3s ease;
}

/* ----- Анимация лайка от собеседника ----- */
@keyframes likePulse {
    0% {
        transform: scale(1);
        background-color: rgba(255, 0, 0, 0);
        box-shadow: 0 0 0 0 rgba(255, 0, 0, 0);
    }
    30% {
        transform: scale(1.04);
        background-color: rgba(255, 0, 0, 0.08);
        box-shadow: 0 0 20px 5px rgba(255, 0, 0, 0.15);
    }
    60% {
        transform: scale(1);
        background-color: rgba(255, 0, 0, 0.03);
        box-shadow: 0 0 10px 2px rgba(255, 0, 0, 0.05);
    }
    100% {
        transform: scale(1);
        background-color: rgba(255, 0, 0, 0);
        box-shadow: 0 0 0 0 rgba(255, 0, 0, 0);
    }
}

/* Эффект для сообщения, получившего лайк от собеседника */
.message.like-animated .message-bubble {
    animation: likePulse 0.9s ease;
    position: relative;
    z-index: 1;
}

/* Дополнительно – пульсация сердечка (если хотите выделить именно иконку) */
.message.like-animated .like-btn {
    animation: heartBeat 0.6s ease;
}

@keyframes heartBeat {
    0% { transform: scale(1); }
    30% { transform: scale(1.4); }
    60% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

/* ========== СТРОКА РЕАКЦИЙ ПОД СООБЩЕНИЕМ ========== */
.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.message.sent .message-reactions {
    border-top-color: rgba(255, 255, 255, 0.15);
}

.reaction-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid transparent;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1.4;
    color: inherit;
}

.reaction-chip:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: scale(1.05);
}

.reaction-chip.active {
    background: #e0e7ff;
    border-color: #6366f1;
    color: #4f46e5;
}

.message.sent .reaction-chip {
    background: rgba(255, 255, 255, 0.18);
    color: inherit;
}

.message.sent .reaction-chip:hover {
    background: rgba(255, 255, 255, 0.28);
}

.message.sent .reaction-chip.active {
    background: rgba(255, 255, 255, 0.35);
    border-color: rgba(255, 255, 255, 0.7);
}

.reaction-count {
    font-size: 11px;
    font-weight: 600;
}



.reaction-btn.reacted {
    background: rgba(99, 102, 241, 0.15);
}

/* ========== КНОПКА РЕАКЦИИ (в стиле «Ответить»/«Переслать») ========== */
.reaction-btn {
    background: transparent;
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: #888;                   /* ← тот же серый, что у reply/forward */
}

.reaction-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #333;
}

.message.sent .reaction-btn {
    color: rgba(255, 255, 255, 0.5);   /* серый на своих сообщениях */
}

.message.sent .reaction-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

/* Активное состояние больше не выделяем цветом —
   эмодзи внутри и так показывает, какая реакция у пользователя */

.message.sent .reaction-btn.reacted {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

/* ========== ПАНЕЛЬ ВЫБОРА РЕАКЦИИ ========== */
.reaction-picker {
    position: fixed;
    z-index: 10050;
    background: white;
    border-radius: 24px;
    padding: 6px 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18), 0 1px 3px rgba(0, 0, 0, 0.08);
    display: flex;
    gap: 2px;
    animation: reactionPickerIn 0.15s ease;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

@keyframes reactionPickerIn {
    from { opacity: 0; transform: translateY(4px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.reaction-picker-item {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 50%;
    transition: transform 0.15s, background 0.15s;
    line-height: 1;
}

.reaction-picker-item:hover {
    transform: scale(1.35);
    background: rgba(99, 102, 241, 0.1);
}

.reaction-picker-item:active {
    transform: scale(1.1);
}

@media (max-width: 480px) {
    .reaction-picker-item { font-size: 20px; padding: 3px 5px; }
    .reaction-chip { font-size: 11px; padding: 2px 6px; }
}

/* ========== КАРАНДАШ РЕДАКТИРОВАНИЯ ========== */
.edit-msg-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-right: 6px;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
    color: #999;
    flex-shrink: 0;
}


/* ========== МЕТКА «ИЗМЕНЕНО» ========== */
.message-edited {
    font-size: 10px;
    color: #999;
    font-style: italic;
    margin-right: 6px;
    user-select: none;
    white-space: nowrap;
}

.message.sent .message-edited {
    color: rgba(255, 255, 255, 0.65);
}

/* ========== КНОПКА «ПРОКРУТИТЬ ВНИЗ» ========== */
.scroll-to-bottom-btn {
    position: absolute;
    bottom: 90px;
    right: 24px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.45),
                0 2px 6px rgba(0, 0, 0, 0.1);
    z-index: 200;
    font-size: 22px;
    line-height: 1;
    padding: 0;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.scroll-to-bottom-btn.visible {
    display: flex;
    animation: scrollBtnAppear 0.22s ease;
}

@keyframes scrollBtnAppear {
    from { opacity: 0; transform: scale(0.7) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.scroll-to-bottom-btn:hover {
    transform: translateY(-2px) scale(1.06);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.6),
                0 3px 8px rgba(0, 0, 0, 0.12);
}

.scroll-to-bottom-btn:active {
    transform: translateY(0) scale(0.94);
}

.scroll-to-bottom-btn .scroll-arrow {
    display: inline-block;
    font-weight: 700;
    transform: translateY(-1px);
    pointer-events: none;
}

/* Бейдж с количеством новых сообщений */
.scroll-to-bottom-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    border-radius: 50%;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.5);
    pointer-events: none;
    animation: badgePop 0.25s ease;
}

@keyframes badgePop {
    from { transform: scale(0.4); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

/* Адаптив */
@media (max-width: 768px) {
    .scroll-to-bottom-btn {
        width: 40px;
        height: 40px;
        bottom: 80px;
        right: 16px;
        font-size: 18px;
    }
    .scroll-to-bottom-badge {
        min-width: 20px;
        height: 20px;
        font-size: 10px;
    }
}

#chatWrapper {
    position: relative; 
}

/* ========== КНОПКА ПРИКРЕПЛЕНИЯ ========== */
.attach-btn {
    padding: 0 12px;
    background: #f0f0f0;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;

    /* Центрируем SVG внутри кнопки */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #555;               /* цвет обводки SVG через currentColor */
    flex-shrink: 0;
}

.attach-btn .attach-icon {
    width: 20px;
    height: 20px;
    display: block;
    pointer-events: none;
}

.attach-btn:hover {
    background: #e0e0e0;
    transform: scale(1.05);
    color: #333;
}

.attach-btn:active {
    transform: scale(0.96);
}

/* Адаптив */
@media (max-width: 768px) {
    .attach-btn {
        padding: 0 10px;
    }
    .attach-btn .attach-icon {
        width: 18px;
        height: 18px;
    }
}