/* =========================================================
   NhaWOW Floating Chatbox
   Scope: Shared _ChatBox.cshtml
   ========================================================= */

.hn-chatbox {
    --chat-primary: #00b1fe;
    --chat-primary-dark: #0478c8;
    --chat-primary-deep: #0878d8;
    --chat-primary-soft: #eaf7ff;
    --chat-bg: #f7f9fc;
    --chat-surface: #ffffff;
    --chat-surface-soft: #f4f7fb;
    --chat-border: #e5edf6;
    --chat-text: #172033;
    --chat-muted: #667085;
    --chat-mine: #c7f1ff;
    --chat-radius-xl: 22px;
    --chat-radius-lg: 18px;
    --chat-radius-md: 13px;
    --chat-panel-shadow: 0 24px 70px rgba(15, 23, 42, .22);
    --chat-toggle-shadow: 0 14px 35px rgba(0, 177, 254, .34);
    --chat-focus: 0 0 0 4px rgba(0, 177, 254, .11);

    position: fixed;
    right: 22px;
    bottom: 24px;
    z-index: 99999;
    font-family: inherit;
}

.hn-chatbox,
.hn-chatbox *,
.hn-chatbox *::before,
.hn-chatbox *::after {
    box-sizing: border-box;
}

/* =========================
   Toggle button
   ========================= */

.hn-chat-toggle {
    position: relative;
    min-width: 186px;
    min-height: 58px;
    padding: 9px 16px 9px 10px;
    border: 0;
    border-radius: 999px;
    outline: none;
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-deep) 100%);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--chat-toggle-shadow);
    transition: transform .22s ease, box-shadow .22s ease, filter .22s ease;
}

.hn-chat-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 45px rgba(0, 177, 254, .42);
}

.hn-chat-toggle:active {
    transform: translateY(0) scale(.98);
}

.hn-chat-toggle-icon {
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: rgba(255, 255, 255, .22);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.hn-chat-toggle-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.15;
    text-align: left;
}

