/* =============================================================================
   Chat Widget — Scoped Stylesheet
   All rules are prefixed with #chat-widget so nothing leaks into or is
   overridden by the host page's global CSS.
   ============================================================================= */


/* ── CSS Custom Properties ─────────────────────────────────────────────────── */

#chat-widget {
    --primary-color: #6331D8;
    --background-color: #f5f5f7;
    --input-background: #fff;
    --input-shadow: rgba(0, 0, 0, 0.1);
    --button-background: #ececf1;
    --button-shadow: rgba(123, 47, 247, 0.4);
    --icon-background: #F2EEFC;
    --icon-Color: #000000;
    --Active-Color: #15BA83;
    --Font-Color: #212426;
    --Font-Color-body: #4C4F51;
}


    /* ── Box-sizing & Font Reset ───────────────────────────────────────────────── */

    #chat-widget,
    #chat-widget *,
    #chat-widget *::before,
    #chat-widget *::after {
        box-sizing: border-box;
    }

#chat-widget {
    margin: 0;
    padding: 0;
    font-family: "Poppins", sans-serif;
    text-size-adjust: 100%;
    position: fixed;
    z-index: 1090;
    bottom: 4.5rem;
    right: 1rem;
}


    /* ── Typing Indicator ──────────────────────────────────────────────────────── */

    /* Row: spinner + label sit side by side */
    #chat-widget .chat-widget-typing {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 16px 4px;
    }

    /* Animated ring that spins while the assistant is responding */
    #chat-widget .chat-widget-spinner {
        display: inline-block;
        flex-shrink: 0;
        width: 14px;
        height: 14px;
        border: 2px solid rgba(83, 74, 183, 0.2);
        border-top-color: #6331D8;
        border-radius: 50%;
        animation: chat-widget-spin 0.75s linear infinite;
    }

    /* "Assistant is typing…" label */
    #chat-widget .chat-widget-typing-text {
        color: #6f7582;
        font-size: 0.88rem;
        line-height: 1;
    }

@keyframes chat-widget-spin {
    to {
        transform: rotate(360deg);
    }
}


/* ── Floating Launcher Icon ────────────────────────────────────────────────── */

/* Fixed container that holds the floating input row and the toggle button */
#chat-widget .chatbot-flobation-icon {
    position: fixed;
    bottom: 80px;
    right: 25px;
    z-index: 9999;
    transition: opacity 0.25s ease, transform 0.3s ease;
    transform: translateY(0);
    opacity: 1;
}

    /* Hidden state — fades and scales down when the chat window is open */
    #chat-widget .chatbot-flobation-icon.hide,
    #chat-widget .chatbot.open ~ .chatbot-flobation-icon {
        opacity: 0;
        transform: translateY(30px);
        pointer-events: none;
    }


/* ── Floating Input Group ──────────────────────────────────────────────────── */

/* Wraps the text input, send button, close button, and toggle button */
#chat-widget .chat-input-group {
    position: relative;
}

/* Horizontal row that aligns the input box, close button, and action button */
#chat-widget .chat-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Reveal the close button when the input box is hovered */
#chat-widget .chat-input-group:has(.input-box:hover) .close-btn {
    opacity: 1;
}

/* Floating close button — hidden by default, revealed on input hover/focus */
#chat-widget .close-btn {
    position: absolute;
    top: -30px;
    left: 0;
    margin-bottom: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--icon-background);
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.25s ease;
}

    #chat-widget .close-btn svg {
        width: 32px;
        height: 32px;
        flex-shrink: 0;
    }

    /* Reveal the close button when the input box or itself is hovered/focused */
    #chat-widget .input-box:hover ~ .close-btn,
    #chat-widget .input-box:focus-within ~ .close-btn,
    #chat-widget .close-btn:hover {
        opacity: 1;
        pointer-events: auto;
    }

/* Keep the close button hidden when focus is on the toggle button */
#chat-widget .action-btn:focus ~ .close-btn {
    opacity: 0 !important;
}

/* Pill-shaped input box that expands when the user focuses the floating field */
#chat-widget .input-box {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 30px;
    background: #fff;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    transition: width 0.35s cubic-bezier(.15, 1, .36, 1), box-shadow 0.5s ease;
}

/* Expanded width when the floating input is focused */
#chat-widget .chat-input-group.focused .input-box {
    width: 350px;
}

/* Visible border ring on keyboard focus */
#chat-widget .chat-input-group:focus-within .input-box {
    border: 1px solid #000;
}

#chat-widget .input-box input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
}


/* ── Shared Send Button ─────────────────────────────────────────────────────── */

/* Used in both the floating launcher and the main chat footer */
#chat-widget .send-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: var(--icon-background);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

    #chat-widget .send-btn svg {
        width: 34px;
        height: 34px;
        flex-shrink: 0;
    }


/* ── Toggle / Action Button ────────────────────────────────────────────────── */

