#chat-container {
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
}

/* =========================================================
   CHAT WIDGET ROOT
   ========================================================= */

#chat-widget {
    position: fixed !important;
    right: 15px !important;
    bottom: 50px !important;

    width: 0;
    height: 0;

    margin: 0 !important;
    padding: 0 !important;

    z-index: 2147483647 !important;

    pointer-events: none;
    isolation: isolate;
}


/* =========================================================
   FLOATING ACTION BUTTONS
   ========================================================= */

#chat-widget .chat-action-button {
    position: fixed !important;

    right: 15px !important;

    width: 64px;
    height: 64px;

    margin: 0 !important;
    padding: 0 !important;

    border: none;
    outline: none;

    background: transparent;

    display: flex;
    align-items: center;
    justify-content: center;

    cursor: pointer;
    pointer-events: auto;

    z-index: 2147483647 !important;
    isolation: isolate;

    text-decoration: none;

    -webkit-tap-highlight-color: transparent;

    transition:
        transform .22s cubic-bezier(.2, .8, .2, 1);
}


#chat-widget .chat-toggle {
    bottom: 125px !important;
}


#chat-widget .messenger-button {
    bottom: 50px !important;
}


/* =========================================================
   FLOATING BUTTON SHADOW
   ========================================================= */

#chat-widget .chat-action-button::before {
    content: "";

    position: absolute;

    left: 50%;
    top: 50%;

    width: 56px;
    height: 56px;

    transform:
        translate(-50%, -50%);

    border-radius: 17px;

    background:
        rgba(0, 0, 0, .14);

    filter: blur(10px);

    opacity: .48;

    z-index: -1;

    pointer-events: none;

    transition:
        transform .25s ease,
        opacity .25s ease;
}


/* =========================================================
   FLOATING IMAGE
   ========================================================= */

#chat-widget .chat-action-button img {
    display: block;

    width: 58px;
    height: 58px;

    box-sizing: border-box;

    object-fit: cover;

    border:
        2px solid rgba(255, 255, 255, .98);

    border-radius: 10px;

    background: #fff;

    box-shadow:
        0 2px 4px rgba(0, 0, 0, .08),
        0 6px 14px rgba(0, 0, 0, .13),
        0 12px 26px rgba(0, 0, 0, .09);

    user-select: none;

    -webkit-user-drag: none;

    transition:
        transform .22s cubic-bezier(.2, .8, .2, 1),
        box-shadow .22s ease,
        filter .22s ease;
}


#chat-widget .chat-action-button:hover {
    transform:
        translateY(-3px);
}


#chat-widget .chat-action-button:hover img {
    transform:
        scale(1.055);

    box-shadow:
        0 3px 6px rgba(0, 0, 0, .08),
        0 9px 20px rgba(0, 0, 0, .15),
        0 16px 34px rgba(0, 0, 0, .11);

    filter:
        brightness(1.025);
}


#chat-widget .chat-action-button:hover::before {
    transform:
        translate(-50%, -50%)
        scale(1.12);

    opacity: .55;
}


#chat-widget .chat-action-button:active {
    transform:
        scale(.93);
}


#chat-widget .chat-action-button:active img {
    transform:
        scale(.98);
}


#chat-widget .chat-action-button:focus-visible {
    outline:
        3px solid rgba(236, 72, 153, .28);

    outline-offset: 4px;

    border-radius: 18px;
}


/* =========================================================
   UNREAD BADGE
   ========================================================= */

#chat-widget .chat-unread {
    position: absolute;

    top: -3px;
    right: -3px;

    min-width: 21px;
    height: 21px;

    padding: 0 5px;

    box-sizing: border-box;

    border-radius: 999px;

    background:
        linear-gradient(
            135deg,
            #ff4757,
            #ef233c
        );

    color: #fff;

    border:
        2px solid #fff;

    font-family:
        Arial,
        Helvetica,
        sans-serif;

    font-size: 10px;
    font-weight: 700;

    line-height: 17px;

    display: none;

    align-items: center;
    justify-content: center;

    z-index: 2147483647;

    box-shadow:
        0 2px 5px rgba(0, 0, 0, .16),
        0 4px 10px rgba(239, 68, 68, .18);

    animation:
        chatBadgePop .25s cubic-bezier(.2, .8, .2, 1);
}


