/* =========================================================
   CANDY — SHEN STUDIOS ASSISTANT
========================================================= */

#candyAssistant {
    --candy-black: #0b0b0b;
    --candy-black-soft: #121212;
    --candy-white: #ffffff;
    --candy-off-white: #f7f5f1;
    --candy-border: rgba(255, 255, 255, 0.12);
    --candy-bronze: #c99768;
    --candy-bronze-dark: #9b673c;
    --candy-text-muted: #777;

    position: fixed;
    right: 32px;
    bottom: 28px;

    z-index: 99999;

    font-family: inherit;
}


/* =========================================================
   CLOSED LAUNCHER
========================================================= */

#candyAssistant .candy-chat-button {
    border: 1px solid rgba(0, 0, 0, 0.12);

    background: #ffffff;

    min-width: 154px;
    height: 62px;

    padding: 8px 18px 8px 8px;

    border-radius: 999px;

    display: flex;
    align-items: center;
    gap: 10px;

    cursor: pointer;

    box-shadow:
        0 12px 35px rgba(0, 0, 0, 0.14);

    transition:
        transform 0.25s ease,
        box-shadow 0.25s ease;
}


#candyAssistant .candy-chat-button:hover {
    transform: translateY(-2px);

    box-shadow:
        0 16px 42px rgba(0, 0, 0, 0.18);
}


#candyAssistant .candy-chat-button img {
    width: 44px;
    height: 44px;

    object-fit: cover;

    border-radius: 50%;
}


#candyAssistant .candy-launcher-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;

    line-height: 1.1;
}


#candyAssistant .candy-launcher-text strong {
    color: #111;

    font-size: 14px;
    font-weight: 600;
}


#candyAssistant .candy-launcher-text span {
    color: #888;

    margin-top: 4px;

    font-size: 9px;

    letter-spacing: 0.04em;
}


/* =========================================================
   CHAT WINDOW
========================================================= */

#candyAssistant .candy-chat-window {
    width: 360px;
    height: 500px;

    display: none;

    overflow: hidden;

    background: var(--candy-off-white);

    border:
        1px solid rgba(255, 255, 255, 0.12);

    border-radius: 18px;

    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.24);
}


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

#candyAssistant .candy-chat-header {
    min-height: 68px;

    padding: 0 18px;

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

    background: var(--candy-black);

    border-bottom:
        1px solid rgba(255, 255, 255, 0.08);
}


#candyAssistant .candy-chat-header>div {
    display: flex;
    flex-direction: column;
}


#candyAssistant .candy-chat-header strong {
    color: white;

    font-size: 15px;
    font-weight: 600;
}


#candyAssistant .candy-chat-header span {
    color: var(--candy-bronze);

    margin-top: 3px;

    font-size: 9px;

    letter-spacing: 0.08em;
    text-transform: uppercase;
}


#candyAssistant .candy-chat-close {
    width: 34px;
    height: 34px;

    padding: 0;

    display: grid;
    place-items: center;

    border: 1px solid rgba(255, 255, 255, 0.12);

    border-radius: 50%;

    background: transparent;

    color: white;

    font-size: 22px;
    line-height: 1;

    cursor: pointer;

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


#candyAssistant .candy-chat-close:hover {
    background: rgba(255, 255, 255, 0.08);

    border-color:
        rgba(201, 151, 104, 0.55);
}


/* =========================================================
   MESSAGE AREA
========================================================= */

#candyAssistant .candy-chat-messages {
    height: calc(100% - 68px - 46px - 58px);

    padding: 18px;

    overflow-y: auto;

    box-sizing: border-box;
}


#candyAssistant .candy-bot-row {
    width: 100%;

    display: flex;
    align-items: flex-end;

    gap: 9px;

    margin-bottom: 15px;
}


#candyAssistant .candy-message-avatar {
    width: 34px;
    height: 34px;

    flex: 0 0 34px;

    object-fit: cover;

    border-radius: 50%;
}


#candyAssistant .candy-message {
    max-width: 78%;

    padding: 11px 13px;

    box-sizing: border-box;

    font-size: 13px;
    line-height: 1.55;

    white-space: pre-line;
}


#candyAssistant .bot-message {
    background: #ffffff;

    color: #111;

    border:
        1px solid rgba(0, 0, 0, 0.05);

    border-radius:
        14px 14px 14px 4px;
}


#candyAssistant .user-message {
    margin:
        0 0 15px auto;

    background:
        var(--candy-black);

    color:
        white;

    border-radius:
        14px 14px 4px 14px;
}


/* =========================================================
   CANDY LINKS INSIDE RESPONSES
========================================================= */

