/* Мобильный layout: safe-area, чат под клавиатуру, без ломания списка чатов */

@media (max-width: 900px) {
    :root {
        --layout-safe-top: env(safe-area-inset-top, 0px);
        --layout-header-total: calc(var(--header-height, 60px) + var(--layout-safe-top));
    }

    html {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    /* Шапка не залезает под статус-бар iPhone */
    body.page-split-layout .header {
        padding-top: var(--layout-safe-top);
        height: var(--layout-header-total);
        min-height: var(--layout-header-total);
        box-sizing: border-box;
    }

    body.page-split-layout .header-burger-slot {
        height: var(--header-height, 60px);
        align-self: flex-end;
    }

    body.page-split-layout .main {
        padding-top: var(--layout-header-total);
    }

    body.page-split-layout .sidebar {
        top: var(--layout-header-total);
        height: calc(100dvh - var(--layout-header-total));
    }

    /* iOS не зумит поле ввода при font-size >= 16px */
    body.page-split-layout #chatComposer .composer-rich-input,
    body.page-split-layout #chatComposer .composer-post textarea,
    body.page-split-layout #channelComposer .composer-rich-input,
    body.page-split-layout #channelComposer .composer-post textarea {
        font-size: 16px !important;
    }

    /* В iframe shell шапки нет — не дублируем отступ под header */
    body.plm-embed-body.page-split-layout .plm-embed-content {
        padding: 0;
    }

    body.plm-embed-body.page-split-layout .split-layout.show-right .split-right {
        top: 6px;
    }

    body.plm-embed-body.page-split-layout.split-keyboard-open .split-layout.show-right .split-right {
        top: calc(6px + var(--vv-offset-top, 0px));
    }

    body.plm-embed-body.page-split-layout.pn-call-active .split-layout.show-right .split-right {
        top: 6px;
    }

    /* Открытый чат — с небольшими отступами от краёв экрана */
    body.page-split-layout .split-layout.show-right .split-right {
        position: fixed;
        left: 8px;
        right: 8px;
        top: calc(var(--layout-header-total) + 6px);
        bottom: max(8px, env(safe-area-inset-bottom, 0px));
        width: auto;
        height: auto;
        max-height: none;
        min-height: 0;
        z-index: 50;
        display: flex;
        flex-direction: column;
        background-color: var(--content-bg-color, #1a1a1a);
        border-radius: 16px;
        overflow: hidden;
        box-sizing: border-box;
    }

    body.page-split-layout.split-keyboard-open .split-layout.show-right .split-right {
        top: calc(var(--layout-header-total) + 6px + var(--vv-offset-top, 0px));
        bottom: var(--keyboard-inset, 0px);
        border-radius: 16px 16px 0 0;
    }

    body.page-split-layout #chatComposer .composer-post .composer-rich-input,
    body.page-split-layout #chatComposer .composer-post textarea {
        max-height: 230px;
    }

    body.page-split-layout #channelComposer .composer-post .composer-rich-input,
    body.page-split-layout #channelComposer .composer-post textarea {
        max-height: 230px;
    }

    body.page-split-layout .split-layout.show-right .right-container,
    body.page-split-layout .split-layout.show-right #chatBox,
    body.page-split-layout .split-layout.show-right #channelBox,
    body.page-split-layout .split-layout.show-right .chat {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        height: 100%;
        max-height: 100%;
        overflow: hidden;
    }

    body.page-split-layout .split-layout.show-right .chat-messages {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    /* Убираем «пустую чёрную» зону: min-height 100% растягивал ленту */
    body.page-split-layout .split-layout.show-right #messagesBox,
    body.page-split-layout .split-layout.show-right #postsBox {
        min-height: 0;
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        width: 100%;
        box-sizing: border-box;
    }

    body.page-split-layout #chatComposer.input-text,
    body.page-split-layout #channelComposer.input-text {
        flex: 0 0 auto;
    }
}

/* Legacy bar — заменён на #plumnetCallDock (plumnet-call.css) */
#plumnetCallBar {
    display: none !important;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2147483640;
    align-items: center;
    gap: 10px;
    padding: max(8px, env(safe-area-inset-top)) 12px 8px;
    box-sizing: border-box;
    background: linear-gradient(180deg, #3d2648 0%, #2a1a32 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    color: #fff;
    font-size: 14px;
}

#plumnetCallBar.is-visible {
    display: flex;
}

#plumnetCallBar .pn-call-bar__info {
    flex: 1;
    min-width: 0;
}

#plumnetCallBar .pn-call-bar__title {
    font-weight: 700;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#plumnetCallBar .pn-call-bar__sub {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 2px;
}

#plumnetCallBar .pn-call-bar__actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

#plumnetCallBar .pn-call-bar__btn {
    border: none;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: #fff;
}

#plumnetCallBar .pn-call-bar__btn--accept {
    background: #2d9d5a;
}

#plumnetCallBar .pn-call-bar__btn--decline,
#plumnetCallBar .pn-call-bar__btn--hangup {
    background: #c44a4a;
}

#plumnetCallBar .pn-call-bar__btn--mute {
    background: rgba(255, 255, 255, 0.15);
}