@keyframes chatBadgePop {

    0% {
        opacity: 0;
        transform: scale(.5);
    }

    70% {
        transform: scale(1.08);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }

}


/* =========================================================
   CHAT BOX
   ========================================================= */

#chat-widget .chat-box {
    position: fixed !important;

    right: 15px !important;
    bottom: 200px !important;

    width: 360px;
    height: 420px;

    margin: 0 !important;
    padding: 0 !important;

    box-sizing: border-box;

    background: #faf9f7;

    border:
        1px solid rgba(17, 24, 39, .13);

    border-radius: 18px;

    overflow: hidden;

    display: flex;
    flex-direction: column;

    z-index: 2147483646 !important;

    box-shadow:
        0 24px 60px rgba(17, 24, 39, .16),
        0 10px 28px rgba(17, 24, 39, .10),
        0 2px 7px rgba(17, 24, 39, .07);

    opacity: 0;
    visibility: hidden;

    transform:
        translateY(15px)
        scale(.98);

    transform-origin:
        bottom right;

    transition:
        opacity .2s ease,
        visibility .2s ease,
        transform .2s ease,
        box-shadow .25s ease,
        border-color .25s ease;

    pointer-events: none;
}


/* =========================================================
   CHAT BOX OPEN
   ========================================================= */

#chat-widget .chat-box.open {
    opacity: 1;

    visibility: visible;

    transform:
        translateY(0)
        scale(1);

    pointer-events: auto;
}


#chat-widget .chat-box.open:hover {
    border-color:
        rgba(236, 72, 153, .16);

    box-shadow:
        0 28px 70px rgba(17, 24, 39, .18),
        0 12px 30px rgba(17, 24, 39, .10),
        0 2px 8px rgba(17, 24, 39, .07);
}


/* =========================================================
   CHAT HEADER
   ========================================================= */

#chat-widget .chat-header {
    position: relative;

    width: 100%;
    min-height: 64px;

    padding: 10px 12px;

    box-sizing: border-box;

    background:
        linear-gradient(
            135deg,
            var(--pink),
            color-mix(
                in srgb,
                var(--pink) 85%,
                #000
            )
        );

    color: #fff;

    display: flex;
    align-items: center;
    justify-content: space-between;

    flex-shrink: 0;

    box-shadow:
        0 2px 8px rgba(0, 0, 0, .08);

    z-index: 2;
}


#chat-widget .chat-header-info {
    display: flex;
    align-items: center;

    gap: 10px;

    min-width: 0;
}


#chat-widget .chat-avatar {
    width: 40px;
    height: 40px;

    flex: 0 0 40px;

    border-radius: 50%;

    background: #fff;
    color: #2563eb;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 20px;

    box-shadow:
        0 2px 6px rgba(0, 0, 0, .12);
}


#chat-widget .chat-title {
    color: #fff;

    font-size: 15px;
    font-weight: 700;

    line-height: 20px;

    white-space: nowrap;

    overflow: hidden;
    text-overflow: ellipsis;
}


#chat-widget .chat-status {
    margin-top: 2px;

    color:
        rgba(255, 255, 255, .84);

    font-size: 11px;

    line-height: 16px;
}


/* =========================================================
   CLOSE / MINIMIZE
   ========================================================= */

.chat-minimize,
.chat-close {
    position: absolute;

    top: 50%;

    transform:
        translateY(-50%);

    width: 36px;
    height: 36px;

    margin: 0;
    padding: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border: none;

    border-radius: 50%;

    background: transparent;

    color: #fff;

    font-size: 28px;

    font-family:
        Arial,
        sans-serif;

    font-weight: 300;

    line-height: 1;

    cursor: pointer;

    transition:
        background .2s ease,
        transform .2s ease;
}


.chat-close {
    right: 8px;
}


.chat-minimize {
    right: 48px;
}


#chat-widget .chat-close:hover,
#chat-widget .chat-minimize:hover {
    background:
        rgba(255, 255, 255, .16);
}


#chat-widget .chat-close:active,
#chat-widget .chat-minimize:active {
    transform:
        translateY(-50%)
        scale(.90);
}


