.tmo-messages {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    min-height: 620px;
    background: #fff;
    border: 1px solid #e8ece9;
    border-radius: 16px;
    overflow: hidden;
    color: #202b25;
    font-family: inherit;
}

.tmo-messages-sidebar {
    border-right: 1px solid #e8ece9;
    background: #fbfcfb;
}

.tmo-messages-sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid #e8ece9;
}

.tmo-messages-sidebar-header h2 {
    margin: 0 0 5px;
    font-size: 21px;
}

.tmo-messages-sidebar-header p {
    margin: 0;
    color: #78837c;
    font-size: 13px;
}

.tmo-conversation-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    color: inherit;
    text-decoration: none !important;
    border-bottom: 1px solid #edf0ed;
}

.tmo-conversation-item:hover,
.tmo-conversation-item.is-active {
    background: #edf6f0;
}

.tmo-conversation-avatar {
    display: flex;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #dcefe3;
    color: #187447;
    font-weight: 700;
    font-size: 17px;
}

.tmo-conversation-info {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    gap: 5px;
}

.tmo-conversation-info strong {
    font-size: 14px;
}

.tmo-conversation-info small {
    color: #78837c;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 12px;
}

.tmo-message-unread {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    border-radius: 20px;
    background: #16834d;
    color: white;
    font-size: 11px;
}

.tmo-messages-conversation {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.tmo-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 22px;
    border-bottom: 1px solid #e8ece9;
}

.tmo-chat-header div:last-child {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tmo-chat-header small {
    color: #78837c;
    font-size: 12px;
}

.tmo-chat-messages {
    display: flex;
    flex: 1;
    min-height: 350px;
    max-height: 560px;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    padding: 24px;
    background: #fff;
}

.tmo-chat-message {
    display: flex;
    max-width: 78%;
    flex-direction: column;
    gap: 5px;
}

.tmo-chat-message.is-mine {
    align-self: flex-end;
    align-items: flex-end;
}

.tmo-chat-message.is-theirs {
    align-self: flex-start;
    align-items: flex-start;
}

.tmo-chat-bubble {
    padding: 12px 15px;
    border-radius: 14px;
    background: #f0f3f1;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.tmo-chat-message.is-mine .tmo-chat-bubble {
    background: #187447;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.tmo-chat-message.is-theirs .tmo-chat-bubble {
    border-bottom-left-radius: 4px;
}

.tmo-chat-message > small {
    color: #87918b;
    font-size: 10px;
}

.tmo-chat-compose {
    padding: 18px;
    border-top: 1px solid #e8ece9;
}

.tmo-chat-compose textarea {
    display: block;
    width: 100%;
    min-height: 75px;
    padding: 13px;
    border: 1px solid #dfe6e1;
    border-radius: 10px;
    resize: vertical;
    box-sizing: border-box;
}

.tmo-chat-compose-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
}

.tmo-chat-compose-footer small {
    color: #87918b;
    font-size: 11px;
}

