* {
    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: 15px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
    animation: slideIn 0.3s ease-out;
}

.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: 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;
    flex-shrink: 0;
    position: relative;
}

.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: 18px;
}

.user-info-container {
    flex: 1;
    position: relative;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    font-size: 15px;
    color: #333;
    margin-bottom: 4px;
}

.user-last-message {
    font-size: 12px;
    color: #999;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.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;
}

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

.unread-badge {
    background: linear-gradient(135deg, #f44336 0%, #e91e63 100%);
    color: white;
    border-radius: 12px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    flex-shrink: 0;
    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: 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;
}

.chat-header-content {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.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: 5px;
    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: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    will-change: transform;
    backface-visibility: hidden;
}

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

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

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

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

/* Сообщения */
.message {
    display: flex;
    margin-bottom: 8px;
    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: 60%;
    padding: 10px 15px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
}

.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-text {
    font-size: 14px;
    line-height: 1.4;
}

.message-meta {
    font-size: 11px;
    margin-top: 5px;
    opacity: 0.7;
}

.message.sent .message-meta {
    text-align: right;
    color: rgba(255,255,255,0.8);
}

.message.received .message-meta {
    text-align: left;
    color: #999;
}

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

/* Поле ввода */
.message-input-area {
    padding: 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 12px;
}

.message-input-area textarea {
    flex: 1;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.3s;
}

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

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

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

.attach-btn {
    padding: 0 15px;
    background: #f0f0f0;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.2s;
}

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

/* Сообщения с файлами */
.message-file {
    margin-top: 8px;
    padding: 10px;
    background: rgba(0,0,0,0.05);
    border-radius: 8px;
    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: 12px;
    align-items: flex-start;
}

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

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

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

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

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

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

.file-actions-bottom .file-open-btn,
.file-actions-bottom .file-save-btn {
    padding: 4px 10px;
    font-size: 11px;
    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: 200px;
    max-height: 150px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 5px;
}

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

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

/* ========== КНОПКИ НА СООБЩЕНИЯХ ========== */

/* Базовые стили для всех кнопок */
.forward-btn,
.reply-btn,
.like-btn {
    position: absolute;
    bottom: 8px;
    opacity: 0; /* Уже скрыты изначально */
    background: rgba(0, 0, 0, 0.65);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    z-index: 5;
    animation: none !important; /* ОТКЛЮЧАЕМ АНИМАЦИЮ ПОЛНОСТЬЮ */
}

/* Кнопка пересылки - самая правая */
.forward-btn {
    right: 8px;
}

/* Кнопка ответа - вторая справа */
.reply-btn {
    right: 48px;
}

/* Кнопка лайка - третья справа */
.like-btn {
    right: 88px;
    min-width: 32px;
    width: auto;
    padding: 0 10px;
    gap: 4px;
}

/* Показываем кнопки ТОЛЬКО при наведении на сообщение */
.message:hover .forward-btn,
.message:hover .reply-btn,
.message:hover .like-btn {
    opacity: 1;
}

/* Убираем анимацию при наведении */
.message:hover .forward-btn,
.message:hover .reply-btn,
.message:hover .like-btn {
    animation: none;
}

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

/* Кнопка лайка в активном состоянии */
.like-btn.liked {
    background: linear-gradient(135deg, #e91e63 0%, #c2185b 100%);
    opacity: 1;
}

/* Счетчик лайков */
.like-count {
    font-size: 11px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 20px;
    padding: 2px 6px;
    min-width: 20px;
    text-align: center;
}

/* Кастомные тултипы */
.forward-btn::after,
.reply-btn::after,
.like-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 11px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 1000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: normal;
    backdrop-filter: blur(4px);
}

.forward-btn:hover::after,
.reply-btn:hover::after,
.like-btn:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

.forward-btn::before,
.reply-btn::before,
.like-btn::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.85);
    pointer-events: none;
    opacity: 0;
    transition: all 0.2s ease;
}

.forward-btn:hover::before,
.reply-btn:hover::before,
.like-btn:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(4px);
}

/* Превью ответа на сообщение */
.message-reply-preview {
    background: rgba(0, 0, 0, 0.08);
    border-left: 3px solid #667eea;
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 8px;
    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: 11px;
    color: #667eea;
    margin-bottom: 4px;
    font-weight: 500;
}

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