/* =========================================================
   MESSAGE AREA
   ========================================================= */

#chat-widget .chat-messages {
    position: relative;

    flex: 1;

    min-height: 0;

    width: 100%;

    padding: 14px;

    box-sizing: border-box;

    background:
        radial-gradient(
            circle at 0% 0%,
            rgba(236, 72, 153, .045),
            transparent 35%
        ),
        linear-gradient(
            180deg,
            #f7f6f4 0%,
            #f3f4f6 100%
        );

    overflow-x: hidden;
    overflow-y: auto;

    display: flex;
    flex-direction: column;

    gap: 8px;

    scroll-behavior: smooth;
}


#chat-widget .chat-messages::before {
    content: "";

    position: absolute;

    inset: 0;

    border-top:
        1px solid rgba(255, 255, 255, .7);

    pointer-events: none;
}


/* =========================================================
   SCROLLBAR
   ========================================================= */

#chat-widget .chat-messages::-webkit-scrollbar {
    width: 5px;
}


#chat-widget .chat-messages::-webkit-scrollbar-track {
    background: transparent;
}


#chat-widget .chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;

    border-radius: 10px;
}


#chat-widget .chat-messages {
    scrollbar-width: thin;

    scrollbar-color:
        #cbd5e1
        transparent;
}


/* =========================================================
   MESSAGE ROWS
   ========================================================= */

#chat-widget .chat-message {
    width: 100%;

    box-sizing: border-box;

    display: flex;

    align-items: flex-end;

    flex-shrink: 0;
}


#chat-widget .chat-message.customer {
    justify-content: flex-end;
}


#chat-widget .chat-message.agent,
#chat-widget .chat-message.auto_reply {
    justify-content: flex-start;
}


#chat-widget .chat-message.system {
    width: 100%;

    display: flex;

    align-items: center;
    justify-content: center;

    padding: 2px 0;
}


/* =========================================================
   SYSTEM MESSAGE
   ========================================================= */

#chat-widget
.chat-message.system
.chat-message-content {
    max-width: 92%;

    padding: 8px 12px;

    box-sizing: border-box;

    border:
        1px solid rgba(156, 163, 175, .22);

    border-radius: 10px;

    background:
        rgba(255, 255, 255, .72);

    color: #9ca3af;

    font-family:
        Arial,
        Helvetica,
        sans-serif;

    font-size: 12px;

    font-weight: 400;

    line-height: 1.45;

    text-align: center;

    box-shadow:
        0 1px 3px rgba(0, 0, 0, .025);

    backdrop-filter:
        blur(4px);

    -webkit-backdrop-filter:
        blur(4px);
}


#chat-widget
.chat-message.system.chat-countdown
.chat-message-content {
    color: #d97706;

    background:
        rgba(255, 251, 235, .88);

    border-color:
        rgba(245, 158, 11, .22);
}


/* =========================================================
   MESSAGE BUBBLE
   ========================================================= */

#chat-widget .chat-message-content {
    max-width: 85%;

    padding: 9px 12px;

    box-sizing: border-box;

    border-radius: 13px;

    font-family:
        Arial,
        Helvetica,
        sans-serif;

    font-size: 14px;

    line-height: 1.5;

    word-break: break-word;

    overflow-wrap: anywhere;

    white-space: normal;
}


/* =========================================================
   CUSTOMER BUBBLE
   ========================================================= */

#chat-widget
.chat-message.customer
.chat-message-content {
    order: 1;

    background:
        linear-gradient(
            135deg,
            var(--pink),
            color-mix(
                in srgb,
                var(--pink) 92%,
                #000
            )
        );

    color: #fff;

    border-bottom-right-radius: 4px;

    box-shadow:
        0 3px 8px
        color-mix(
            in srgb,
            var(--pink) 18%,
            transparent
        );
}


/* =========================================================
   AGENT / AUTO REPLY BUBBLE
   ========================================================= */

#chat-widget
.chat-message.agent
.chat-message-content,

#chat-widget
.chat-message.auto_reply
.chat-message-content {
    order: 2;

    background: #fff;

    color: #111827;

    border:
        1px solid rgba(17, 24, 39, .08);

    border-bottom-left-radius: 4px;

    box-shadow:
        0 2px 5px rgba(17, 24, 39, .045),
        0 1px 2px rgba(17, 24, 39, .03);
}


