* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'DejaVu Sans Mono', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #00BFFF 10%, #0000FF 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 1200px;
    height: 90vh;
    background-color: white;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
    display: flex;
}

/* Стили для страницы регистрации/авторизации */
.auth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 40px;
    transition: all 0.3s ease;
}

.auth-form {
    width: 100%;
    max-width: 400px;
    background-color: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.auth-form h1 {
    color: #2575fc;
    text-align: center;
    margin-bottom: 10px;
    font-size: 2.5rem;
}

.auth-form h2 {
    color: #333;
    text-align: center;
    margin-bottom: 30px;
    font-weight: 400;
}

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

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

.form-control {
    width: 100%;
    padding: 14px;
    border: 2px solid #e1e5ee;
    border-radius: 10px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-control:focus {
    border-color: #2575fc;
    outline: none;
}

.btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(to right, #6a11cb, #2575fc);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(37, 117, 252, 0.4);
}

.auth-switch {
    text-align: center;
    margin-top: 25px;
    color: #666;
}

.auth-switch a {
    color: #2575fc;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.error-message {
    color: #e74c3c;
    font-size: 14px;
    margin-top: 5px;
    display: none;
}

/* Стили для интерфейса мессенджера */
.messenger-container {
    display: none;
    width: 100%;
    height: 100%;
}

.sidebar {
    width: 30%;
    background-color: #f8f9fa;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.header {
    padding: 20px;
    background-color: white;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #2575fc;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-right: 12px;
    position: relative;
    overflow: hidden;
    background-size: cover;
    background-position: center;
}

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

.avatar-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.user-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #4CAF50;
    margin-left: 5px;
    position: relative;
    top: -8px;
    left: 8px;
    z-index: 2;
}

.user-status.offline {
    background-color: #95a5a6;
}

.username {
    font-weight: 600;
    color: #333;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.header-btn {
    background: none;
    border: none;
    color: #2575fc;
    font-size: 20px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.header-btn:hover {
    background-color: rgba(37, 117, 252, 0.1);
}

.search-container {
    padding: 15px 20px;
    background-color: white;
    border-bottom: 1px solid #e9ecef;
}

.search-box {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #e1e5ee;
    border-radius: 20px;
    font-size: 14px;
    background-color: #f8f9fa;
}

.search-results {
    max-height: 300px;
    overflow-y: auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    position: absolute;
    width: calc(100% - 40px);
    z-index: 100;
    display: none;
}

.search-result-item {
    padding: 12px 15px;
    display: flex;
    align-items: center;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.search-result-item:hover {
    background-color: #f5f5f5;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.chat-item {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.chat-item:hover {
    background-color: #e9ecef;
}

.chat-item.active {
    background-color: #e3f2fd;
}

.chat-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-right: 15px;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    background-size: cover;
    background-position: center;
}

.group-avatar {
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
}

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

.chat-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-type {
    font-size: 12px;
    color: #666;
    background-color: #e9ecef;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 5px;
}

.unread-badge {
    background-color: #2575fc;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-last-message {
    color: #777;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Основная область чата */
.chat-area {
    width: 70%;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    padding: 20px;
    background-color: white;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-contact {
    display: flex;
    align-items: center;
}

.chat-info-group {
    margin-left: 15px;
}

.chat-title {
    font-weight: 600;
    color: #333;
    font-size: 18px;
}

.chat-members {
    color: #777;
    font-size: 14px;
    margin-top: 5px;
}

.chat-actions {
    display: flex;
    gap: 10px;
}

.chat-action-btn {
    background: none;
    border: none;
    color: #2575fc;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.chat-action-btn:hover {
    background-color: rgba(37, 117, 252, 0.1);
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: #fafafa;
    display: flex;
    flex-direction: column;
}

.message {
    max-width: 70%;
    padding: 12px 18px;
    margin-bottom: 15px;
    border-radius: 18px;
    position: relative;
}

.message-incoming {
    align-self: flex-start;
    background-color: white;
    border: 1px solid #e9ecef;
    border-top-left-radius: 5px;
}

.message-outgoing {
    align-self: flex-end;
    background: linear-gradient(to right, #6a11cb, #2575fc);
    color: white;
    border-top-right-radius: 5px;
}

.message-sender {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 3px;
    color: #666;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 5px;
    text-align: right;
}

.message-input-container {
    padding: 20px;
    background-color: white;
    border-top: 1px solid #e9ecef;
}

.message-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.message-input {
    flex: 1;
    padding: 15px;
    border: 1px solid #e1e5ee;
    border-radius: 25px;
    font-size: 16px;
}

.send-button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(to right, #6a11cb, #2575fc);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.send-button:hover {
    transform: scale(1.05);
}

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

.modal-content {
    background-color: white;
    width: 90%;
    max-width: 500px;
    border-radius: 15px;
    overflow: hidden;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px;
    background: linear-gradient(to right, #6a11cb, #2575fc);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.5rem;
}

.close-modal {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

.modal-body {
    padding: 30px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Окно настроек */
.settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.settings-content {
    background-color: white;
    width: 90%;
    max-width: 600px;
    border-radius: 15px;
    overflow: hidden;
    max-height: 90vh;
    overflow-y: auto;
}

.settings-header {
    padding: 20px;
    background: linear-gradient(to right, #6a11cb, #2575fc);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.settings-header h3 {
    font-size: 1.5rem;
}

.close-settings {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

.settings-body {
    padding: 30px;
}

.settings-section {
    margin-bottom: 30px;
}

.settings-section h4 {
    color: #333;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e9ecef;
}

.avatar-preview {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background-color: #2575fc;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 36px;
    margin: 0 auto 20px;
    overflow: hidden;
    position: relative;
    background-size: cover;
    background-position: center;
}

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

.avatar-upload-container {
    text-align: center;
    margin-bottom: 20px;
}

.avatar-upload-btn {
    display: inline-block;
    padding: 10px 20px;
    background-color: #2575fc;
    color: white;
    border-radius: 5px;
    cursor: pointer;
    margin: 5px;
    transition: background-color 0.2s;
}

.avatar-upload-btn:hover {
    background-color: #1a68e8;
}

.avatar-upload-input {
    display: none;
}

.btn-secondary {
    padding: 10px 20px;
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-danger {
    padding: 10px 20px;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-success {
    padding: 10px 20px;
    background-color: #2ecc71;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-success:hover {
    background-color: #27ae60;
}

.settings-footer {
    padding: 20px;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
}

.btn-primary {
    padding: 12px 30px;
    background: linear-gradient(to right, #6a11cb, #2575fc);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: transform 0.2s;
}

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

.welcome-message {
    text-align: center;
    color: #666;
    font-style: italic;
    margin-top: 20px;
}

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    background-color: #4CAF50;
    color: white;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    display: none;
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.typing-indicator {
    font-size: 12px;
    color: #666;
    font-style: italic;
    margin-left: 10px;
}

.logout-section {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 2px solid #eee;
}

/* Стили для групповых чатов */
.members-list {
    max-height: 200px;
    overflow-y: auto;
    margin: 15px 0;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 10px;
}

.member-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
}

.member-item:last-child {
    border-bottom: none;
}

.member-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #2575fc;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-right: 10px;
    overflow: hidden;
    background-size: cover;
    background-position: center;
}

.member-name {
    flex: 1;
}

.member-role {
    font-size: 12px;
    color: #666;
    background-color: #e9ecef;
    padding: 2px 6px;
    border-radius: 10px;
}

.checkbox-list {
    max-height: 200px;
    overflow-y: auto;
    margin: 15px 0;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 10px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
}

.checkbox-item:last-child {
    border-bottom: none;
}

.checkbox-item label {
    display: flex;
    align-items: center;
    width: 100%;
    cursor: pointer;
}

.checkbox-item input {
    margin-right: 10px;
}

/* Системные сообщения */
.system-message {
    align-self: center;
    background-color: #e9ecef;
    color: #666;
    padding: 8px 16px;
    border-radius: 15px;
    font-size: 13px;
    margin: 10px 0;
    max-width: 80%;
    text-align: center;
}

/* Адаптивность */
@media (max-width: 768px) {
    .container {
        height: 95vh;
    }
    
    .sidebar {
        width: 100%;
    }
    
    .chat-area {
        width: 100%;
        display: none;
    }
    
    .chat-area.active {
        display: flex;
    }
    
    .auth-form {
        padding: 30px 20px;
    }
    
    .avatar-preview {
        width: 100px;
        height: 100px;
        font-size: 28px;
    }
}

.avatar-options {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.file-info {
    font-size: 12px;
    color: #666;
    text-align: center;
    margin-top: 10px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.empty-state i {
    font-size: 48px;
    color: #adb5bd;
    margin-bottom: 15px;
}

/* Стили для файловых сообщений */
.message-file {
    padding: 10px;
    border-radius: 10px;
    background-color: white;
    border: 1px solid #e9ecef;
    max-width: 250px;
    cursor: pointer;
    transition: transform 0.2s;
}

.message-file:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.file-preview {
    width: 100%;
    height: 150px;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 10px;
    position: relative;
    background-color: #f8f9fa;
}

.file-preview img,
.file-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-icon {
    font-size: 48px;
    color: #2575fc;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.file-info {
    padding: 8px;
}

.file-name {
    font-weight: 600;
    color: #333;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 5px;
}

.file-size {
    font-size: 12px;
    color: #666;
}

.file-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #2575fc;
    font-size: 14px;
    text-decoration: none;
    margin-top: 5px;
}

.file-download-btn:hover {
    text-decoration: underline;
}

/* Кнопка отправки файлов */
.file-upload-btn {
    background: none;
    border: none;
    color: #2575fc;
    font-size: 20px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.file-upload-btn:hover {
    background-color: rgba(37, 117, 252, 0.1);
}

/* Контейнер для кнопок ввода */
.input-buttons {
    display: flex;
    align-items: center;
}

/* Модальное окно предпросмотра файла */
.file-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.file-preview-content {
    max-width: 90%;
    max-height: 90%;
    position: relative;
}

.file-preview-content img,
.file-preview-content video {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 10px;
}

.close-preview {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 30px;
    cursor: pointer;
}

.file-preview-info {
    color: white;
    text-align: center;
    margin-top: 10px;
}

/* Кнопка "Назад" для мобильных */
.back-button {
    display: none;
    background: none;
    border: none;
    color: #2575fc;
    font-size: 20px;
    cursor: pointer;
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
    .back-button {
        display: block;
    }
    
    .chat-header {
        padding: 15px;
    }
    
    .input-buttons {
        margin-right: 5px;
    }
    
    .file-upload-btn {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
    
    .message-file {
        max-width: 200px;
    }
}