.reply-preview-content-text {
    font-size: 12px;
    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: 5px;
    padding-top: 5px;
    border-top: 1px solid rgba(0,0,0,0.1);
    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: 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;
}

.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-bottom: 12px;
    border: 1px solid #e0e0e0;
    overflow: hidden;
    animation: slideDown 0.3s ease;
}

@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: 10px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

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

.forward-preview-cancel,
.reply-preview-cancel {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    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: 12px 15px;
}

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

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

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

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

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

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

.cancel-forward-mode,
.cancel-reply-mode {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 3px 10px;
    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;
}

/* Адаптация для мобильных устройств */
@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: 150px;
        max-height: 120px;
    }
    
    .attach-btn {
        padding: 0 12px;
        font-size: 18px;
    }
    
    .file-icon-left .file-type-icon {
        width: 36px;
        height: 36px;
    }
    
    .forward-btn,
    .reply-btn,
    .like-btn {
        width: 28px;
        height: 28px;
        font-size: 13px;
        opacity: 0.7;
    }
    
    .forward-btn {
        right: 6px;
    }
    
    .reply-btn {
        right: 42px;
    }
    
    .like-btn {
        right: 78px;
        min-width: 28px;
        padding: 0 8px;
    }
    
    .message:hover .forward-btn,
    .message:hover .reply-btn,
    .message:hover .like-btn {
        opacity: 0.85;
    }
    
    .notifications-panel {
        width: 280px;
        right: 10px;
    }
    
    .message-reply-preview {
        padding: 6px 10px;
    }
    
    .reply-preview-header-text {
        font-size: 10px;
    }
    
    .reply-preview-content-text {
        font-size: 11px;
    }
    
    .message-bubble {
        max-width: 75%;
    }
    
    .date-separator-text {
        font-size: 10px;
        padding: 3px 10px;
    }
    
    .message-date-separator {
        margin: 15px 0;
    }
}

@media (max-width: 480px) {
    .forward-btn,
    .reply-btn,
    .like-btn {
        width: 24px;
        height: 24px;
        font-size: 11px;
    }
    
    .forward-btn {
        right: 5px;
    }
    
    .reply-btn {
        right: 37px;
    }
    
    .like-btn {
        right: 69px;
        min-width: 24px;
        padding: 0 6px;
    }
    
    .like-count {
        font-size: 9px;
        padding: 1px 4px;
        min-width: 16px;
    }
}

@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);
    }
}

/* Кнопка переключения режимов */
.users-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

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

.toggle-contacts-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    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, #4caf50 0%, #45a049 100%);
}

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

.category-header {
    padding: 12px 15px;
    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: 14px;
    color: #333;
}

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

.category-content {
    background: #fff;
}

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

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

.small-avatar {
    width: 32px;
    height: 32px;
    font-size: 14px;
}

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

/* Индикатор набора текста */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #667eea;
    padding: 4px 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;
}

/* Добавьте в конец файла style.css */

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

.read-status {
    font-size: 12px;
    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;
}

/* Добавьте в конец style.css */

/* Анимация для появления галочек */
@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;
    }
}

/* Для мобильных устройств */
@media (max-width: 768px) {
    .read-status {
        font-size: 10px;
    }
}

/* Кнопка файлов в шапке */
.user-files-btn {
    background: rgba(102, 126, 234, 0.1);
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    color: #667eea;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    margin-left: auto;
}

.user-files-btn:hover {
    background: rgba(102, 126, 234, 0.2);
    transform: translateY(-1px);
}

/* Модальное окно файлов */
.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;
}

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

.files-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    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: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.files-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    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: 20px;
}

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

.file-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 12px;
    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: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    flex-shrink: 0;
}

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

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

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

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

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

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

.file-item-actions button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    padding: 8px;
    border-radius: 8px;
    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);
}

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

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

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

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

/* Исправление: кнопка "Файлы" в одной строке с именем пользователя */
.chat-header .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;
}

/* Улучшенная кнопка "Файлы" с эффектами при наведении */
.user-files-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    margin-left: 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    letter-spacing: 0.3px;
}

.user-files-btn:hover {
    background: linear-gradient(135deg, #bfbfbf 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);
}