/* =========================================================
   MESSAGE TIME
   ========================================================= */

#chat-widget .chat-message-time {
    flex: 0 0 auto;

    align-self: flex-end;

    margin-bottom: 2px;

    color: #9ca3af;

    font-family:
        Arial,
        Helvetica,
        sans-serif;

    font-size: 10px;

    font-weight: 400;

    line-height: 14px;

    white-space: nowrap;

    user-select: none;

    opacity: .9;
}


/* =========================================================
   CUSTOMER TIME
   ========================================================= */

#chat-widget
.chat-message.customer
.chat-message-time {
    order: 2;

    margin-left: 6px;
    margin-right: 0;

    color: #9ca3af;
}


/* =========================================================
   AGENT TIME
   ========================================================= */

#chat-widget
.chat-message.agent
.chat-message-time,

#chat-widget
.chat-message.auto_reply
.chat-message-time {
    order: 1;

    margin-left: 0;
    margin-right: 6px;

    color: #9ca3af;
}


/* =========================================================
   CLOSED CONVERSATION
   ========================================================= */

.chat-conversation-closed {
    display: flex;

    align-items: center;
    justify-content: center;

    width: 100%;

    padding: 10px 12px;

    color: #9ca3af;

    font-size: 12px !important;

    font-weight: 400;

    text-align: center;

    opacity: .7;
}


/* =========================================================
   CHAT FORM
   ========================================================= */

#chat-widget .chat-form {
    width: 100%;

    min-height: 62px;

    padding: 10px;

    box-sizing: border-box;

    background: #fff;

    border-top:
        1px solid rgba(17, 24, 39, .09);

    display: flex;

    align-items: center;

    gap: 8px;

    flex-shrink: 0;

    box-shadow:
        0 -2px 8px rgba(17, 24, 39, .025);
}


/* =========================================================
   INPUT
   ========================================================= */

#chat-widget .chat-input {
    flex: 1;

    min-width: 0;

    width: 100%;

    height: 42px;

    padding: 0 12px;

    box-sizing: border-box;

    border:
        1px solid #d1d5db;

    border-radius: 10px;

    background: #fff;

    color: #111827;

    outline: none;

    font-family:
        Arial,
        Helvetica,
        sans-serif;

    font-size: 14px;

    transition:
        border-color .2s ease,
        box-shadow .2s ease;
}


#chat-widget .chat-input::placeholder {
    color: #9ca3af;
}


#chat-widget .chat-input:focus {
    border-color:
        var(--pink);

    box-shadow:
        0 0 0 3px
        color-mix(
            in srgb,
            var(--pink) 12%,
            transparent
        );
}


/* =========================================================
   SEND BUTTON
   ========================================================= */

#chat-widget .chat-send {
    width: 42px;
    height: 42px;

    flex: 0 0 42px;

    padding: 0;

    border: none;

    border-radius: 10px;

    background:
        var(--pink);

    color: #fff;

    display: flex;

    align-items: center;
    justify-content: center;

    cursor: pointer;

    font-size: 18px;

    transition:
        transform .2s ease,
        filter .2s ease,
        box-shadow .2s ease;
}


#chat-widget .chat-send:hover {
    background:
        var(--pink);

    filter:
        brightness(1.05);

    box-shadow:
        0 4px 10px
        color-mix(
            in srgb,
            var(--pink) 30%,
            transparent
        );
}


#chat-widget .chat-send:active {
    transform:
        scale(.92);
}


/* =========================================================
   TABLET / MOBILE
   ========================================================= */

