/* =========================================================
 * MYSHOES AI GLOBAL CHAT
 * COMPLETE STYLESHEET
 *
 * V1.1.1
 *
 * - Launcher icon cách cạnh phải rộng hơn
 * - Font toàn chatbot lớn hơn, dễ đọc hơn
 * - Mobile panel chừa khoảng trống phía trên
 * - Mobile textarea >= 16px chống Safari/iPhone auto zoom
 * - Pulse ring + shake
 * - Product cards
 * - Checkout actions
 * - Login popup
 * ========================================================= */


/* =========================================================
 * ROOT / RESET
 * ========================================================= */

.msai-root,
.msai-root * {
    box-sizing: border-box;
}

.msai-root {
    --msai-primary: #0A437F;
    --msai-primary-dark: #07345F;

    --msai-danger: #D92D20;

    --msai-text: #172033;
    --msai-muted: #667085;

    --msai-border: #E6EAF0;
    --msai-bg: #F7F9FC;
    --msai-white: #FFFFFF;

    font-family: Arial, Helvetica, sans-serif !important;

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

.msai-root *,
.msai-root button,
.msai-root input,
.msai-root textarea,
.msai-root select,
.msai-root a,
.msai-root strong,
.msai-root small {
    font-family: Arial, Helvetica, sans-serif !important;
}


/* =========================================================
 * FLOATING MYSHOES AI LAUNCHER
 * ========================================================= */

.msai-launcher {
    position: fixed;

    /*
     * Tăng khoảng cách với cạnh phải.
     */
    right: 24px;
    bottom: 26px;

    z-index: 99970;

    width: 86px;
    height: 86px;

    min-width: 0;

    margin: 0;
    padding: 0;

    border: 0 !important;
    outline: 0 !important;

    border-radius: 50% !important;

    background: transparent !important;

    box-shadow: none !important;

    display: flex;
    align-items: center;
    justify-content: center;

    overflow: visible;

    cursor: pointer;

    -webkit-appearance: none;
    appearance: none;

    touch-action: manipulation;

    animation:
        msaiLauncherShake
        4.8s
        ease-in-out
        infinite;

    transition:
        transform 0.18s ease,
        opacity 0.18s ease;
}


/* Không dùng text launcher cũ */
.msai-launcher-copy {
    display: none !important;
}


/* Không dùng icon CSS/SVG cũ */
.msai-launcher-icon,
.msai-chat-bubble-svg,
.msai-launcher-ai-text,
.msai-launcher-ai-spark {
    display: none !important;
}


/* =========================================================
 * PNG LAUNCHER IMAGE
 * ========================================================= */

.msai-launcher-image {
    position: relative;

    z-index: 3;

    display: block;

    width: 86px;
    height: 86px;

    max-width: none !important;

    margin: 0;
    padding: 0;

    border: 0;

    background: transparent;

    object-fit: contain;

    pointer-events: none;

    filter:
        drop-shadow(
            0 4px 7px
            rgba(10, 67, 127, 0.20)
        );

    transition:
        transform 0.18s ease,
        filter 0.18s ease;
}


/* =========================================================
 * PULSE RINGS
 * ========================================================= */

.msai-launcher::before,
.msai-launcher::after {
    content: '';

    position: absolute;

    left: 50%;
    top: 50%;

    border-radius: 50%;

    pointer-events: none;

    opacity: 0;

    transform:
        translate(-50%, -50%)
        scale(0.68);

    z-index: 1;
}


/* Vòng trong */
.msai-launcher::before {
    width: 92px;
    height: 92px;

    border:
        3px solid
        rgba(20, 135, 225, 0.72);

    box-shadow:
        0 0 10px
        rgba(20, 145, 230, 0.24);

    animation:
        msaiPulseRingStrong
        2.5s
        ease-out
        infinite;
}


/* Vòng ngoài */
.msai-launcher::after {
    width: 106px;
    height: 106px;

    border:
        2px solid
        rgba(38, 181, 221, 0.52);

    box-shadow:
        0 0 13px
        rgba(38, 181, 221, 0.18);

    animation:
        msaiPulseRingStrong
        2.5s
        ease-out
        0.78s
        infinite;
}


/* =========================================================
 * PULSE ANIMATION
 * ========================================================= */

@keyframes msaiPulseRingStrong {

    0% {
        transform:
            translate(-50%, -50%)
            scale(0.68);

        opacity: 0;
    }

    12% {
        opacity: 0.95;
    }

    32% {
        opacity: 0.80;
    }

    68% {
        opacity: 0.35;
    }

    100% {
        transform:
            translate(-50%, -50%)
            scale(1.22);

        opacity: 0;
    }
}


/* =========================================================
 * SHAKE ANIMATION
 * ========================================================= */

@keyframes msaiLauncherShake {

    0%,
    82%,
    100% {
        transform:
            translateX(0)
            rotate(0deg);
    }

    84% {
        transform:
            translateX(-2px)
            rotate(-2deg);
    }

    86% {
        transform:
            translateX(2px)
            rotate(2deg);
    }

    88% {
        transform:
            translateX(-2px)
            rotate(-1.5deg);
    }

    90% {
        transform:
            translateX(2px)
            rotate(1.5deg);
    }

    92% {
        transform:
            translateX(-1px)
            rotate(-1deg);
    }

    94% {
        transform:
            translateX(1px)
            rotate(1deg);
    }

    96% {
        transform:
            translateX(0)
            rotate(0deg);
    }
}


/* Desktop hover */
.msai-launcher:hover {
    animation-play-state: paused;
}

.msai-launcher:hover .msai-launcher-image {
    transform: scale(1.035);

    filter:
        drop-shadow(
            0 6px 10px
            rgba(10, 67, 127, 0.26)
        );
}

.msai-launcher:active .msai-launcher-image {
    transform: scale(0.96);
}


/* =========================================================
 * UNREAD BADGE
 * ========================================================= */

.msai-unread {
    position: absolute;

    right: 3px;
    top: 4px;

    z-index: 5;

    min-width: 21px;
    height: 21px;

    padding: 0 5px;

    border-radius: 999px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #E5484D;

    color: #FFFFFF;

    border: 2px solid #FFFFFF;

    font-size: 11px;
    font-weight: 700;

    line-height: 1;

    box-shadow:
        0 2px 7px
        rgba(0, 0, 0, 0.16);
}

.msai-unread[hidden] {
    display: none !important;
}


/* =========================================================
 * CHAT PANEL DESKTOP
 * ========================================================= */

.msai-panel {
    position: fixed;

    right: 28px;
    bottom: 112px;

    z-index: 99975;

    width: 440px;

    height:
        min(
            690px,
            calc(100vh - 140px)
        );

    max-width:
        calc(100vw - 56px);

    background: #FFFFFF;

    border:
        1px solid
        rgba(16, 24, 40, 0.08);

    border-radius: 20px;

    overflow: hidden;

    box-shadow:
        0 24px 70px
        rgba(16, 24, 40, 0.22);

    display: flex;
    flex-direction: column;

    opacity: 0;
    visibility: hidden;

    pointer-events: none;

    transform:
        translateY(14px)
        scale(0.985);

    transform-origin:
        bottom right;

    transition:
        opacity 0.18s ease,
        transform 0.18s ease,
        visibility 0.18s ease;
}

.msai-panel.msai-open {
    opacity: 1;
    visibility: visible;

    pointer-events: auto;

    transform:
        translateY(0)
        scale(1);
}


/* =========================================================
 * CHAT HEADER
 * ========================================================= */

.msai-header {
    min-height: 72px;

    padding:
        11px
        13px
        11px
        15px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    flex: 0 0 auto;

    border-bottom:
        1px solid
        var(--msai-border);

    background: #FFFFFF;
}

.msai-brand {
    display: flex;
    align-items: center;

    gap: 11px;

    min-width: 0;
}


/* =========================================================
 * HEADER AVATAR
 * ========================================================= */

.msai-avatar {
    width: 44px;
    height: 44px;

    flex: 0 0 44px;

    border-radius: 12px;

    overflow: hidden;

    background:
        var(--msai-primary);

    display: flex;
    align-items: center;
    justify-content: center;

    color: #FFFFFF;

    font-size: 21px;
    font-weight: 700;
}

.msai-avatar-image {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: contain;

    background: #FFFFFF;
}


/* =========================================================
 * HEADER TEXT
 * ========================================================= */

.msai-title {
    font-size: 15.5px;

    font-weight: 700;

    color:
        var(--msai-text);

    line-height: 1.25;
}

.msai-subtitle {
    margin-top: 4px;

    font-size: 12px;
    font-weight: 400;

    color:
        var(--msai-muted);

    display: flex;
    align-items: center;

    gap: 5px;
}

.msai-online-dot {
    width: 7px;
    height: 7px;

    flex: 0 0 7px;

    border-radius: 50%;

    background: #12B76A;

    display: inline-block;
}


/* =========================================================
 * HEADER ACTIONS
 * ========================================================= */

.msai-header-actions {
    display: flex;
    align-items: center;

    gap: 5px;

    flex: 0 0 auto;
}

.msai-icon-button {
    width: 36px;
    height: 36px;

    padding: 0;

    border: 0;
    border-radius: 10px;

    background: transparent;

    color: #667085;

    cursor: pointer;

    font-size: 23px;
    font-weight: 400;

    display: flex;
    align-items: center;
    justify-content: center;

    touch-action: manipulation;

    transition:
        background 0.15s ease,
        color 0.15s ease;
}

.msai-icon-button:hover {
    background: #F2F4F7;

    color: #344054;
}


/* =========================================================
 * MESSAGES AREA
 * ========================================================= */

.msai-messages {
    flex: 1 1 auto;

    min-width: 0;
    min-height: 0;

    width: 100%;

    overflow-y: auto;
    overflow-x: hidden;

    padding:
        17px
        15px
        13px;

    background:
        linear-gradient(
            180deg,
            #FBFCFE 0%,
            #F7F9FC 100%
        );

    scroll-behavior: smooth;

    overscroll-behavior: contain;

    -webkit-overflow-scrolling: touch;
}


/* =========================================================
 * MESSAGE ROW
 * ========================================================= */

.msai-message-row {
    display: flex;

    width: 100%;

    min-width: 0;

    margin:
        0
        0
        11px;
}

.msai-message-row.msai-user {
    justify-content: flex-end;
}

.msai-message-row.msai-bot {
    justify-content: flex-start;
}


/* =========================================================
 * MESSAGE BUBBLE
 * ========================================================= */

.msai-bubble {
    max-width: 87%;

    min-width: 0;

    padding:
        11px
        13px;

    border-radius: 14px;

    font-size: 14px;
    font-weight: 400;

    line-height: 1.55;

    white-space: pre-wrap;

    word-break: break-word;

    overflow-wrap: anywhere;
}

.msai-user .msai-bubble {
    background:
        var(--msai-primary);

    color: #FFFFFF;

    border-bottom-right-radius: 5px;
}

.msai-bot .msai-bubble {
    background: #FFFFFF;

    color: #344054;

    border:
        1px solid
        #E8ECF2;

    border-bottom-left-radius: 5px;

    box-shadow:
        0 2px 7px
        rgba(16, 24, 40, 0.03);
}

.msai-system .msai-bubble {
    background: #ECFDF3;

    color: #027A48;

    border-color: #ABEFC6;
}


/* =========================================================
 * LOADING DOTS
 * ========================================================= */

.msai-loading .msai-bubble {
    display: flex;

    gap: 5px;

    align-items: center;

    min-width: 50px;
}

.msai-loading-dot {
    width: 7px;
    height: 7px;

    border-radius: 50%;

    background: #98A2B3;

    animation:
        msaiBlink
        1.1s
        infinite
        ease-in-out;
}

.msai-loading-dot:nth-child(2) {
    animation-delay: 0.12s;
}

.msai-loading-dot:nth-child(3) {
    animation-delay: 0.24s;
}

@keyframes msaiBlink {

    0%,
    60%,
    100% {
        opacity: 0.35;

        transform:
            translateY(0);
    }

    30% {
        opacity: 1;

        transform:
            translateY(-3px);
    }
}


/* =========================================================
 * PRODUCT RECOMMENDATIONS
 * ========================================================= */

.msai-products {
    width: 100%;

    min-width: 0;

    margin:
        7px
        0
        14px;
}

.msai-products-title {
    margin:
        0
        0
        8px
        2px;

    font-size: 12.5px;

    font-weight: 700;

    line-height: 1.4;

    color:
        var(--msai-primary);
}


/* =========================================================
 * PRODUCT CARD
 * ========================================================= */

.msai-product-card {
    display: flex;

    width: 100%;

    min-width: 0;

    gap: 11px;

    padding: 10px;

    margin-bottom: 8px;

    background: #FFFFFF;

    border:
        1px solid
        var(--msai-border);

    border-radius: 13px;

    color: inherit;

    text-decoration: none;

    box-shadow:
        0 2px 8px
        rgba(16, 24, 40, 0.03);

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}

.msai-product-card:hover {
    border-color: #CED8E5;

    box-shadow:
        0 4px 12px
        rgba(16, 24, 40, 0.06);
}


/* =========================================================
 * PRODUCT IMAGE
 * ========================================================= */

.msai-product-image {
    width: 74px;
    height: 74px;

    flex: 0 0 74px;

    border-radius: 10px;

    overflow: hidden;

    background: #F7F8FA;

    border:
        1px solid
        #F0F2F5;

    display: flex;
    align-items: center;
    justify-content: center;
}

.msai-product-image img {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: contain;
}


/* =========================================================
 * PRODUCT CONTENT
 * ========================================================= */

.msai-product-body {
    min-width: 0;

    flex: 1 1 auto;
}

.msai-product-name {
    font-size: 13.5px;

    line-height: 1.4;

    font-weight: 700;

    color: #253047;
}

.msai-product-meta {
    margin-top: 4px;

    color: #98A2B3;

    font-size: 10.5px;
    font-weight: 400;

    line-height: 1.4;
}

.msai-product-price {
    margin-top: 5px;

    font-size: 14.5px;

    font-weight: 700;

    color: #D92D20;
}

.msai-product-price del {
    margin-left: 6px;

    color: #98A2B3;

    font-size: 10.5px;

    font-weight: 400;
}

.msai-product-note {
    margin-top: 5px;

    font-size: 10.5px;
    font-weight: 400;

    color: #475467;

    line-height: 1.45;

    display: -webkit-box;

    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;

    overflow: hidden;
}

.msai-product-size {
    margin-top: 5px;

    font-size: 10.5px;

    color:
        var(--msai-primary);

    font-weight: 700;
}


/* =========================================================
 * PRODUCT ACTION BUTTONS
 * ========================================================= */

.msai-product-actions {
    margin-top: 8px;

    display: flex;

    flex-wrap: wrap;

    gap: 7px;
}

.msai-product-actions a,
.msai-product-actions button {
    min-height: 32px;

    padding:
        0
        10px;

    border-radius: 8px;

    font-size: 11.5px;
    font-weight: 700;

    line-height: 1.2;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    cursor: pointer;

    text-decoration: none;

    touch-action: manipulation;

    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease;
}

.msai-product-actions a {
    color:
        var(--msai-primary);

    background: #F3F7FB;

    border:
        1px solid
        #DCE8F4;
}

.msai-product-actions a:hover {
    color:
        var(--msai-primary-dark);

    background: #EDF4FA;
}

.msai-product-actions button {
    color: #FFFFFF;

    background:
        var(--msai-primary);

    border:
        1px solid
        var(--msai-primary);
}

.msai-product-actions button:hover {
    background:
        var(--msai-primary-dark);

    border-color:
        var(--msai-primary-dark);
}


/* =========================================================
 * GENERIC ACTIONS
 * ========================================================= */

.msai-action-row {
    display: flex;

    flex-wrap: wrap;

    gap: 8px;

    width: 100%;

    margin:
        5px
        0
        14px;
}

.msai-action {
    min-height: 36px;

    padding:
        8px
        12px;

    border-radius: 9px;

    border:
        1px solid
        #D7E2EE;

    background: #FFFFFF;

    color:
        var(--msai-primary);

    font-size: 11.5px;

    font-weight: 700;

    line-height: 1.3;

    cursor: pointer;

    touch-action: manipulation;

    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease;
}

.msai-action:hover {
    background: #F4F8FC;
}

.msai-action.msai-primary {
    color: #FFFFFF;

    border-color:
        var(--msai-primary);

    background:
        var(--msai-primary);
}

.msai-action.msai-primary:hover {
    border-color:
        var(--msai-primary-dark);

    background:
        var(--msai-primary-dark);
}

.msai-action.msai-danger {
    color: #B42318;

    border-color: #FECDCA;

    background: #FFF7F6;
}

.msai-action:disabled {
    opacity: 0.55;

    cursor: not-allowed;
}


/* =========================================================
 * QUICK PROMPTS
 * ========================================================= */

.msai-quick-prompts {
    flex: 0 0 auto;

    width: 100%;

    min-width: 0;

    padding:
        9px
        12px
        5px;

    background: #FFFFFF;

    display: flex;

    gap: 7px;

    overflow-x: auto;
    overflow-y: hidden;

    border-top:
        1px solid
        #F0F2F5;

    scrollbar-width: none;

    -webkit-overflow-scrolling: touch;
}

.msai-quick-prompts::-webkit-scrollbar {
    display: none;
}

.msai-quick-prompts button {
    flex: 0 0 auto;

    border:
        1px solid
        #DCE5EF;

    background: #FFFFFF;

    color: #475467;

    padding:
        8px
        10px;

    border-radius: 999px;

    font-size: 10.5px;

    font-weight: 600;

    cursor: pointer;

    white-space: nowrap;

    touch-action: manipulation;

    transition:
        border-color 0.15s ease,
        color 0.15s ease,
        background 0.15s ease;
}

.msai-quick-prompts button:hover {
    border-color: #A9BFD7;

    color:
        var(--msai-primary);

    background: #F8FBFE;
}


/* =========================================================
 * COMPOSER DESKTOP
 * ========================================================= */

.msai-composer {
    flex: 0 0 auto;

    width: 100%;

    min-width: 0;

    background: #FFFFFF;

    padding:
        10px
        11px
        9px;

    display: flex;

    align-items: flex-end;

    gap: 8px;

    border-top:
        1px solid
        var(--msai-border);
}

.msai-composer textarea {
    flex: 1 1 auto;

    width: 100%;

    min-width: 0;

    min-height: 42px;
    max-height: 105px;

    resize: none;

    overflow-y: auto;
    overflow-x: hidden;

    border:
        1px solid
        #DFE5EC;

    border-radius: 12px;

    padding:
        10px
        12px;

    outline: none;

    font-size: 14px;

    font-weight: 400;

    line-height: 1.45;

    color: #344054;

    background: #FFFFFF;

    -webkit-appearance: none;
    appearance: none;

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}

.msai-composer textarea::placeholder {
    color: #98A2B3;
}

.msai-composer textarea:focus {
    border-color: #94B3D2;

    box-shadow:
        0 0 0 3px
        rgba(10, 67, 127, 0.07);
}

.msai-composer button {
    width: 42px;
    height: 42px;

    flex: 0 0 42px;

    padding: 0;

    border: 0;

    border-radius: 12px;

    background:
        var(--msai-primary);

    color: #FFFFFF;

    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;

    touch-action: manipulation;

    transition:
        background 0.15s ease,
        opacity 0.15s ease;
}

.msai-composer button:hover {
    background:
        var(--msai-primary-dark);
}

.msai-composer button:disabled {
    opacity: 0.55;

    cursor: not-allowed;
}


/* =========================================================
 * FOOTER NOTE
 * ========================================================= */

.msai-footer-note {
    flex: 0 0 auto;

    width: 100%;

    padding:
        0
        12px
        9px;

    background: #FFFFFF;

    text-align: center;

    font-size: 9.5px;

    font-weight: 400;

    line-height: 1.4;

    color: #98A2B3;
}


/* =========================================================
 * LOGIN POPUP
 * ========================================================= */

.msai-login-overlay {
    position: fixed;

    inset: 0;

    z-index: 100005;

    padding: 12px;

    background:
        rgba(15, 23, 42, 0.55);

    display: flex;
    align-items: center;
    justify-content: center;

    opacity: 0;
    visibility: hidden;

    pointer-events: none;

    transition:
        opacity 0.16s ease,
        visibility 0.16s ease;
}

.msai-login-overlay.msai-open {
    opacity: 1;
    visibility: visible;

    pointer-events: auto;
}

.msai-login-dialog {
    width:
        min(
            480px,
            calc(100vw - 24px)
        );

    height:
        min(
            690px,
            calc(100vh - 28px)
        );

    background: #FFFFFF;

    border-radius: 18px;

    overflow: hidden;

    box-shadow:
        0 25px 80px
        rgba(0, 0, 0, 0.28);

    display: flex;
    flex-direction: column;
}

.msai-login-head {
    height: 50px;

    flex: 0 0 50px;

    padding:
        0
        12px
        0
        16px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    border-bottom:
        1px solid
        #EDF0F4;

    color: #172033;

    font-size: 14px;

    font-weight: 700;
}

.msai-login-head button {
    width: 34px;
    height: 34px;

    padding: 0;

    border: 0;

    border-radius: 9px;

    background: transparent;

    font-size: 24px;

    font-weight: 400;

    color: #667085;

    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;

    touch-action: manipulation;
}

.msai-login-head button:hover {
    background: #F2F4F7;
}

.msai-login-dialog iframe {
    flex: 1 1 auto;

    min-height: 0;

    width: 100%;

    border: 0;

    background: #FFFFFF;
}


/* =========================================================
 * TABLET
 * ========================================================= */

@media (max-width: 768px) and (min-width: 641px) {

    .msai-launcher {
        right: 20px;
        bottom: 30px;

        width: 84px;
        height: 84px;
    }

    .msai-launcher-image {
        width: 84px;
        height: 84px;
    }

    .msai-launcher::before {
        width: 90px;
        height: 90px;
    }

    .msai-launcher::after {
        width: 103px;
        height: 103px;
    }

    .msai-panel {
        right: 22px;

        bottom: 112px;

        width:
            min(
                430px,
                calc(100vw - 44px)
            );
    }
}


/* =========================================================
 * MOBILE
 * ========================================================= */

@media (max-width: 640px) {

    /* =====================================================
     * FLOATING ICON MOBILE
     * ===================================================== */

    .msai-launcher {
        /*
         * Cách cạnh phải nhiều hơn bản trước.
         */
        right: 14px;

        /*
         * Nâng icon cao hơn.
         */
        bottom:
            calc(
                92px +
                env(safe-area-inset-bottom)
            );

        width: 76px;
        height: 76px;

        min-width: 0;

        padding: 0;

        border: 0 !important;

        background:
            transparent !important;

        box-shadow:
            none !important;
    }

    .msai-launcher-image {
        width: 76px;
        height: 76px;

        object-fit: contain;

        filter:
            drop-shadow(
                0 4px 6px
                rgba(10, 67, 127, 0.18)
            );
    }

    .msai-launcher::before {
        width: 80px;
        height: 80px;

        border-width: 3px;
    }

    .msai-launcher::after {
        width: 92px;
        height: 92px;

        border-width: 2px;
    }

    .msai-launcher:hover {
        transform: none;

        animation-play-state: running;
    }

    .msai-launcher:hover
    .msai-launcher-image {
        transform: none;

        filter:
            drop-shadow(
                0 4px 6px
                rgba(10, 67, 127, 0.18)
            );
    }

    .msai-launcher:active
    .msai-launcher-image {
        transform: scale(0.95);
    }

    .msai-unread {
        right: 3px;
        top: 4px;
    }


    /* =====================================================
     * CHAT PANEL MOBILE
     *
     * Chừa khoảng trống phía trên rõ ràng hơn.
     *
     * Không dùng panel gần full-screen như trước.
     * ===================================================== */

    .msai-panel {
        /*
         * Chừa ~60px ở top.
         */
        top:
            calc(
                60px +
                env(safe-area-inset-top)
            );

        right: 8px;
        left: 8px;

        bottom:
            calc(
                8px +
                env(safe-area-inset-bottom)
            );

        width: auto;

        max-width: none;

        /*
         * top + bottom quyết định chiều cao.
         */
        height: auto;

        max-height: none;

        border-radius: 18px;

        overflow: hidden;

        transform-origin:
            center bottom;
    }


    /* =====================================================
     * HEADER MOBILE
     * ===================================================== */

    .msai-header {
        min-height: 64px;

        padding:
            9px
            10px
            9px
            12px;
    }

    .msai-avatar {
        width: 40px;
        height: 40px;

        flex-basis: 40px;

        border-radius: 10px;
    }

    .msai-title {
        font-size: 15px;
    }

    .msai-subtitle {
        font-size: 11.5px;
    }

    .msai-icon-button {
        width: 34px;
        height: 34px;

        font-size: 22px;
    }


    /* =====================================================
     * MESSAGES MOBILE
     * ===================================================== */

    .msai-messages {
        width: 100%;

        min-width: 0;

        padding:
            14px
            10px
            10px;

        overflow-x: hidden;
    }

    .msai-bubble {
        max-width: 91%;

        /*
         * Tăng chữ chat rõ ràng hơn.
         */
        font-size: 14px;

        line-height: 1.5;
    }


    /* =====================================================
     * PRODUCT MOBILE
     * ===================================================== */

    .msai-products-title {
        font-size: 12px;
    }

    .msai-product-card {
        gap: 9px;

        padding: 9px;

        border-radius: 12px;
    }

    .msai-product-image {
        width: 64px;
        height: 64px;

        flex-basis: 64px;
    }

    .msai-product-name {
        font-size: 13px;
    }

    .msai-product-meta {
        font-size: 10px;
    }

    .msai-product-price {
        font-size: 14px;
    }

    .msai-product-price del {
        font-size: 10px;
    }

    .msai-product-note {
        font-size: 10px;
    }

    .msai-product-size {
        font-size: 10px;
    }

    .msai-product-actions a,
    .msai-product-actions button {
        min-height: 32px;

        padding:
            0
            9px;

        font-size: 11px;
    }

    .msai-action {
        min-height: 36px;

        padding:
            8px
            11px;

        font-size: 11px;
    }


    /* =====================================================
     * QUICK PROMPTS MOBILE
     * ===================================================== */

    .msai-quick-prompts {
        width: 100%;

        min-width: 0;

        padding:
            8px
            10px
            5px;
    }

    .msai-quick-prompts button {
        padding:
            8px
            10px;

        font-size: 10.5px;
    }


    /* =====================================================
     * COMPOSER MOBILE
     *
     * IMPORTANT:
     * font-size 16px ngăn Safari/iPhone auto zoom.
     * ===================================================== */

    .msai-composer {
        width: 100%;

        min-width: 0;

        padding:
            8px
            9px
            calc(
                8px +
                env(safe-area-inset-bottom)
            );

        gap: 8px;
    }

    .msai-composer textarea {
        width: 100%;

        min-width: 0;

        min-height: 44px;
        max-height: 100px;

        /*
         * Không được giảm dưới 16px.
         */
        font-size: 16px !important;

        line-height: 1.4;

        padding:
            10px
            12px;

        border-radius: 12px;

        transform: none !important;

        zoom: 1 !important;
    }

    .msai-composer textarea:focus {
        font-size: 16px !important;

        transform: none !important;

        zoom: 1 !important;
    }

    .msai-composer button {
        width: 44px;
        height: 44px;

        flex-basis: 44px;

        border-radius: 12px;
    }


    .msai-footer-note {
        font-size: 9.5px;
    }


    /* =====================================================
     * LOGIN MOBILE
     * ===================================================== */

    .msai-login-overlay {
        padding:
            7px
            7px
            calc(
                7px +
                env(safe-area-inset-bottom)
            );
    }

    .msai-login-dialog {
        width:
            calc(100vw - 14px);

        height:
            calc(100dvh - 30px);

        max-width:
            calc(100vw - 14px);

        max-height:
            calc(100dvh - 30px);

        border-radius: 16px;
    }

    .msai-login-head {
        font-size: 14px;
    }
}


/* =========================================================
 * VERY SMALL MOBILE
 * ========================================================= */

@media (max-width: 380px) {

    .msai-launcher {
        right: 12px;

        bottom:
            calc(
                88px +
                env(safe-area-inset-bottom)
            );

        width: 72px;
        height: 72px;
    }

    .msai-launcher-image {
        width: 72px;
        height: 72px;
    }

    .msai-launcher::before {
        width: 76px;
        height: 76px;
    }

    .msai-launcher::after {
        width: 87px;
        height: 87px;
    }

    .msai-unread {
        right: 2px;
        top: 3px;
    }


    /*
     * Máy nhỏ vẫn chừa top,
     * nhưng giảm nhẹ để giữ đủ vùng chat.
     */
    .msai-panel {
        top:
            calc(
                52px +
                env(safe-area-inset-top)
            );

        right: 5px;
        left: 5px;

        bottom:
            calc(
                5px +
                env(safe-area-inset-bottom)
            );

        height: auto;

        border-radius: 16px;
    }

    .msai-header {
        min-height: 60px;

        padding:
            8px
            8px
            8px
            10px;
    }

    .msai-avatar {
        width: 38px;
        height: 38px;

        flex-basis: 38px;
    }

    .msai-title {
        font-size: 14.5px;
    }

    .msai-subtitle {
        font-size: 11px;
    }

    .msai-bubble {
        font-size: 13.5px;
    }

    .msai-product-image {
        width: 58px;
        height: 58px;

        flex-basis: 58px;
    }

    .msai-product-name {
        font-size: 12.5px;
    }

    .msai-product-actions {
        gap: 5px;
    }

    .msai-product-actions a,
    .msai-product-actions button {
        padding:
            0
            8px;

        font-size: 10.5px;
    }

    /*
     * Vẫn bắt buộc 16px để iPhone không zoom.
     */
    .msai-composer textarea,
    .msai-composer textarea:focus {
        font-size: 16px !important;
    }
}


/* =========================================================
 * LANDSCAPE MOBILE
 * ========================================================= */

@media
(max-width: 900px)
and (max-height: 500px)
and (orientation: landscape) {

    .msai-launcher {
        right: 16px;

        bottom:
            calc(
                16px +
                env(safe-area-inset-bottom)
            );

        width: 68px;
        height: 68px;
    }

    .msai-launcher-image {
        width: 68px;
        height: 68px;
    }

    .msai-launcher::before {
        width: 72px;
        height: 72px;
    }

    .msai-launcher::after {
        width: 84px;
        height: 84px;
    }

    .msai-panel {
        top:
            calc(
                10px +
                env(safe-area-inset-top)
            );

        right: 10px;

        bottom:
            calc(
                10px +
                env(safe-area-inset-bottom)
            );

        left: auto;

        width:
            min(
                440px,
                calc(100vw - 20px)
            );

        height: auto;

        max-height: none;
    }
}


/* =========================================================
 * REDUCED MOTION
 * ========================================================= */

@media (prefers-reduced-motion: reduce) {

    .msai-launcher {
        animation: none !important;
    }

    .msai-launcher::before,
    .msai-launcher::after {
        animation: none !important;

        opacity: 0 !important;
    }

    .msai-launcher,
    .msai-launcher-image,
    .msai-panel,
    .msai-icon-button,
    .msai-action,
    .msai-product-actions a,
    .msai-product-actions button {
        transition: none !important;
    }

    .msai-loading-dot {
        animation: none !important;
    }
}