#candyAssistant .candy-reply-link,
#candyAssistant .shen-reply-link {
    width: fit-content;

    display: block;

    margin-top: 10px;

    padding-top: 9px;

    border-top:
        1px solid rgba(0, 0, 0, 0.08);

    color:
        var(--candy-bronze-dark);

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

    letter-spacing: 0.12em;

    text-decoration: none;
    text-transform: uppercase;
}


#candyAssistant .candy-reply-link:hover,
#candyAssistant .shen-reply-link:hover {
    color: #111;
}


/* =========================================================
   TESTING NOTICE
========================================================= */

#candyAssistant .candy-testing-note {
    height: 46px;

    margin: 0;

    padding: 0 14px;

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

    box-sizing: border-box;

    border-top:
        1px solid rgba(0, 0, 0, 0.06);

    background:
        rgba(255, 255, 255, 0.72);

    color:
        var(--candy-text-muted);

    text-align: center;

    font-size: 8px;

    line-height: 1.35;

    letter-spacing: 0.02em;
}


/* =========================================================
   INPUT AREA
========================================================= */

#candyAssistant .candy-chat-input {
    height: 58px;

    padding: 7px 8px 7px 15px;

    display: flex;
    align-items: center;

    gap: 8px;

    box-sizing: border-box;

    border-top:
        1px solid rgba(0, 0, 0, 0.07);

    background: #ffffff;
}


#candyAssistant .candy-chat-input input {
    min-width: 0;
    flex: 1;

    border: 0;
    outline: 0;

    background: transparent;

    color: #111;

    font-family: inherit;
    font-size: 12px;
}


#candyAssistant .candy-chat-input input::placeholder {
    color: #969696;
}


#candyAssistant .candy-chat-input button {
    width: 42px;
    height: 42px;

    flex: 0 0 42px;

    padding: 0;

    display: grid;
    place-items: center;

    border: 0;
    border-radius: 50%;

    background:
        var(--candy-bronze);

    color:
        #111;

    font-size: 17px;

    cursor: pointer;

    transition:
        transform 0.2s ease,
        background 0.2s ease;
}


#candyAssistant .candy-chat-input button:hover {
    transform: translateY(-1px);

    background:
        #d7ab7e;
}


/* =========================================================
   SCROLLBAR
========================================================= */

#candyAssistant .candy-chat-messages::-webkit-scrollbar {
    width: 5px;
}


#candyAssistant .candy-chat-messages::-webkit-scrollbar-thumb {
    background:
        rgba(0, 0, 0, 0.16);

    border-radius: 10px;
}


/* =========================================================
   DARK MODE
========================================================= */

html[data-theme="dark"] #candyAssistant .candy-chat-button {
    background: #111;

    border-color:
        rgba(255, 255, 255, 0.12);
}


html[data-theme="dark"] #candyAssistant .candy-launcher-text strong {
    color: white;
}


html[data-theme="dark"] #candyAssistant .candy-chat-window {
    background: #0d0d0d;

    border-color:
        rgba(255, 255, 255, 0.12);
}


html[data-theme="dark"] #candyAssistant .candy-chat-messages {
    background: #0d0d0d;
}


html[data-theme="dark"] #candyAssistant .bot-message {
    background: #171717;

    color: #f4f4f4;

    border-color:
        rgba(255, 255, 255, 0.07);
}


html[data-theme="dark"] #candyAssistant .user-message {
    background:
        var(--candy-bronze);

    color:
        #111;
}


html[data-theme="dark"] #candyAssistant .candy-testing-note {
    background: #111;

    color: #888;

    border-color:
        rgba(255, 255, 255, 0.07);
}


html[data-theme="dark"] #candyAssistant .candy-chat-input {
    background: #111;

    border-color:
        rgba(255, 255, 255, 0.08);
}


html[data-theme="dark"] #candyAssistant .candy-chat-input input {
    color: white;
}


html[data-theme="dark"] #candyAssistant .candy-reply-link,
html[data-theme="dark"] #candyAssistant .shen-reply-link {
    color:
        var(--candy-bronze);
}


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

@media (min-width: 721px) and (max-width: 1000px) {

    #candyAssistant {
        right: 20px;
        bottom: 20px;
    }


    #candyAssistant .candy-chat-window {
        width: 350px;
        height: 490px;
    }

}


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

