/* static/css/chat.css */

/* ===== Чат (экран сообщений) ===== */
.chat-screen {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #0d0d0d;
}

.chat-messages {
    flex: 1;
    padding: 16px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* ===== Разделитель дат ===== */
.date-separator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 0;
    opacity: 0.5;
    margin: 4px 0;
}

.date-line {
    flex: 1;
    height: 1px;
    background: #2a2a2a;
}

.date-text {
    font-size: 12px;
    color: #6a6a6a;
    white-space: nowrap;
    font-weight: 500;
    padding: 0 4px;
}

/* ===== Кнопка "Назад" ===== */
.header-btn-link {
    background: transparent;
    border: none;
    color: #7c7c7c;
    font-size: 22px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    transition: 0.2s;
    text-decoration: none;
    line-height: 1;
}

.header-btn-link:hover {
    background: #2a2a2a;
    color: #ffffff;
}

/* ===== Шапка чата ===== */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: #141414;
    border-bottom: 1px solid #222222;
    flex-shrink: 0;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #2a2a2a;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
}

.header-info .header-name {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
}

.header-info .header-status {
    font-size: 12px;
    color: #7c7c7c;
}

.header-btn {
    background: transparent;
    border: none;
    color: #7c7c7c;
    font-size: 20px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    transition: 0.2s;
}

.header-btn:hover {
    background: #2a2a2a;
    color: #ffffff;
}

/* ===== Сообщения ===== */
.msg-item {
    display: flex;
    gap: 10px;
    max-width: 80%;
    margin-bottom: 0;
    animation: fadeIn 0.2s ease;
}

.msg-item.incoming {
    align-self: flex-start;
    align-items: flex-end;
}

.msg-item.outgoing {
    align-self: flex-end;
    flex-direction: row-reverse;
    margin-bottom: 8px;
}

.msg-sender-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #1a1a1a;
    color: #e4e4e4;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}

.msg-sender-name {
    font-size: 12px;
    font-weight: 600;
    color: #7c7c7c;
    line-height: 36px;
    padding-bottom: 2px;
}

/* Облако строго под аватаркой */
.msg-bubble-indent {
    margin-left: 0;
    margin-top: 2px;
    margin-bottom: 8px;
    max-width: fit-content;
}

.msg-bubble-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 100%;
}

.msg-bubble {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    padding: 0;
    max-width: 100%;
    overflow: hidden;
    min-width: 80px;
    display: inline-block;
}

.msg-item.outgoing .msg-bubble {
    background: #1e1e1e;
    border-color: #333333;
}

/* Верхняя декоративная линия */
.msg-top-line {
    height: 2px;
    background: linear-gradient(90deg, transparent 5%, #444444 30%, #666666 50%, #444444 70%, transparent 95%);
    margin: 4px 14px 0 14px;
    border-radius: 2px;
}

.msg-item.outgoing .msg-top-line {
    background: linear-gradient(90deg, transparent 5%, #4a4a4a 30%, #6a6a6a 50%, #4a4a4a 70%, transparent 95%);
}

/* Внутренний слой */
.msg-inner {
    padding: 6px 14px 4px 14px;
}

.msg-text {
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    color: #d4d4d4;
}

.msg-item.outgoing .msg-text {
    color: #e8e8e8;
}

/* Разделительная линия */
.msg-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
    margin: 0 12px;
}

/* Футер */
.msg-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 12px 5px 12px;
}

.msg-time {
    font-size: 10px;
    color: #6a6a6a;
}

.msg-item.outgoing .msg-time {
    color: #7a7a7a;
}

.msg-status {
    font-size: 12px;
    color: #6a6a6a;
}

.msg-status.sent {
    color: #6a6a6a;
}

.msg-status.read {
    color: #8a8a8a;
}

.msg-status.error {
    color: #884444;
}

/* ===== Форма ввода ===== */
.msg-form {
    display: flex;
    gap: 10px;
    padding: 12px 24px;
    background: #141414;
    border-top: 1px solid #222222;
    flex-shrink: 0;
}

.msg-input {
    flex: 1;
    padding: 10px 16px;
    background: #0d0d0d;
    border: 1px solid #2a2a2a;
    border-radius: 24px;
    color: #e4e4e4;
    font-size: 15px;
    outline: none;
    transition: 0.2s;
}

.msg-input:focus {
    border-color: #555555;
}

.msg-send {
    padding: 10px 20px;
    background: #2a2a2a;
    color: #e4e4e4;
    border: 1px solid #333333;
    border-radius: 24px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    white-space: nowrap;
}

.msg-send:hover {
    background: #3a3a3a;
}

.msg-send:active {
    transform: scale(0.96);
}

/* ===== Кнопка подписки ===== */
.subscribe-bar {
    display: flex;
    justify-content: center;
    padding: 12px 24px;
    background: #141414;
    border-top: 1px solid #222222;
    flex-shrink: 0;
}

.subscribe-btn {
    padding: 10px 32px;
    background: #1a1a1a;
    color: #e4e4e4;
    border: 1px solid #333333;
    border-radius: 24px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
}

.subscribe-btn:hover {
    background: #2a2a2a;
    border-color: #555555;
}

.subscribe-btn:active {
    background: #333333;
}

/* ===== Анимации ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Адаптив ===== */
@media (max-width: 1024px) {
    .chat-header { padding: 12px 16px; }
    .chat-messages { padding: 12px 16px; }
    .msg-form { padding: 10px 16px; }
    .msg-item { max-width: 85%; }
}

@media (max-width: 600px) {
    .chat-screen {
        height: 100vh;
        height: 100dvh;
    }
    .chat-header {
        padding: 8px 12px;
        flex-shrink: 0;
    }
    .chat-header-left {
        gap: 8px;
    }
    .header-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    .header-name {
        font-size: 14px;
    }
    .header-btn-link {
        font-size: 18px;
        padding: 4px 6px;
    }
    .chat-messages {
        padding: 8px 12px;
        gap: 1px;
    }
    .msg-item {
        max-width: 90%;
        gap: 6px;
    }
    .msg-sender-avatar {
        width: 30px;
        height: 30px;
        font-size: 13px;
    }
    .msg-sender-name {
        line-height: 30px;
        font-size: 11px;
    }
    .msg-bubble {
        min-width: 60px;
    }
    .msg-text {
        font-size: 13px;
    }
    .msg-inner {
        padding: 4px 10px 2px 10px;
    }
    .msg-top-line {
        margin: 2px 10px 0 10px;
    }
    .msg-footer {
        padding: 2px 8px 3px 8px;
    }
    .msg-time {
        font-size: 9px;
    }
    .msg-form {
        padding: 8px 12px;
        gap: 6px;
        flex-shrink: 0;
        position: sticky;
        bottom: 0;
        background: #141414;
    }
    .msg-input {
        font-size: 14px;
        padding: 8px 12px;
    }
    .msg-send {
        padding: 8px 14px;
        font-size: 14px;
    }
    .date-separator {
        padding: 10px 0;
    }
    .date-text {
        font-size: 11px;
    }
    .msg-bubble-indent {
        margin-left: 0;
        max-width: fit-content;
    }
}