@media (max-width: 768px) {

    #chat-widget {
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;

        width: 100% !important;
        height: 72px !important;

        pointer-events: none;

        z-index: 2147483647 !important;

        background:
            linear-gradient(
                180deg,
                #ffffff 0%,
                #faf8f8 100%
            );

        border-top:
            1px solid rgba(17, 24, 39, .10);

        box-shadow:
            0 -8px 24px
            rgba(17, 24, 39, .08);

        backdrop-filter:
            blur(12px);

        -webkit-backdrop-filter:
            blur(12px);
    }


    #chat-widget::before {
        content: "";

        position: absolute;

        inset: 0;

        background:
            linear-gradient(
                90deg,
                rgba(236, 72, 153, .025),
                transparent 50%,
                rgba(236, 72, 153, .025)
            );

        pointer-events: none;
    }


    #chat-widget .chat-action-button {
        position: absolute !important;

        top: 50% !important;
        bottom: auto !important;

        width: 58px;
        height: 58px;

        transform:
            translateY(-50%);

        pointer-events: auto;
    }


    #chat-widget .chat-toggle {
        right:
            calc(50% + 8px) !important;
    }


    #chat-widget .messenger-button {
        right:
            calc(50% - 66px) !important;
    }


    #chat-widget
    .chat-action-button img {
        width: 52px;
        height: 52px;

        border-radius: 14px;

        box-shadow:
            0 2px 5px rgba(0, 0, 0, .08),
            0 6px 14px rgba(236, 72, 153, .13),
            0 10px 22px rgba(0, 0, 0, .08);
    }


    #chat-widget
    .chat-action-button::before {
        width: 50px;
        height: 50px;

        border-radius: 14px;

        background:
            rgba(236, 72, 153, .16);

        filter: blur(9px);

        opacity: .65;
    }


    #chat-widget
    .chat-action-button:hover {
        transform:
            translateY(-50%);
    }


    #chat-widget
    .chat-action-button:hover img {
        transform:
            scale(1.035);
    }


    #chat-widget .chat-unread {
        top: 1px;
        right: 1px;
    }


    /* =====================================================
       CHAT BOX MOBILE
       ===================================================== */

    #chat-widget .chat-box {
        right: 16px !important;
        bottom: 88px !important;

        width:
            calc(100% - 32px);

        max-width: 360px;

        height:
            calc(100dvh - 120px);

        max-height: 600px;

        border-radius: 17px;

        box-shadow:
            0 24px 60px rgba(17, 24, 39, .18),
            0 8px 24px rgba(17, 24, 39, .10);
    }


    #chat-widget .chat-input {
        font-size: 16px;
    }


    #chat-widget
    .chat-message.system
    .chat-message-content {
        max-width: 94%;

        font-size: 11px;
    }


    #chat-widget .chat-message-time {
        font-size: 9.5px;

        line-height: 13px;

        margin-bottom: 2px;
    }


    #chat-widget
    .chat-message.customer
    .chat-message-time {
        margin-left: 5px;
    }


    #chat-widget
    .chat-message.agent
    .chat-message-time,

    #chat-widget
    .chat-message.auto_reply
    .chat-message-time {
        margin-right: 5px;
    }

}


/* =========================================================
   SMALL MOBILE
   ========================================================= */

@media (max-width: 600px) {

    #chat-widget {
        height:
            calc(
                70px +
                env(safe-area-inset-bottom)
            ) !important;
    }


    #chat-widget .chat-action-button {
        width: 58px;
        height: 58px;
    }


    #chat-widget .chat-toggle {
        right:
            calc(50% + 7px) !important;
    }


    #chat-widget .messenger-button {
        right:
            calc(50% - 65px) !important;
    }


    #chat-widget
    .chat-action-button img {
        width: 52px;
        height: 52px;

        border-radius: 14px;
    }


    #chat-widget
    .chat-action-button::before {
        width: 50px;
        height: 50px;

        border-radius: 14px;
    }


    #chat-widget .chat-box {
        left: auto !important;

        right: 16px !important;

        width:
            calc(100vw - 32px);

        max-width: 360px;

        bottom: 86px !important;

        height:
            calc(100dvh - 115px);

        max-height: 600px;

        border-radius: 16px;
    }


    #chat-widget .chat-input {
        font-size: 16px !important;
    }

}


/* =========================================================
   MOBILE 480px
   ========================================================= */

