/* css/chat.css (ПОЛНОСТЬЮ ПЕРЕПИСАННЫЙ ФАЙЛ) */

/* Главный контейнер для двухуровневого макета внутри .container */
.chat-main-content {
    padding: 20px 0; /* Отступ сверху/снизу */
}

.chat-layout {
    display: flex;
    height: 80vh;
    border: 1px solid #ddd;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    background-color: #fff;
    border-radius: 8px;
    overflow: hidden;
}

/* 1. ЛЕВАЯ КОЛОНКА (САЙДБАР) */
.sidebar {
    width: 300px;
    flex-shrink: 0;
    border-right: 1px solid #eee;
    background-color: #f7f7f7;
    overflow-y: auto;
}

.conversations-list {
    /* Стилей не требуется */
}

.conversation-item {
    padding: 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s;
}
.conversation-item:hover { background-color: #f0f0f0; }
.conversation-item.active { background-color: #e6e6e6; }
.partner-name {
    font-weight: 700;
    color: #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.last-message {
    color: #666;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.message-time {
    float: right; /* Позиционируется относительно последнего сообщения */
    font-size: 11px;
    color: #999;
    position: relative;
    top: 2px; /* Небольшая коррекция */
}
.unread-count {
    background-color: #ff5722;
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 11px;
    margin-left: 5px;
    line-height: 1;
}


/* 2. ОСНОВНАЯ ОБЛАСТЬ ЧАТА */
.chat-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.chat-header {
    /* ✅ ИСПРАВЛЕНИЕ: Используем Flexbox для расположения имени и статуса */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    background-color: #fff;
    flex-shrink: 0; /* Чтобы хедер не сжимался */
}

.partner-title {
    margin: 0; /* Сброс стандартного маржина h3 */
    font-size: 1.2em;
    color: #333;
}

/* ✅ ИСПРАВЛЕНИЕ: Стили для статуса */
.typing-indicator {
    font-size: 13px;
    font-style: italic;
    color: #008069; /* Цвет "На связи" или "Печатает" */
    text-align: right;
    margin-left: 15px;
    flex-shrink: 0;
    line-height: 1.2;
}


.messages-container {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: #e5ddd5;
}

/* Стили сообщений */
.message {
    max-width: 60%;
    padding: 10px 14px;
    border-radius: 18px;
    margin-bottom: 10px;
    clear: both;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}
.incoming {
    background-color: #fff;
    float: left;
}
.outgoing {
    background-color: #dcf8c6;
    float: right;
}
.message p {
    margin: 0;
    word-wrap: break-word;
}
.message .time {
    font-size: 11px;
    color: #888;
    margin-top: 5px;
    text-align: right;
    display: block;
}

/* Футер ввода сообщения */
.chat-footer-controls {
    padding: 10px 20px;
    background-color: #f0f0f0;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.message-input {
    flex-grow: 1;
    padding: 10px 15px;
    border: 1px solid #ccc;
    border-radius: 20px;
    margin-right: 10px;
    font-size: 14px;
}
.send-button {
    padding: 10px 20px;
    flex-shrink: 0;
}

/* Стили для начальных/загрузочных сообщений */
.placeholder-message, .loading-message, .no-messages {
    text-align: center;
    color: #999;
    margin-top: 50px;
}

#typing-indicator.status-online {
    color: #00b300; /* зелёный */
    font-weight: 500;
}

#typing-indicator.status-offline {
    color: #ff3b3b; /* красный */
    font-weight: 500;
}

.system-message {
    background: #f8f9fa;
    border-left: 4px solid #007bff;
    padding: 12px 16px;
    margin: 8px 0;
    border-radius: 6px;
    font-size: 0.95rem;
}

.lesson-link-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: white;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.lesson-link-info code {
    background: #f1f3f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
}

.lesson-link-btn {
    display: inline-block;
    text-align: center;
    width: 100%;
    padding: 8px 16px;
    font-weight: 600;
}

@media (max-width: 768px) {
    /* Растягиваем контейнер на весь экран */
    .chat-layout {
        display: flex;
        height: calc(100vh - 120px); /* Вычитаем высоту шапки и футера */
        position: relative;
        overflow: hidden;
    }

    /* Боковая панель (список диалогов) на весь экран */
    .sidebar {
        width: 100%;
        flex: none;
        transition: transform 0.3s ease;
    }

    /* Сама область чата */
    .chat-area {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: white;
        z-index: 10;
        transform: translateX(100%); /* Прячем чат за правую границу */
        transition: transform 0.3s ease;
        display: flex;
        flex-direction: column;
    }

    /* Когда чат активен — выдвигаем его */
    .chat-layout.chat-open .chat-area {
        transform: translateX(0);
    }

    /* Кнопка "Назад" в заголовке чата (нужно будет добавить в HTML) */
    .back-to-list {
        display: block !important;
        margin-right: 15px;
        cursor: pointer;
        font-size: 20px;
        color: #007bff;
    }

    .chat-header {
        display: flex;
        align-items: center;
        padding: 10px;
    }

    /* Фикс инпутов для мобилок, чтобы не зумилось */
    .message-input {
        font-size: 16px !important;
    }
}