/*
 * Messenger phone header.
 *
 * The desktop header carries several independent controls. On narrow screens
 * it becomes a two-row layout so contact identity and actions never compete
 * for the same horizontal space.
 */

@media (max-width: 768px) {
    .chat-header-info,
    .chat-header-name,
    .chat-header-status,
    #messenger-translation-status-slot {
        min-width: 0;
    }

    .chat-header-name,
    .chat-header-status {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .chat-header-name .header-tag {
        flex: 0 0 auto;
    }

    .chat-header-actions > .tag-badges {
        display: none;
    }

    .message {
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .compose-row,
    .compose-input-wrapper,
    .compose-input {
        min-width: 0;
    }

    .compose-input {
        max-width: 100%;
    }

    .messenger-translation-modal {
        z-index: 9000;
    }
}

@media (max-width: 768px) {
    .messenger-layout.chat-open .chat-header {
        display: grid;
        grid-template-columns: 44px 44px minmax(0, 1fr);
        grid-template-areas:
            "back avatar identity"
            "actions actions actions";
        align-items: center;
        column-gap: 8px;
        row-gap: 7px;
        min-width: 0;
        padding: 8px 10px;
    }

    .messenger-layout.chat-open .chat-header > #back-btn {
        grid-area: back;
        align-items: center;
        justify-content: center;
        width: 44px;
        min-width: 44px;
        height: 44px;
        padding: 0;
        border-radius: 10px;
    }

    .messenger-layout.chat-open .chat-header > .avatar {
        grid-area: avatar;
        width: 44px;
        height: 44px;
        margin: 0;
    }

    .messenger-layout.chat-open .chat-header > .chat-header-info {
        grid-area: identity;
        overflow: hidden;
    }

    .messenger-layout.chat-open .chat-header-name {
        font-size: 0.88rem;
    }

    .messenger-layout.chat-open .chat-header-status {
        display: block;
        margin-top: 1px;
        font-size: 0.68rem;
    }

    .messenger-layout.chat-open #messenger-translation-status-slot {
        overflow: hidden;
    }

    .messenger-layout.chat-open .messenger-translation-status {
        max-width: 100%;
    }

    .messenger-layout.chat-open .chat-header > .chat-header-actions {
        grid-area: actions;
        position: relative;
        display: flex !important;
        align-items: center;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 4px !important;
        width: 100%;
        min-width: 0;
        padding-top: 7px;
        border-top: 1px solid var(--border-color);
    }

    .messenger-layout.chat-open .chat-header-actions .header-action-divider {
        display: none;
    }

    .messenger-layout.chat-open .chat-header-actions .header-action-group {
        flex: 0 0 auto;
        gap: 2px;
        margin-left: 0 !important;
        padding: 0;
    }

    .messenger-layout.chat-open .chat-header-actions > .header-action-group:nth-last-of-type(2) {
        margin-left: auto !important;
    }

    .messenger-layout.chat-open .chat-header-actions .conv-actions-bar {
        gap: 2px;
        margin-left: 0;
    }

    .messenger-layout.chat-open .chat-header-actions .chat-action-btn,
    .messenger-layout.chat-open .chat-header-actions .messenger-translation-control {
        width: 44px;
        min-width: 44px;
        height: 44px;
        padding: 0;
        border-radius: 10px;
    }

    .messenger-layout.chat-open .chat-header-actions .assign-dropdown {
        right: auto;
        left: 0;
        max-width: calc(100vw - 20px);
    }

    .messenger-layout.chat-open .chat-header-actions .contact-menu {
        top: calc(100% + 7px);
        right: 0;
        max-width: calc(100vw - 20px);
        max-height: calc(100dvh - 180px);
        overflow-y: auto;
    }

    .messenger-layout.chat-open .compose-row {
        gap: 6px;
        padding: 8px;
    }

    .messenger-layout.chat-open .compose-actions,
    .messenger-layout.chat-open .compose-right-actions {
        flex: 0 0 auto;
        gap: 2px;
    }

    .messenger-layout.chat-open .compose-actions .chat-action-btn,
    .messenger-layout.chat-open .compose-right-actions .chat-action-btn,
    .messenger-layout.chat-open .compose-send {
        width: 44px;
        min-width: 44px;
        height: 44px;
    }

    .messenger-layout.chat-open .compose-input {
        min-height: 44px;
        padding-inline: 10px;
    }

    .messenger-layout.chat-open .emoji-picker {
        right: 0;
        left: auto;
        width: min(340px, calc(100vw - 16px));
        max-width: calc(100vw - 16px);
    }

    .messenger-translation-dialog {
        max-height: calc(100dvh - 8px);
    }
}