@media (max-width: 480px) {

    #chat-widget {
        height:
            calc(
                68px +
                env(safe-area-inset-bottom)
            ) !important;

        background:
            linear-gradient(
                180deg,
                #ffffff 0%,
                #fcf9fa 100%
            );

        border-top:
            1px solid rgba(17, 24, 39, .09);

        box-shadow:
            0 -7px 24px
            rgba(17, 24, 39, .08);
    }


    #chat-widget .chat-action-button {
        width: 56px;
        height: 56px;
    }


    #chat-widget .chat-toggle {
        right:
            calc(50% + 6px) !important;
    }


    #chat-widget .messenger-button {
        right:
            calc(50% - 62px) !important;
    }


    #chat-widget
    .chat-action-button img {
        width: 50px;
        height: 50px;

        border-radius: 13px;
    }


    #chat-widget
    .chat-action-button::before {
        width: 48px;
        height: 48px;

        border-radius: 13px;

        background:
            rgba(236, 72, 153, .18);
    }


    #chat-widget .chat-unread {
        top: 0;
        right: 0;

        min-width: 20px;
        height: 20px;

        line-height: 16px;
    }


    #chat-widget .chat-box {
        left: 8px !important;
        right: 8px !important;

        width:
            calc(100vw - 16px);

        max-width: none;

        bottom:
            calc(
                78px +
                env(safe-area-inset-bottom)
            ) !important;

        height:
            calc(
                100dvh -
                105px -
                env(safe-area-inset-bottom)
            );

        max-height: 600px;

        border-radius: 15px;

        box-shadow:
            0 24px 60px rgba(17, 24, 39, .18),
            0 8px 24px rgba(17, 24, 39, .10);
    }


    #chat-widget .chat-messages {
        padding: 12px;
    }


    #chat-widget .chat-input {
        font-size: 16px !important;
    }


    #chat-widget
    .chat-message.system
    .chat-message-content {
        max-width: 94%;

        padding: 7px 10px;

        font-size: 11px;

        line-height: 1.4;
    }


    #chat-widget .chat-message-time {
        font-size: 9px;

        line-height: 12px;
    }


    #chat-widget
    .chat-message.customer
    .chat-message-time {
        margin-left: 5px;
    }


    #chat-widget
    .chat-message.agent
    .chat-message-time,

    #chat-widget
    .chat-message.auto_reply
    .chat-message-time {
        margin-right: 5px;
    }

}


/* =========================================================
   VERY SMALL MOBILE
   ========================================================= */

@media (max-width: 360px) {

    #chat-widget {
        height:
            calc(
                66px +
                env(safe-area-inset-bottom)
            ) !important;
    }


    #chat-widget .chat-action-button {
        width: 54px;
        height: 54px;
    }


    #chat-widget .chat-toggle {
        right:
            calc(50% + 5px) !important;
    }


    #chat-widget .messenger-button {
        right:
            calc(50% - 59px) !important;
    }


    #chat-widget
    .chat-action-button img {
        width: 48px;
        height: 48px;

        border-radius: 12px;
    }


    #chat-widget
    .chat-action-button::before {
        width: 46px;
        height: 46px;

        border-radius: 12px;
    }


    #chat-widget .chat-box {
        left: 6px !important;
        right: 6px !important;

        width:
            calc(100vw - 12px);

        bottom:
            calc(
                74px +
                env(safe-area-inset-bottom)
            ) !important;

        height:
            calc(
                100dvh -
                98px -
                env(safe-area-inset-bottom)
            );

        border-radius: 14px;
    }


    #chat-widget .chat-message-content {
        max-width: 86%;

        font-size: 13px;
    }


    #chat-widget
    .chat-message.system
    .chat-message-content {
        max-width: 94%;

        padding: 7px 9px;

        font-size: 10.5px;
    }


    #chat-widget .chat-message-time {
        font-size: 8.5px;

        line-height: 12px;

        margin-left: 4px;
        margin-right: 4px;
    }


    #chat-widget .chat-input {
        font-size: 16px !important;
    }

}


/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

    #chat-widget,
    #chat-widget .chat-action-button,
    #chat-widget .chat-action-button img,
    #chat-widget .chat-action-button::before,
    #chat-widget .chat-box,
    #chat-widget .chat-send,
    #chat-widget .chat-close,
    #chat-widget .chat-minimize,
    #chat-widget .chat-unread,
    #chat-widget .chat-input {

        transition: none !important;
        animation: none !important;
    }


    #chat-widget .chat-messages {
        scroll-behavior: auto;
    }

}