.tmo-chat-compose-footer button {
    padding: 11px 20px;
    border: 0;
    border-radius: 8px;
    background: #187447;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

.tmo-chat-compose-footer button:hover {
    background: #125d39;
}

.tmo-messages-empty,
.tmo-messages-welcome,
.tmo-chat-empty {
    padding: 35px 22px;
    text-align: center;
    color: #78837c;
}

.tmo-messages-empty h3,
.tmo-messages-welcome h2 {
    color: #26362d;
}

.tmo-messages-empty-icon,
.tmo-messages-welcome > span {
    display: block;
    margin-bottom: 15px;
    color: #187447;
    font-size: 34px;
}

.tmo-messages-welcome {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.tmo-messages-notice {
    padding: 20px;
    border-radius: 10px;
    background: #f5f7f5;
}

@media (max-width: 767px) {
    .tmo-messages {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .tmo-messages-sidebar {
        border-right: 0;
        border-bottom: 1px solid #e8ece9;
    }

    .tmo-conversation-list {
        max-height: 240px;
        overflow-y: auto;
    }

    .tmo-chat-messages {
        min-height: 300px;
        max-height: 55vh;
        padding: 16px;
    }

    .tmo-chat-compose {
        padding: 12px;
    }

    .tmo-chat-message {
        max-width: 90%;
    }

    .tmo-chat-compose-footer {
        align-items: flex-end;
    }
}

/* Live messaging refinements */
.tmo-chat-messages {
    scroll-behavior: smooth;
}

.tmo-chat-message {
    animation: tmo-message-appear .18s ease-out;
}

@keyframes tmo-message-appear {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* Advertisement enquiry preview cards */
.tmo-ad-enquiry-preview {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 13px;
    margin-bottom: 9px;
    border: 1px solid #d7e8dc;
    border-radius: 10px;
    background: #f7fbf8;
}

.tmo-ad-enquiry-label {
    color: #187447;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.tmo-ad-enquiry-title {
    color: #24372c;
    font-size: 14px;
    line-height: 1.45;
}

.tmo-ad-enquiry-link {
    display: inline-flex;
    align-self: flex-start;
    color: #087443 !important;
    font-size: 12px;
    font-weight: 700;
    text-decoration: underline !important;
}

.tmo-ad-enquiry-body {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.6;
}

.tmo-chat-message.is-mine .tmo-ad-enquiry-preview {
    border-color: rgba(255,255,255,.35);
    background: rgba(255,255,255,.12);
}

.tmo-chat-message.is-mine .tmo-ad-enquiry-label,
.tmo-chat-message.is-mine .tmo-ad-enquiry-title,
.tmo-chat-message.is-mine .tmo-ad-enquiry-link {
    color: #fff !important;
}


/* =====================================================
   TMO 2.0 - MOBILE MESSAGING OVERFLOW FIX
   Date: 2026-11-28
   Scope: Mobile messaging interface only
===================================================== */

@media (max-width: 767px) {

    /* Keep every messaging element within its parent */
    .tmo-messages,
    .tmo-messages * {
        box-sizing: border-box;
    }

    .tmo-messages {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: hidden;
    }

    .tmo-messages-sidebar,
    .tmo-messages-conversation {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    /* Conversation list */
    .tmo-conversation-item {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: hidden;
    }

    .tmo-conversation-info {
        flex: 1 1 0;
        min-width: 0;
        overflow: hidden;
    }

    .tmo-conversation-info strong,
    .tmo-conversation-info small {
        display: block;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Chat header */
    .tmo-chat-header {
        min-width: 0;
        max-width: 100%;
    }

    .tmo-chat-header div:last-child {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    /* Message display area */
    .tmo-chat-messages {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: hidden;
    }

    /* Incoming and outgoing message containers */
    .tmo-chat-message {
        width: fit-content;
        max-width: 90%;
        min-width: 0;
        box-sizing: border-box;
    }

    .tmo-chat-message.is-mine {
        align-self: flex-end;
        margin-left: auto;
        margin-right: 0;
    }

    .tmo-chat-message.is-theirs {
        align-self: flex-start;
        margin-right: auto;
        margin-left: 0;
    }

    /* Message bubbles */
    .tmo-chat-bubble {
        width: auto;
        max-width: 100%;
        min-width: 0;
        overflow-wrap: anywhere;
        word-break: break-word;
        white-space: normal;
    }

    /* Advertisement enquiry cards */
    .tmo-ad-enquiry-preview {
        display: flex;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: hidden;
        overflow-wrap: anywhere;
    }

    .tmo-ad-enquiry-title {
        display: block;
        max-width: 100%;
        min-width: 0;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .tmo-ad-enquiry-link {
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .tmo-ad-enquiry-body {
        max-width: 100%;
        min-width: 0;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    /* Message composer */
    .tmo-chat-compose {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .tmo-chat-compose textarea {
        display: block;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    /* Send button and helper text */
    .tmo-chat-compose-footer {
        display: flex;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }

    .tmo-chat-compose-footer small {
        flex: 1 1 150px;
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .tmo-chat-compose-footer button {
        flex: 0 1 auto;
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    /* Narrow mobile screens */
    @media (max-width: 420px) {

        .tmo-chat-message {
            max-width: 94%;
        }

        .tmo-chat-compose-footer {
            flex-direction: column;
            align-items: stretch;
        }

        .tmo-chat-compose-footer small {
            width: 100%;
            flex: 0 1 auto;
        }

        .tmo-chat-compose-footer button {
            align-self: flex-end;
            max-width: 100%;
        }
    }
}

