* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

body {
    background: #0e1621;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app {
    display: flex;
    width: 100%;
    max-width: 1400px;
    height: 100vh;
    background: #17212b;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

/* Левая панель */
.sidebar {
    width: 320px;
    background: #17212b;
    border-right: 1px solid #0e1621;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 15px;
    background: #1e2b37;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo {
    height: 40px;
    width: auto;
}

.search-box {
    flex: 1;
}

.search-box input {
    width: 100%;
    padding: 8px 12px;
    background: #242f3d;
    border: none;
    border-radius: 20px;
    color: #fff;
    font-size: 14px;
}

.search-box input::placeholder {
    color: #7f8c8d;
}

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

.dialog-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #1e2b37;
}

.dialog-item:hover {
    background: #1e2b37;
}

.dialog-item.active {
    background: #2b5278;
}

.dialog-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #2b5278;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: bold;
    font-size: 18px;
    margin-right: 12px;
    text-transform: uppercase;
}

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

.dialog-name {
    font-weight: 600;
    color: #fff;
    margin-bottom: 4px;
}

.dialog-last-message {
    font-size: 13px;
    color: #7f8c8d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dialog-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-left: 8px;
}

.dialog-time {
    font-size: 11px;
    color: #7f8c8d;
    margin-bottom: 4px;
}

.unread-badge {
    background: #2b5278;
    color: #fff;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: bold;
}

.sidebar-footer {
    padding: 15px;
    background: #1e2b37;
    display: flex;
    gap: 10px;
}

#newChatBtn {
    flex: 1;
    padding: 8px;
    background: #2b5278;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

.logout-btn {
    padding: 8px 12px;
    background: #c0392b;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
}

/* Правая панель */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0e1621;
}

.chat-header {
    padding: 15px 20px;
    background: #1e2b37;
    color: #fff;
    font-weight: 600;
    border-bottom: 1px solid #0e1621;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.message {
    max-width: 60%;
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: 12px;
    position: relative;
    word-wrap: break-word;
}

.message.my-message {
    align-self: flex-end;
    background: #2b5278;
    color: #fff;
    border-bottom-right-radius: 2px;
}

.message.their-message {
    align-self: flex-start;
    background: #1e2b37;
    color: #fff;
    border-bottom-left-radius: 2px;
}

.message .sender {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #7f8c8d;
}

.message .time {
    font-size: 10px;
    color: #7f8c8d;
    margin-left: 8px;
    float: right;
}

.message-form {
    padding: 15px 20px;
    background: #1e2b37;
    border-top: 1px solid #0e1621;
}

.message-form form {
    display: flex;
    gap: 10px;
}

#messageInput {
    flex: 1;
    padding: 10px 15px;
    background: #242f3d;
    border: none;
    border-radius: 20px;
    color: #fff;
}

#messageInput::placeholder {
    color: #7f8c8d;
}

.message-form button {
    padding: 10px 20px;
    background: #2b5278;
    color: #fff;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
}

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

.modal-content {
    background: #17212b;
    padding: 20px;
    border-radius: 8px;
    width: 400px;
    max-width: 90%;
    color: #fff;
}

.close {
    float: right;
    font-size: 24px;
    cursor: pointer;
    color: #7f8c8d;
}

.close:hover {
    color: #fff;
}

#searchUsers {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    background: #242f3d;
    border: none;
    border-radius: 4px;
    color: #fff;
}

.user-results {
    max-height: 300px;
    overflow-y: auto;
}

.user-result-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #1e2b37;
}

.user-result-item:hover {
    background: #1e2b37;
}

/* Страницы авторизации */
.auth-container {
    background: #17212b;
    padding: 30px;
    border-radius: 8px;
    width: 350px;
    text-align: center;
    color: #fff;
}

.auth-container .logo {
    width: 120px;
    margin-bottom: 20px;
}

.auth-container input {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    background: #242f3d;
    border: none;
    border-radius: 4px;
    color: #fff;
}

.auth-container button {
    width: 100%;
    padding: 10px;
    background: #2b5278;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}

.auth-container a {
    color: #2b5278;
    text-decoration: none;
}

.error {
    color: #e74c3c;
    margin-bottom: 10px;
}
/* Мобильная адаптация */
@media (max-width: 768px) {
    .app {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
    }
    .chat-area {
        width: 100%;
        height: 100%;
        display: none; /* скрыт по умолчанию */
    }
    .chat-area.active {
        display: flex;
    }
    .sidebar.hidden {
        display: none;
    }
    .back-button {
        display: inline-block;
        margin-right: 10px;
        cursor: pointer;
        font-size: 20px;
    }
    .chat-header {
        display: flex;
        align-items: center;
    }
}
.back-button {
    display: none;
}
@media (max-width: 768px) {
    .back-button {
        display: inline-block;
    }
}