/* Общие настройки */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; 
    background-color: #e6ebee; 
    height: 100vh; 
    overflow: hidden; 
}

.app-container {
    display: flex;
    width: 100%;
    height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
    background: #fff;
}

/* БОКОВАЯ ПАНЕЛЬ (Список чатов) */
.sidebar {
    width: 30%;
    min-width: 300px;
    border-right: 1px solid #dfe5ec;
    display: flex;
    flex-direction: column;
    background: #fff;
    transition: all 0.3s ease;
}

.sidebar-header {
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.search-input {
    flex: 1;
    background: #f1f1f1;
    border: none;
    padding: 10px 15px;
    border-radius: 20px;
    outline: none;
}

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

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

.chat-item:hover { background: #f4f4f5; }

.avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #517da2;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 15px;
}

.avatar.gr { background: #50b332; } /* Цвет для групп */

.chat-info { flex: 1; border-bottom: 1px solid #f0f0f0; padding-bottom: 10px; }
.chat-name { font-weight: 600; color: #222; margin-bottom: 4px; }
.last-msg { font-size: 13px; color: #8a8a8a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ОКНО ЧАТА */
.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #f4f4f5;
    background-image: url('https://user-images.githubusercontent.com'); /* Фон как в TG */
    position: relative;
}

#no-chat-selected {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
}

.select-chat-bubble {
    background: rgba(0,0,0,0.3);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 14px;
}

.chat-header {
    height: 60px;
    background: #fff;
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    z-index: 10;
}

.back-btn { display: none; margin-right: 15px; border: none; background: none; font-size: 20px; cursor: pointer; }

.header-info h3 { font-size: 16px; margin: 0; }
.status { font-size: 12px; color: #517da2; }

/* СООБЩЕНИЯ */
.messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.message {
    max-width: 70%;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.4;
    position: relative;
}

.msg-sent {
    align-self: flex-end;
    background: #effdde;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
}

.msg-received {
    align-self: flex-start;
    background: #fff;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
}

/* ВВОД СООБЩЕНИЯ */
.message-input-form {
    padding: 15px 20px;
    background: #fff;
    display: flex;
    align-items: center;
    gap: 15px;
}

#msg_text {
    flex: 1;
    border: 1px solid #ddd;
    padding: 12px 18px;
    border-radius: 25px;
    outline: none;
    font-size: 15px;
}

.send-btn {
    background: none;
    border: none;
    color: #517da2;
    font-size: 24px;
    cursor: pointer;
}

/* ФУТЕР САЙДБАРА */
.sidebar-footer {
    padding: 15px;
    border-top: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.btn-group {
    color: #517da2;
    text-decoration: none;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    margin-bottom: 5px;
}

/* АДАПТИВНОСТЬ ДЛЯ МОБИЛОК */
@media (max-width: 768px) {
    .sidebar { width: 100%; }
    .chat-window { display: none; }
    
    .sidebar.hidden { display: none; }
    .chat-window.active { display: flex; width: 100%; }
    .back-btn { display: block; }
}