/* The large round button that opens the chat window */
#chat-widget .action-btn {
    width: 58px;
    height: 58px;
    flex-shrink: 0;
    border-radius: 50%;
    border: none;
    background: var(--primary-color);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.25s ease, transform 0.3s ease, margin 0.35s cubic-bezier(.22, 1, .36, 1);
}

    #chat-widget .action-btn svg {
        width: 58px;
        height: 58px;
        flex-shrink: 0;
        transition: transform 0.2s ease;
        display: inline-block;
    }

    /* Press feedback */
    #chat-widget .action-btn:active svg {
        transform: scale(0.85);
    }

/* Slide the toggle button out of view when the floating input is focused */
#chat-widget .chat-input-group.focused .action-btn {
    opacity: 0;
    transform: scale(0.6);
    margin-left: -58px;
    pointer-events: none;
}


/* ── Generic Hidden Utility ────────────────────────────────────────────────── */

#chat-widget .hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}


/* ── Chat Window ───────────────────────────────────────────────────────────── */

/* The pop-up card that contains the full conversation UI */
#chat-widget .chat-window {
    isolation: isolate;
    position: fixed;
    bottom: 80px;
    right: 25px;
    width: min(400px, calc(100vw - 40px));
    height: min(80vh, 700px);
    background: #fff;
    border-radius: 24px;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.1);
    transform-origin: bottom right;
    will-change: transform, opacity;
    box-shadow: 0px 0px 15.7px #EBEAF8;
    overflow: hidden;
    border: 1px solid #FCFCFE;
    transition: transform 0.45s cubic-bezier(.22, 1, .36, 1), opacity 0.25s ease, border-radius 0.35s ease;
}

/* Animate the window open when the chatbot section carries the .open class */
#chat-widget .chatbot.open .chat-window {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
    border-radius: 24px;
}

/* Chatbot section acts as the fixed anchor for the chat window */
#chat-widget .chatbot {
    position: fixed;
    bottom: 25px;
    right: 25px;
}


/* ── Chat Footer ───────────────────────────────────────────────────────────── */

/* Frosted-glass panel that holds the input, pills, and privacy notice */
#chat-widget .chat-footer {
    position: absolute;
    left: 20px;
    right: 20px;
    bottom: 20px;
    z-index: 20;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-radius: 24px;
}

/* Wrapper that reserves vertical space for the footer inside the window */
#chat-widget .chat-footer-wrapper {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 160px;
}


/* ── Header ────────────────────────────────────────────────────────────────── */

/* Pill row containing the assistant logo, name, and action buttons */
#chat-widget .header-pill {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    border-radius: 18px;
    pointer-events: auto;
}

/* Absolute overlay that fades the header into the scroll content below */
#chat-widget .header-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 110px;
    padding: 20px;
    z-index: 50;
    pointer-events: none;
    overflow: hidden;
}

/* Blurred gradient layer behind the header pill */
#chat-widget .header-blur {
    position: absolute;
    inset: 0;
    height: 74px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.88) 0%, rgba(255, 255, 255, 0.72) 24%, rgba(255, 255, 255, 0) 100%);
    mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
    pointer-events: none;
}

/* Left group: logo + name + status */
#chat-widget .left-group {
    display: flex;
    border-radius: 45px;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #FDFDFF;
    box-shadow: 0px 0px 32.4px rgba(0, 0, 0, 0.11);
}

#chat-widget .logo {
    padding: 6px;
}

#chat-widget .text-group {
    display: flex;
    flex-direction: column;
}

#chat-widget .title {
    font-size: 20px;
    font-weight: 400;
    color: var(--Font-Color);
}

/* Right group: reset and close buttons */
#chat-widget .right-group {
    display: flex;
    gap: 8px;
}

    #chat-widget .right-group button {
        width: 34px;
        height: 34px;
        border: none;
        border-radius: 50%;
        background: var(--icon-background);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        font-size: 20px;
    }

    #chat-widget .right-group svg {
        width: 34px;
        height: 34px;
        flex-shrink: 0;
    }

/* "Active now" status label */
#chat-widget .active-state {
    font-size: 14px;
    color: var(--Active-Color);
    font-style: normal;
    font-weight: 500;
}


/* ── Message List ──────────────────────────────────────────────────────────── */

/* Scrollable area that contains all message rows */
#chat-widget .chat-scroll {
    position: absolute;
    top: 48px;
    bottom: 126px;
    left: 0;
    right: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 50px 20px 20px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-gutter: stable;
}

    #chat-widget .chat-scroll::-webkit-scrollbar {
        width: 6px;
    }

    #chat-widget .chat-scroll::-webkit-scrollbar-thumb {
        background: rgba(99, 49, 216, 0.25);
        border-radius: 999px;
    }

    #chat-widget .chat-scroll::-webkit-scrollbar-track {
        background: transparent;
    }

/* Vertical stack of message rows */
#chat-widget .chat-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Single message row — default to user (right-aligned) */
#chat-widget .message-row {
    display: flex;
    gap: 12px;
    margin: 8px 0;
    justify-content: flex-end;
}

    /* Bot rows are left-aligned */
    #chat-widget .message-row.bot {
        justify-content: flex-start;
    }

