/* Основные стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #0088cc 0%, #006699 100%);
    height: 100vh;
    overflow: hidden;
}

/* Мобильный контейнер */
.mobile-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: white;
    max-width: 500px;
    margin: 0 auto;
    position: relative;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.2);
}

/* Верхнее меню */
.chat-header {
    background: linear-gradient(135deg, #0088cc 0%, #006699 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.menu-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
   cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.3s;
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: #00aaff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
    color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 16px;
}

.user-status {
    font-size: 12px;
    opacity: 0.8;
}

.user-status.online {
    color: #4cd964;
}

.user-status.offline {
    color: #ff3b30;
}

/* Кнопка с тремя точками */
.dots-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 50%;
    transition: background 0.3s;
}

.dots-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Выпадающее меню */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: white;
    min-width: 200px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    z-index: 1000;
    overflow: hidden;
}

.dropdown-content a {
    color: #333;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.3s;
    font-size: 14px;
}

.dropdown-content a:hover {
    background: #f8f9fa;
    color: #0088cc;
}

.dropdown-content a i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

.dropdown:hover .dropdown-content {
    display: block;
}

/* Боковое меню */
.sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100%;
    background: white;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar.active {
    left: 0;
}

.sidebar-header {
    background: linear-gradient(135deg, #0088cc 0%, #006699 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    font-size: 24px;
    font-weight: 300;
}

.close-sidebar {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.3s;
}

.close-sidebar:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.sidebar-section {
    margin-bottom: 30px;
}

.sidebar-section h4 {
    color: #0088cc;
    margin-bottom: 15px;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Список пользователей */
.users-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 10px;
    transition: background 0.3s;
    cursor: pointer;
}

.user-item:hover {
    background: #f8f9fa;
}

.user-avatar-small {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    position: relative;
}

.user-avatar-small.online {
    background: #4cd964;
}

.user-avatar-small.offline {
    background: #8e8e93;
}

.user-avatar-small.online::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: #4cd964;
    border: 2px solid white;
    border-radius: 50%;
}

.user-info-small {
    flex: 1;
}

.user-name-small {
    font-weight: 600;
    font-size: 14px;
}

.user-status-small {
    font-size: 12px;
    color: #8e8e93;
}

/* Список чатов */
.chats-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    color: #333;
}

.chat-item:hover {
    background: #f0f8ff;
    color: #0088cc;
}

.chat-item.active {
    background: #0088cc;
    color: white;
}

.chat-item i {
    width: 20px;
    text-align: center;
}

/* Основная область чата */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.chat-container {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.chat-messages {
    height: 100%;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
}

/* Сообщения */
.message {
    max-width: 80%;
    padding: 12px 15px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease;
}

<span style="color: hsl(var(--primary)); font-weight: 500;">@keyframes</span> fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.sent {
    background: #0088cc;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

.message.received {
    background: #f0f0f0;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

.message-sender {
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 5px;
    opacity: 0.8;
}

.message-text {
    font-size: 15px;
    line-height: 1.4;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 5px;
    text-align: right;
}

/* Файлы в сообщениях */
.file-preview {
    margin-top: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.file-link {
    color: #00aaff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.file-link:hover {
    text-decoration: underline;
}

.file-icon {
    font-size: 16px;
}

.image-preview {
    max-width: 200px;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.3s;
}

.image-preview:hover {
    transform: scale(1.05);
}

.video-preview {
    max-width: 200px;
    border-radius: 10px;
}

.audio-preview {
    width: 100%;
    border-radius: 20px;
}

/* Поле ввода сообщения */
.message-input-container {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #e9ecef;
    position: sticky;
    bottom: 0;
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8f9fa;
    border-radius: 25px;
    padding: 5px 5px 5px 20px;
    border: 2px solid transparent;
    transition: border-color 0.3s;
}

.input-wrapper:focus-within {
    border-color: #0088cc;
}

#messageInput {
    flex: 1;
    border: none;
    background: none;
    padding: 12px 0;
    font-size: 16px;
    outline: none;
    color: #333;
}

#messageInput::placeholder {
    color: #8e8e93;
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 5px;
}

.emoji-btn, .send-btn {
    background: none;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.3s;
    font-size: 18px;
}

.emoji-btn {
    color: #8e8e93;
}

.emoji-btn:hover {
    background: #e9ecef;
}

.send-btn {
    background: #0088cc;
    color: white;
}

.send-btn:hover {
    background: #00aaff;
}

.send-btn:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 15px;
    max-width: 90%;
    max-height: 90%;
    overflow: auto;
    position: relative;
    animation: modalFadeIn 0.3s ease;
}

<span style="color: hsl(var(--primary)); font-weight: 500;">@keyframes</span> modalFadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    color: white;
    font-size: 30px;
    cursor: pointer;
    z-index: 2001;
    background: rgba(0, 0, 0, 0.5);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:hover {
    background: rgba(0, 0, 0, 0.7);
}

#filePreview {
    padding: 20px;
    text-align: center;
}

#filePreview img, #filePreview video {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 10px;
}

#filePreview audio {
    width: 100%;
    max-width: 500px;
}

/* Статус загрузки */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0088cc;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

<span style="color: hsl(var(--primary)); font-weight: 500;">@keyframes</span> spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Адаптивность */
<span style="color: hsl(var(--primary)); font-weight: 500;">@media</span> (max-width: 500px) {
    .mobile-container {
        max-width: 100%;
        border-radius: 0;
    }
    
    .chat-header {
        padding: 12px 15px;
    }
    
    .message {
        max-width: 85%;
    }
    
    .sidebar {
        width: 85%;
        left: -85%;
    }
}

<span style="color: hsl(var(--primary)); font-weight: 500;">@media</span> (min-width: 501px) {
    body {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 20px;
    }
    
    .mobile-container {
        border-radius: 20px;
        overflow: hidden;
        height: 90vh;
    }
}

/* Скроллбар */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: #0088cc;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #006699;
}

/* Анимации */
<span style="color: hsl(var(--primary)); font-weight: 500;">@keyframes</span> slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

<span style="color: hsl(var(--primary)); font-weight: 500;">@keyframes</span> pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.new-message {
    animation: pulse 0.5s ease;
}

/* Уведомления */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #0088cc;
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    z-index: 3000;
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.notification i {
    font-size: 20px;
}

.notification.hidden {
    animation: slideOut 0.3s ease forwards;
}

<span style="color: hsl(var(--primary)); font-weight: 500;">@keyframes</span> slideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

/* Индикатор прокрутки */
.scroll-indicator {
    position: absolute;
    bottom: 80px;
    right: 20px;
    background: #0088cc;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s;
}

.scroll-indicator.visible {
    opacity: 1;
}

.scroll-indicator:hover {
    background: #00aaff;
    transform: scale(1.1);
}