@media (max-width: 720px) {

    #candyAssistant {
        right: 14px;
        bottom: 14px;
    }


    #candyAssistant .candy-chat-button {
        min-width: 0;

        width: 54px;
        height: 54px;

        padding: 5px;

        justify-content: center;
    }


    #candyAssistant .candy-chat-button img {
        width: 42px;
        height: 42px;
    }


    #candyAssistant .candy-launcher-text {
        display: none;
    }


    #candyAssistant .candy-chat-window {
        position: fixed;

        left: 12px;
        right: 12px;
        bottom: 12px;

        width: auto;

        height: min(570px, calc(100dvh - 24px));

        border-radius: 16px;
    }


    #candyAssistant .candy-chat-messages {
        padding:
            15px 12px;
    }


    #candyAssistant .candy-message {
        max-width: 82%;

        font-size: 12px;
    }


    #candyAssistant .candy-testing-note {
        padding:
            0 10px;

        font-size: 7px;
    }

}

/* =========================================================
   CANDY IMAGE SHARPNESS
========================================================= */

#candyAssistant .candy-message-avatar {
    width: 38px;
    height: 38px;

    min-width: 38px;
    min-height: 38px;

    object-fit: cover;
    object-position: center;

    border-radius: 50%;

    transform: none;
    filter: none;

    image-rendering: auto;
}


#candyAssistant .candy-chat-button img {
    width: 44px;
    height: 44px;

    min-width: 44px;
    min-height: 44px;

    object-fit: cover;
    object-position: center;

    border-radius: 50%;

    transform: none;
    filter: none;

    image-rendering: auto;
}

/* =========================================================
   FINAL CANDY POSITION OVERRIDE
   Stops draggable positioning + coordinates with WhatsApp
========================================================= */

/* CANDY ALWAYS STAYS BOTTOM-RIGHT */
#candyAssistant {
    position: fixed !important;

    right: 24px !important;
    bottom: 22px !important;

    left: auto !important;
    top: auto !important;

    z-index: 99998 !important;
}


/* STOP DRAGGING FROM VISUALLY MOVING THE LAUNCHER */
#candyAssistant .candy-chat-button {
    cursor: pointer !important;
    touch-action: auto !important;
}


/* CHAT WINDOW ALSO LOCKED TO BOTTOM-RIGHT */
#candyAssistant .candy-chat-window {
    position: fixed !important;

    right: 24px !important;
    bottom: 22px !important;

    left: auto !important;
    top: auto !important;

    z-index: 99998 !important;
}


/* =========================================================
   WHATSAPP — CANDY CLOSED
   WhatsApp sits directly ABOVE Candy
========================================================= */

.floating-whatsapp {
    position: fixed !important;

    right: 24px !important;
    bottom: 96px !important;

    z-index: 99999 !important;

    transition: bottom 0.28s ease !important;
}


/* =========================================================
   WHATSAPP — CANDY OPEN
   Move WhatsApp above entire chat window
========================================================= */

body:has(#candyChatWindow[style*="display: block"]) .floating-whatsapp {
    bottom: 540px !important;
}


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

@media (min-width: 721px) and (max-width: 1000px) {

    #candyAssistant {
        right: 18px !important;
        bottom: 18px !important;
    }

    #candyAssistant .candy-chat-window {
        right: 18px !important;
        bottom: 18px !important;
    }

    .floating-whatsapp {
        right: 18px !important;
        bottom: 88px !important;
    }

    body:has(#candyChatWindow[style*="display: block"]) .floating-whatsapp {
        bottom: 530px !important;
    }
}


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

@media (max-width: 720px) {

    #candyAssistant {
        right: 14px !important;
        bottom: 14px !important;

        left: auto !important;
        top: auto !important;
    }

    #candyAssistant .candy-chat-window {
        left: 12px !important;
        right: 12px !important;

        bottom: 12px !important;

        width: auto !important;
    }

    .floating-whatsapp {
        right: 14px !important;
        bottom: 78px !important;
    }

    body:has(#candyChatWindow[style*="display: block"]) .floating-whatsapp {
        bottom: calc(100dvh - 66px) !important;
    }
}

/* =========================================================
   MOBILE — SHOW ASK CANDY LABEL
========================================================= */

@media (max-width: 720px) {

    #candyAssistant .candy-chat-button {
        width: auto !important;
        min-width: 128px !important;
        height: 52px !important;

        padding: 5px 14px 5px 5px !important;

        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;

        gap: 9px !important;

        border-radius: 999px !important;
    }


    #candyAssistant .candy-chat-button img {
        width: 42px !important;
        height: 42px !important;

        min-width: 42px !important;
        min-height: 42px !important;
    }


    #candyAssistant .candy-launcher-text {
        display: flex !important;

        flex-direction: column !important;
        align-items: flex-start !important;

        line-height: 1.1 !important;
    }


    #candyAssistant .candy-launcher-text strong {
        font-size: 12px !important;
        font-weight: 600 !important;
    }


    #candyAssistant .candy-launcher-text span {
        margin-top: 3px !important;

        font-size: 7px !important;

        opacity: 0.55 !important;
    }

}