/* Base bubble styles shared by user and bot messages */
#chat-widget .message {
    border-radius: 16px;
    font-size: 16px;
    line-height: 1.5;
}

    /* Bot bubble: no background, natural text color, clipped top-left corner */
    #chat-widget .message.bot {
        max-width: 75%;
        color: var(--Font-Color-body);
        border-top-left-radius: 4px;
    }

    /* User bubble: brand-purple background, clipped top-right corner */
    #chat-widget .message.user {
        margin-left: 70px;
        background: var(--primary-color);
        color: #fff;
        border-top-right-radius: 0;
        padding: 10px 14px;
    }

/* Wrapper that stacks the user bubble above the "Read" receipt */
#chat-widget .message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

/* "Read" receipt label below user bubbles */
#chat-widget .read-status {
    font-size: 12px;
    color: #7D7985;
    font-weight: 500;
    padding-right: 6px;
}

/* Bot avatar circle to the left of bot bubbles */
#chat-widget .bot-avatar {
    width: 39px;
    height: 39px;
    object-fit: cover;
    flex-shrink: 0;
}

    #chat-widget .bot-avatar svg {
        width: 39px;
        height: 39px;
        flex-shrink: 1;
    }


/* ── Chat Input (Main Footer) ──────────────────────────────────────────────── */

#chat-widget .chat-input-box {
    background: #fff;
}

/* Pill-shaped input row with a subtle shadow and border */
#chat-widget .input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 30px;
    padding: 6px;
    box-shadow: 0px 4px 12.1px rgba(0, 0, 0, 0.09);
    border: 1px solid #E4E1EA;
    transition: all 0.3s ease;
}

    #chat-widget .input-wrapper input {
        flex: 1;
        border: none;
        outline: none;
        font-size: 14px;
        padding: 8px 12px;
        background: transparent;
    }

    /* Visible focus ring on the main input */
    #chat-widget .input-wrapper:focus-within {
        border: 1px solid black;
    }


/* ── Quick-Action Pill Chips ───────────────────────────────────────────────── */

#chat-widget .chat-suggestions {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    background: transparent;
    margin-bottom: 14px;
}

    #chat-widget .chat-suggestions .pill {
        border: 1px solid #F0EBFA;
        background: #fff;
        padding: 8px 10px;
        border-radius: 20px;
        font-size: 12px !important;
        font-weight: 600 !important;
        cursor: pointer;
        transition: all 0.2s ease;
        white-space: nowrap;
        color: var(--primary-color);
    }

        #chat-widget .chat-suggestions .pill:hover {
            transform: translateY(-2px);
            border-color: #6d28d9;
            color: var(--primary-color);
        }


/* ── Privacy Notice ────────────────────────────────────────────────────────── */

/* Floats above the footer, dismissible via the close button */
#chat-widget .privacy-notice {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    background: #ffffff;
    border: 1px solid #ece7fb;
    padding: 12px 14px;
    border-radius: 16px;
    margin-bottom: 12px;
    box-shadow: 0px 0px 18.1px rgba(0, 0, 0, 0.12);
    animation: fadeIn 0.3s ease;
    position: absolute;
    z-index: 100;
    bottom: 40px;
}

    #chat-widget .privacy-notice p {
        font-size: 14px;
        line-height: 1.5;
        color: var(--Font-Color-body);
    }

    #chat-widget .privacy-notice button {
        border: none;
        background: #ffffff;
        cursor: pointer;
        border-radius: 50%;
        flex-shrink: 0;
        color: var(--icon-Color);
    }

    #chat-widget .privacy-notice svg {
        height: 26px;
        width: 26px;
        flex-shrink: 1;
    }

#chat-widget .privacy-link {
    color: black;
    text-decoration: underline;
    font-weight: 400;
    font-size: 14px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* ── Error Box ─────────────────────────────────────────────────────────────── */

#chat-widget .chat-widget-error {
    padding: 6px 12px;
    font-size: 13px;
    color: #c0392b;
}

#chat-widget .d-none {
    display: none !important;
}


/* ── Responsive — Narrow Screens (≤ 480px) ─────────────────────────────────── */

@media (max-width: 480px) {
    #chat-widget .chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 20px);
        right: 10px;
        bottom: 10px;
        border-radius: 18px;
    }

    #chat-widget .chat-body {
        bottom: 210px;
    }

    #chat-widget .header-pill {
        left: 12px;
        right: 12px;
        top: 12px;
    }

    #chat-widget .chat-footer {
        left: 12px;
        right: 12px;
        bottom: 12px;
    }

    #chat-widget .chat-suggestions {
        justify-content: center;
    }
}


/* ── Responsive — Very Small Screens (≤ 360px) ──────────────────────────────── */

@media (max-width: 360px) {
    #chat-widget .chatbot-flobation-icon {
        bottom: 20px;
        right: 10px;
        transform: scale(0.95);
    }

    #chat-widget .chat-suggestions {
        justify-content: center;
    }
}