.hn-chat-toggle-text strong {
    max-width: 126px;
    font-size: 14px;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hn-chat-toggle-text small {
    max-width: 126px;
    margin-top: 3px;
    font-size: 11px;
    opacity: .9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =========================
   Panel shell
   ========================= */

.hn-chat-panel {
    display: none;
    width: 376px;
    height: 560px;
    max-width: calc(100vw - 28px);
    max-height: calc(100vh - 112px);
    overflow: hidden;
    border: 1px solid rgba(15, 23, 42, .08);
    border-radius: var(--chat-radius-xl);
    background: var(--chat-surface);
    box-shadow: var(--chat-panel-shadow);
    flex-direction: column;
}

.hn-chatbox.open .hn-chat-panel {
    display: flex;
    animation: hnChatPanelIn .22s ease-out;
}

.hn-chatbox.open .hn-chat-toggle {
    display: none;
}

@keyframes hnChatPanelIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* =========================
   Header
   ========================= */

.hn-chat-header {
    position: relative;
    flex: 0 0 auto;
    padding: 15px;
    background: var(--chat-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.hn-chat-header-main {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 11px;
}

.hn-chat-avatar {
    width: 45px;
    height: 45px;
    flex: 0 0 45px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.img_logo_chat {
    height: 30px;
    max-width: 34px;
    margin-right: 2px;
    margin-bottom: 3px;
    display: block;
}

.hn-chat-heading {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.hn-chat-heading strong,
.hn-chat-heading span {
    min-width: 0;
    max-width: 230px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hn-chat-heading strong {
    font-size: 15px;
    font-weight: 850;
}

.hn-chat-heading span {
    margin-top: 3px;
    font-size: 12px;
    opacity: .9;
}

.hn-chat-close {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .16);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .18s ease, transform .18s ease;
}

.hn-chat-close:hover {
    background: rgba(255, 255, 255, .24);
}

.hn-chat-close:active {
    transform: scale(.95);
}

/* =========================
   Pinned property
   ========================= */

.hn-chat-property {
    flex: 0 0 auto;
    min-width: 0;
    padding: 11px 13px;
    border-bottom: 1px solid #e3f2fb;
    background: linear-gradient(180deg, #f3fbff 0%, #ffffff 100%);
    display: flex;
    align-items: center;
    gap: 11px;
}

.hn-chat-property-img-wrap {
    width: 62px;
    height: 48px;
    flex: 0 0 62px;
    border-radius: var(--chat-radius-md);
    overflow: hidden;
    background: #e5e7eb;
}

.hn-chat-property-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.hn-chat-property-info {
    min-width: 0;
    flex: 1 1 auto;
}

.hn-chat-property-title {
    max-height: 34px;
    overflow: hidden;
    font-size: 13px;
    font-weight: 650;
    line-height: 1.28;
    color: var(--chat-text);
}

.hn-chat-property-note {
    margin-top: 4px;
    color: var(--chat-muted);
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* =========================
   Messages
   ========================= */

.hn-chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 15px 13px;
    background: linear-gradient(180deg, #f7f9fc 0%, #f3f6f9 100%);
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.hn-chat-welcome {
    margin: 8px auto 14px;
    padding: 17px 16px;
    border: 1px solid rgba(226, 232, 240, .9);
    border-radius: var(--chat-radius-lg);
    background: rgba(255, 255, 255, .78);
    text-align: center;
    box-shadow: 0 10px 28px rgba(15, 23, 42, .06);
}

.hn-chat-welcome-icon {
    width: 42px;
    height: 42px;
    margin: 0 auto 10px;
    border-radius: 50%;
    background: rgba(0, 177, 254, .11);
    color: #009ee4;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.hn-chat-welcome-title {
    margin-bottom: 5px;
    color: var(--chat-text);
    font-size: 15px;
    font-weight: 850;
}

.hn-chat-welcome-text {
    color: var(--chat-muted);
    font-size: 13px;
    line-height: 1.55;
}

.hn-chat-msg {
    min-width: 0;
    display: flex;
    margin-bottom: 10px;
}

.hn-chat-msg.mine {
    justify-content: flex-end;
}

.hn-chat-bubble {
    max-width: 78%;
    min-width: 0;
    padding: 9px 12px;
    border: 1px solid rgba(226, 232, 240, .82);
    border-radius: 17px;
    background: var(--chat-surface);
    color: #1f2937;
    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    box-shadow: 0 4px 14px rgba(15, 23, 42, .07);
}

.hn-chat-msg.mine .hn-chat-bubble {
    border-color: transparent;
    background: var(--chat-mine);
    color: #111827;
}

.hn-chat-sender {
    margin-bottom: 4px;
    color: var(--chat-primary-dark);
    font-size: 11px;
    font-weight: 800;
}

.hn-chat-time {
    margin-top: 5px;
    color: #5a6981;
    font-size: 10px;
    line-height: 1;
    text-align: right;
}

.hn-chat-system {
    justify-content: center;
}

.hn-chat-system .hn-chat-bubble {
    max-width: 92%;
    border-color: #ffe2a8;
    background: #fff8e6;
    color: #9a6700;
    font-size: 12px;
    text-align: center;
    box-shadow: none;
}

/* =========================
   Composer
   ========================= */

.hn-chat-input-area {
    flex: 0 0 auto;
    padding: 11px 11px 10px;
    border-top: 1px solid #e9eef5;
    background: var(--chat-surface);
}

.hn-chat-input-wrap {
    padding: 5px;
    border: 1px solid #dbe4ef;
    border-radius: 999px;
    background: var(--chat-surface-soft);
    display: flex;
    align-items: center;
    gap: 8px;
}

.hn-chat-input-wrap:focus-within {
    border-color: rgba(0, 177, 254, .75);
    background: var(--chat-surface);
    box-shadow: var(--chat-focus);
}

.hn-chat-input {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    height: 36px;
    border: 0;
    outline: none;
    padding: 0 9px;
    background: transparent;
    color: var(--chat-text);
    font-size: 16px;
}

.hn-chat-send {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-deep) 100%);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.hn-chat-footer-note {
    margin-top: 8px;
    text-align: center;
    font-size: 12px;
}

.hn-chat-footer-note a {
    color: var(--chat-primary);
    font-weight: 700;
    text-decoration: none;
}

.hn-chat-footer-note a:hover {
    text-decoration: underline;
}

/* =========================
   Responsive
   ========================= */

@media (max-width: 1000px) {
    .hn-chatbox {
        right: 16px;
        bottom: 18px;
    }
}

@media (max-width: 576px) {
    .hn-chatbox {
        right: 12px;
        bottom: 14px;
    }

    .hn-chat-toggle {
        min-width: 0;
        width: 56px;
        height: 56px;
        min-height: 56px;
        padding: 0;
        justify-content: center;
    }

    .hn-chat-toggle-icon {
        width: 56px;
        height: 56px;
        background: transparent;
        font-size: 21px;
    }

    .hn-chat-toggle-text {
        display: none;
    }

    .hn-chat-panel {
        width: calc(100vw - 24px);
        height: min(74vh, 640px);
        max-height: calc(100vh - 92px);
        border-radius: 20px;
    }

    .hn-chat-heading strong,
    .hn-chat-heading span {
        max-width: calc(100vw - 152px);
    }

    .hn-chat-bubble {
        max-width: 84%;
    }
}

/* =========================
   Message media + reactions in floating chatbox
   ========================= */

.hn-chat-msg-inner {
    position: relative;
    max-width: 78%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.hn-chat-msg.mine .hn-chat-msg-inner {
    align-items: flex-end;
}

.hn-chat-msg-inner .hn-chat-bubble {
    max-width: 100%;
}

.hn-chat-msg.has-image .hn-chat-msg-inner {
    max-width: min(280px, 76%);
}

.hn-chat-msg.has-image .hn-chat-bubble {
    padding: 7px;
}

.hn-chat-message-body {
    min-width: 0;
    white-space: normal;
}

.hn-chat-message-text {
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.hn-chat-message-image-link {
    display: block;
    max-width: 100%;
    border-radius: 14px;
    overflow: hidden;
    background: #e2e8f0;
    text-decoration: none;
}

.hn-chat-message-image-link:hover,
.hn-chat-message-image-link:focus {
    text-decoration: none;
}

.hn-chat-message-image {
    display: block;
    width: 100%;
    max-width: 260px;
    max-height: 300px;
    object-fit: cover;
}

.hn-chat-message-image-caption {
    margin-top: 7px;
    padding: 0 3px;
}

/* Tin nhắn người kia gửi tới nằm bên trái, icon thả tim nằm bên phải bong bóng. */
.hn-chat-msg:not(.mine) .hn-chat-message-actions {
    align-self: flex-end;
    margin-right: 2px;
    margin-top: -10px;
}

.hn-chat-message-actions {
    margin-top: 4px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity .16s ease, transform .16s ease;
}

.hn-chat-msg:hover .hn-chat-message-actions,
.hn-chat-msg:focus-within .hn-chat-message-actions,
.hn-chat-msg.has-heart .hn-chat-message-actions {
    opacity: 1;
    transform: translateY(0);
}

.hn-chat-message-action {
    min-width: 26px;
    height: 26px;
    padding: 0 8px;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: rgba(255, 255, 255, .96);
    color: #64748b;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 12px;
    line-height: 1;
    box-shadow: 0 6px 16px rgba(15, 23, 42, .08);
    transition: background .16s ease, color .16s ease, transform .16s ease, border-color .16s ease;
}

.hn-chat-message-action:hover {
    background: #eef7ff;
    border-color: #bfdbfe;
    color: var(--chat-primary-dark);
    transform: translateY(-1px);
}

.hn-chat-message-action.js-message-heart.is-active {
    background: #fff1f2;
    border-color: #fecdd3;
    color: #e11d48;
}

.hn-chat-heart-count:empty {
    display: none;
}

.hn-chat-message-recalled {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #64748b;
    font-size: 13px;
    font-style: italic;
    line-height: 1.45;
}

.hn-chat-message-recalled i {
    font-size: 12px;
    color: #94a3b8;
}

.hn-chat-msg.is-recalled .hn-chat-bubble {
    background: #f8fafc;
    border-style: dashed;
    color: #64748b;
}

.hn-chat-msg.is-recalled.mine .hn-chat-bubble {
    background: #eaf7ff;
    border-color: #bfdbfe;
}

.hn-chat-image-btn {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border: 0;
    border-radius: 50%;
    background: #eef7ff;
    color: var(--chat-primary-dark);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.hn-chat-image-btn:hover {
    background: #e0f2fe;
}

.hn-chat-image-btn:disabled {
    cursor: not-allowed;
    opacity: .62;
}

.hn-chat-image-btn.is-loading i {
    animation: hnChatSpin .8s linear infinite;
}

@keyframes hnChatSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@media (max-width: 576px) {
    .hn-chat-msg-inner {
        max-width: 84%;
    }

    .hn-chat-msg.has-image .hn-chat-msg-inner {
        max-width: 80%;
    }

    .hn-chat-message-actions {
        opacity: 1;
        transform: none;
    }

    .hn-chat-message-action {
        min-width: 30px;
        height: 30px;
        padding: 0 9px;
    }

    /* Mobile: nút thu hồi chỉ hiện sau khi giữ lâu vào tin nhắn của mình. */
    .hn-chat-message-action.js-message-recall {
        display: none;
    }

    .hn-chat-msg.is-message-action-open .hn-chat-message-action.js-message-recall {
        display: inline-flex;
    }

    .hn-chat-msg.is-message-action-open .hn-chat-bubble {
        box-shadow: 0 10px 26px rgba(15, 23, 42, .13);
    }

    .hn-chat-message-image {
        max-width: 240px;
        max-height: 280px;
    }
}


/* =========================================================
   Mobile keyboard stability for floating chatbox
   - Khóa scroll nền khi chat mở để iOS Safari không tự kéo trang lên.
   - Khi bàn phím mở, co khung chat từ phía dưới, không đẩy cả panel lên trên.
   ========================================================= */
@media (max-width: 576px) {
    html.hn-floating-chat-scroll-locked,
    html.hn-floating-chat-scroll-locked body {
        width: 100%;
        height: 100%;
        overflow: hidden !important;
        overscroll-behavior: none;
    }

    body.hn-floating-chat-scroll-locked {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        top: var(--hn-floating-page-lock-top, 0px) !important;
        width: 100% !important;
    }

    body.hn-floating-chat-open {
        overflow: hidden !important;
        overscroll-behavior: none;
    }

    body.hn-floating-chat-open .hn-chatbox.open {
        left: 0 !important;
        right: 0 !important;
        top: var(--hn-floating-chat-top, 0px) !important;
        bottom: var(--hn-floating-chat-bottom, 0px) !important;
        width: 100vw !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
        z-index: 200000 !important;
        transform: translateZ(0);
        will-change: top, bottom;
    }

    body.hn-floating-chat-open .hn-chatbox.open .hn-chat-panel {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        border-radius: 18px;
        display: flex;
    }

    body.hn-floating-chat-keyboard-open .hn-chatbox.open {
        padding: 0 !important;
    }

    body.hn-floating-chat-keyboard-open .hn-chatbox.open .hn-chat-panel {
        border-radius: 0;
        border-left: 0;
        border-right: 0;
    }

    body.hn-floating-chat-keyboard-open .hn-chat-header {
        padding: 10px 12px;
    }

    body.hn-floating-chat-keyboard-open .hn-chat-property {
        padding: 8px 10px;
    }

    body.hn-floating-chat-keyboard-open .hn-chat-messages {
        padding-top: 10px;
    }

    body.hn-floating-chat-keyboard-open .hn-chat-input-area {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
}

/* =========================================================
   v3 Mobile floating chat keyboard hard fix
   - Chat ngoài detail là fixed full-screen overlay trên mobile.
   - Dùng visualViewport height; không cộng bottom bằng chiều cao bàn phím.
   ========================================================= */
@media (max-width: 576px) {
    body.hn-floating-chat-scroll-locked {
        position: static !important;
        width: 100% !important;
        overflow: hidden !important;
        overscroll-behavior: none !important;
    }

    html.hn-floating-chat-scroll-locked,
    html.hn-floating-chat-scroll-locked body,
    body.hn-floating-chat-open {
        height: 100% !important;
        overflow: hidden !important;
        overscroll-behavior: none !important;
    }

    body.hn-floating-chat-open .home-hero.list-hero,
    body.hn-floating-chat-keyboard-open .home-hero.list-hero,
    body.hn-floating-chat-open #hnGlobalBackBtn,
    body.hn-floating-chat-keyboard-open #hnGlobalBackBtn {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }

    body.hn-floating-chat-open .hn-chatbox.open,
    body.hn-floating-chat-keyboard-open .hn-chatbox.open {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        top: var(--hn-floating-chat-top, 0px) !important;
        bottom: auto !important;
        width: 100vw !important;
        height: var(--hn-floating-chat-vh, 100dvh) !important;
        min-height: 0 !important;
        max-height: none !important;
        padding: 0 !important;
        z-index: 200000 !important;
        transform: translate3d(0,0,0) !important;
        will-change: height;
    }

    body.hn-floating-chat-open .hn-chatbox.open .hn-chat-panel,
    body.hn-floating-chat-keyboard-open .hn-chatbox.open .hn-chat-panel {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        min-height: 0 !important;
        border-radius: 0 !important;
        border-left: 0 !important;
        border-right: 0 !important;
        display: flex !important;
        animation: none !important;
    }

    body.hn-floating-chat-open .hn-chat-header,
    body.hn-floating-chat-open .hn-chat-property,
    body.hn-floating-chat-open .hn-chat-input-area {
        flex: 0 0 auto !important;
    }

    body.hn-floating-chat-open .hn-chat-messages {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    body.hn-floating-chat-keyboard-open .hn-chat-input-area {
        padding-bottom: max(8px, env(safe-area-inset-bottom)) !important;
    }
}


/* =========================================================
   v4 Zalo-style mobile keyboard final override for Detail floating chat
   Chatbox mở thành một màn chat fixed, bám theo visualViewport.
   ========================================================= */
@media (max-width: 576px) {
    html.hn-floating-chat-scroll-locked,
    html.hn-floating-chat-scroll-locked body,
    body.hn-floating-chat-open {
        width: 100% !important;
        height: 100% !important;
        min-height: 100% !important;
        overflow: hidden !important;
        overscroll-behavior: none !important;
        touch-action: manipulation;
    }

    body.hn-floating-chat-scroll-locked {
        position: static !important;
        left: auto !important;
        right: auto !important;
        top: auto !important;
    }

    body.hn-floating-chat-open .home-hero.list-hero,
    body.hn-floating-chat-open #hnGlobalBackBtn,
    body.hn-floating-chat-open .hn-fab-contact,
    body.hn-floating-chat-open .hn-detail-mobile-contact-bar,
    body.hn-floating-chat-open .property-mobile-contact-bar,
    body.hn-floating-chat-open .detail-mobile-contact-bar,
    body.hn-floating-chat-open .mobile-contact-bar {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }

    body.hn-floating-chat-open .hn-chatbox.open,
    body.hn-floating-chat-keyboard-open .hn-chatbox.open {
        position: fixed !important;
        left: var(--hn-floating-chat-left, 0px) !important;
        top: 0 !important;
        right: auto !important;
        bottom: auto !important;
        width: var(--hn-floating-chat-vw, 100vw) !important;
        height: var(--hn-floating-chat-vh, 100dvh) !important;
        min-height: 0 !important;
        max-height: none !important;
        padding: 0 !important;
        margin: 0 !important;
        z-index: 200000 !important;
        transform: translate3d(0, var(--hn-floating-chat-top, 0px), 0) !important;
        transition: none !important;
        animation: none !important;
        will-change: transform, height;
    }

    body.hn-floating-chat-open .hn-chatbox.open .hn-chat-panel,
    body.hn-floating-chat-keyboard-open .hn-chatbox.open .hn-chat-panel {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        min-height: 0 !important;
        border-radius: 0 !important;
        border-left: 0 !important;
        border-right: 0 !important;
        display: flex !important;
        animation: none !important;
        overflow: hidden !important;
    }

    body.hn-floating-chat-open .hn-chat-header,
    body.hn-floating-chat-open .hn-chat-property,
    body.hn-floating-chat-open .hn-chat-input-area {
        flex: 0 0 auto !important;
        transition: none !important;
    }

    body.hn-floating-chat-open .hn-chat-messages,
    body.hn-floating-chat-keyboard-open .hn-chat-messages {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        scroll-behavior: auto !important;
        transition: none !important;
    }

    body.hn-floating-chat-keyboard-open .hn-chat-input-area,
    body.hn-floating-chat-open .hn-chat-input-area {
        padding-bottom: max(8px, env(safe-area-inset-bottom)) !important;
    }
}

/* =========================================================
   GLOBAL FINAL MOBILE INPUT ZOOM GUARD
   File chatbox.css đang được _Layout load sau @RenderSection("Styles"),
   nên rule này chặn cả các CSS riêng từng trang đang set input/select2 12px/14px !important.
   ========================================================= */
@media (max-width: 1000px) {
    html body input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="hidden"]),
    html body select,
    html body textarea,
    html body [contenteditable="true"],
    html body .select2-search--dropdown .select2-search__field,
    html body .select2-container .select2-search__field,
    html body .hn-auth-modal input,
    html body #profileOverlay input,
    html body #changePwOverlay input,
    html body .hn-chat-input,
    html body #hnChatMessageInput,
    html body .hn-chat-compose input {
        font-size: 16px !important;
        max-width: 100% !important;
    }
}

/* Avatar người đang chat */
.hn-chat-avatar.has-image {
    background: #f8fafc;
}

.hn-chat-avatar img:not(.img_logo_chat) {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.hn-chat-avatar span {
    width: 100%;
    height: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    color: #fff;
    font-size: 18px;
    font-weight: 950;
    line-height: 1;
}
