/* ==============================================
   /css/messenger/style.css
   Стилі для месенджера
   ============================================== */

/* ── Значок і нотифікація ──────────────────── */
.lc-messenger-wrap {
    position: relative;
    display: block;
}

.lc-notif-dot {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 10px;
    height: 10px;
    background: #e91e63;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
    z-index: 5;
}

.lc-notif-dot.visible {
    display: block;
}

/* Лічильник на іконці (число) */
.lc-notif-count {
    position: absolute;
    top: 4px;
    right: 6px;
    background: #e91e63;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
    z-index: 5;
}

.lc-notif-count.visible {
    display: flex;
}

/* Кнопка "Запросити переписку" на профілі */
.btn-request-chat {
    display: inline-block;
    margin-top: 10px;
    padding: 9px 18px;
    background: #e91e63;
    color: #fff !important;
    font-size: 14px;
    font-weight: 700;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}

.btn-request-chat:hover {
    background: #c2185b;
}

.btn-request-chat:disabled,
.btn-request-chat.sent {
    background: #9ca3af;
    cursor: default;
}

/* ── Месенджер layout ──────────────────────── */
.mess-layout {
    display: flex;
    height: calc(100vh - 80px);
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

/* Лівий список діалогів — 30% */
.mess-sidebar {
    width: 30%;
    min-width: 220px;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    background: #fafafa;
}

.mess-sidebar-head {
    padding: 16px 14px 12px;
    font-size: 16px;
    font-weight: 700;
    border-bottom: 1px solid #e5e7eb;
    color: #1f2937;
    flex-shrink: 0;
}

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

/* Один рядок діалогу */
.mess-dialog-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.12s;
    text-decoration: none;
    color: inherit;
}

.mess-dialog-item:hover,
.mess-dialog-item.active {
    background: #f3f4f6;
}

.mess-dialog-ava {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

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

.mess-dialog-name {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mess-dialog-preview {
    font-size: 12px;
    color: #9ca3af;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.mess-dialog-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.mess-dialog-time {
    font-size: 11px;
    color: #9ca3af;
}

.mess-dialog-badge {
    background: #e91e63;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* Запити на переписку у sidebar */
.mess-requests-section {
    border-bottom: 1px solid #e5e7eb;
    padding: 8px 0;
}

.mess-requests-head {
    font-size: 12px;
    font-weight: 700;
    color: #e91e63;
    padding: 4px 14px 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Права частина — чат ─────────────────── */
.mess-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.mess-chat-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
    background: #fff;
}

.mess-chat-head-ava {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
}

.mess-chat-head-name {
    font-size: 15px;
    font-weight: 700;
    color: #1f2937;
}

.mess-chat-head-back {
    display: none;
    font-size: 22px;
    cursor: pointer;
    color: #e91e63;
    margin-right: 4px;
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
}

/* Пусте місце коли діалог не вибрано */
.mess-chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-size: 15px;
}

/* Список повідомлень */
.mess-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f9fafb;
}

/* Одне повідомлення */
.mess-msg {
    max-width: 70%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    position: relative;
}

.mess-msg.me {
    align-self: flex-end;
    background: #e91e63;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.mess-msg.them {
    align-self: flex-start;
    background: #fff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.mess-msg-time {
    font-size: 10px;
    opacity: 0.6;
    margin-top: 4px;
    text-align: right;
}

.mess-msg.them .mess-msg-time {
    text-align: left;
}

/* Форма вводу */
.mess-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}

.mess-input-area textarea {
    flex: 1;
    resize: none;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 14px;
    font-family: Arial, sans-serif;
    outline: none;
    max-height: 120px;
    overflow-y: auto;
    transition: border-color 0.15s;
    line-height: 1.4;
}

.mess-input-area textarea:focus {
    border-color: #e91e63;
}

.mess-send-btn {
    width: 40px;
    height: 40px;
    background: #e91e63;
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}

.mess-send-btn:hover {
    background: #c2185b;
}

/* Розділювач дати */
.mess-date-divider {
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    margin: 8px 0;
}

/* Запит на переписку — блок у чаті */
.mess-request-block {
    text-align: center;
    padding: 24px 16px;
    color: #6b7280;
    font-size: 14px;
}

.mess-request-block p {
    margin-bottom: 12px;
}

.mess-request-accept {
    background: #e91e63;
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 9px 20px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    margin: 0 6px;
    transition: background 0.15s;
}

.mess-request-accept:hover { background: #c2185b; }

.mess-request-decline {
    background: #f3f4f6;
    color: #6b7280;
    border: none;
    border-radius: 20px;
    padding: 9px 20px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    margin: 0 6px;
    transition: background 0.15s;
}

.mess-request-decline:hover { background: #e5e7eb; }

/* ── Мобільна версія ───────────────────────── */
@media (max-width: 1024px) {
    .mess-layout {
        height: calc(100vh - 60px);
        border-radius: 0;
        flex-direction: column;
    }

    .mess-sidebar {
        width: 100%;
        min-width: unset;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
        height: 100%;
    }

    /* На мобільному — або список або чат */
    .mess-layout.chat-open .mess-sidebar {
        display: none;
    }

    .mess-layout.chat-open .mess-chat {
        display: flex;
    }

    .mess-chat {
        display: none;
        position: absolute;
        inset: 60px 0 0 0;
        z-index: 10;
        background: #fff;
    }

    .mess-layout.chat-open .mess-chat {
        position: absolute;
        inset: 60px 0 0 0;
    }

    .mess-chat-head-back {
        display: block;
    }

    .mess-msg {
        max-width: 85%;
    }
}
/* Safe area iOS — нижний отступ под клавиатуру/панель браузера */
/* ── Мобільна версія ───────────────────────── */
@media (max-width: 1024px) {

    .mess-layout {
        height: calc(100dvh - 60px); /* dvh = видима область без панелі браузера */
        border-radius: 0;
        flex-direction: column;
        overflow: hidden;
        position: relative;
    }

    .mess-sidebar {
        width: 100%;
        min-width: unset;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    .mess-dialog-list {
        flex: 1;
        overflow-y: auto;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    /* На мобільному — або список або чат */
    .mess-layout.chat-open .mess-sidebar {
        display: none;
    }

    /* ── Чат займає весь екран, фіксований ── */
    .mess-chat {
        display: none;
        position: fixed;           /* fixed — не їде при появі клавіатури */
        top: 60px;                 /* під хедером */
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 10;
        background: #fff;
        flex-direction: column;
    }

    .mess-layout.chat-open .mess-chat {
        display: flex;
    }

    /* Шапка чату — завжди на місці */
    .mess-chat-head {
        flex-shrink: 0;            /* не стискається */
        position: relative;
        z-index: 2;
    }

    /* Повідомлення — скролляться, займають вільний простір */
    .mess-messages {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    /* Поле вводу — прилипає до низу над клавіатурою */
    .mess-input-area {
        flex-shrink: 0;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .mess-chat-head-back {
        display: block;
    }

    .mess-msg {
        max-width: 85%;
    }
}

/* Меню sidebar прижато к низу на мобильном */
@media (max-width: 1024px) {
    .mess-sidebar {
        display: flex;
        flex-direction: column;
        height: calc(100dvh - 60px); /* dvh учитывает панель браузера */
    }
    .mess-dialog-list {
        flex: 1;
        overflow-y: auto;
        /* Отступ снизу чтобы последний диалог не прятался под панель */
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
}