#chat-toggle {
    position: fixed;
    bottom: 10px;
    right: 20px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    animation: chatbotBounce 3s ease-in-out infinite;
    z-index: 999;
}
.chat-bubble img {
    width: 75px;
    height: 75px;
    object-fit: contain;
}
.chat-bubble::before {
    content: "✦";
    position: absolute;
    top: -5px;
    right: -2px;

    width: 20px;
    height: 20px;

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

    background: #ffffff;
    color: #6759e8;

    border-radius: 50%;

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

    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);

    animation: aiSparkle 2s infinite;
}
@keyframes aiSparkle {
    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.25);
        opacity: 0.7;
    }
}
#chat-box {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 480px;
    height: calc(100dvh - 1.5rem);
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,.2);
    overflow: hidden;
    z-index: 9999;
    animation: chatOpen 0.25s ease-out;
}
#chat-box .chatbox-wrapper{
    display: flex;
    flex-direction: column;
    height: 100%;
}
.chat-header {
    background: #0d6efd;
    color: white;
    padding: 15px;
    font-weight: bold;
}

#close-chat {
    float: right;
    cursor: pointer;
}

#messages {
    flex: 1;
    /* height: 360px; */
    overflow-y: auto;
    padding: 15px;
    scroll-behavior: smooth;
}
#messages::-webkit-scrollbar {
    width: 5px;
}

#messages::-webkit-scrollbar-thumb {
    background: #d4d7dc;
    border-radius: 10px;
}

.chat-footer {
    /* display: flex; */
    border-top: 1px solid #ddd;
    padding: 10px 15px;
    position: relative;
}
.chat-footer .ai-input-sparkle {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 24px;
    height: 24px;

    flex-shrink: 0;

    color: #6759e8;

    font-size: 18px;

    animation: inputSparkle 2s ease-in-out infinite;
}
@keyframes inputSparkle {
    0%,
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 0.7;
    }

    50% {
        transform: scale(1.15) rotate(8deg);
        opacity: 1;
    }
}
.chat-footer button {
    width: 40px;
    height: 40px;

    flex-shrink: 0;

    border: none;

    border-radius: 50%;

    background: #F7B316;

    color: #16233A;

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

    cursor: pointer;

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

.chat-footer button:hover {
    transform: scale(1.06);

    background: #e9a700;
}

.chat-footer button:active {
    transform: scale(0.95);
}
/* =========================================
   POWERED BY
========================================= */

.chat-powered {
    text-align: center;

    padding-top: 7px;

    font-size: 10px;

    color: #a0a5ad;
}

.chat-powered strong {
    color: #737983;
}
/* #typing{
    font-style:italic;
    color:#777;
} */
/* .typing-message {
    width: 55px;

    display: flex;

    align-items: center;

    justify-content: center;

    gap: 4px;

    padding: 13px 10px;
}

.typing-message span {
    width: 6px;
    height: 6px;

    background: #8d939c;

    border-radius: 50%;

    animation: typingDots 1.4s infinite ease-in-out;
}

.typing-message span:nth-child(1) {
    animation-delay: 0s;
}

.typing-message span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-message span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDots {

    0%,
    60%,
    100% {
        transform: translateY(0);

        opacity: 0.4;
    }

    30% {
        transform: translateY(-5px);

        opacity: 1;
    }

} */


@keyframes chatbotBounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-12px);
    }

    60% {
        transform: translateY(-6px);
    }
}

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

/* Opening animation */

@keyframes chatOpen {

    from {
        opacity: 0;
        transform: translateY(15px) scale(0.97);
    }

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

}


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

.chat-header {
    min-height: 76px;
    padding: 14px 18px;
    background: #F7B316;
    display: flex;
    align-items: center;
    justify-content: space-between;
}


/* Header left */

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.chat-header-right{
    display: flex;
    gap: 20px;
}

/* Logo */

.chat-logo {
    width: 46px;
    height: 46px;
    background: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.chat-logo img {
    width: 34px;
    height: 34px;
    object-fit: contain;
}

/* Header text */

.chat-header-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-title {
    font-size: 16px;
    font-weight: 700;
    color: #16233A;
}

.chat-online {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #364152;
}

.chat-online span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #3D9B31;
}


/* Close button */

.chat-close {
    width: 34px;
    height: 34px;
    border: none;
    background: rgba(255, 255, 255, 0.45);
    border-radius: 50%;
    font-size: 25px;
    line-height: 1;
    color: #16233A;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.chat-close:hover {
    background: #ffffff;
}

/* =========================================
   BOT MESSAGE
========================================= */

.bot-message {
    width: 88%;
    margin-bottom: 14px;
    padding: 13px 15px;
    background: #ffffff;
    color: #263244;
    border-radius: 4px 16px 16px 16px;
    font-size: 14px;
    line-height: 1.6;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid #eeeeee;
    /* width:fit-content; */
}
.bot-message .ai-message-content .ai-response-text{
    white-space: unset;
}
.ai-thinking {
    display: flex;
    align-items: center;
    gap: 9px;
    /* padding: 12px 15px; */
    width: fit-content;
    background: #ffffff;
    /* border: 1px solid #e8edf3;
    border-radius: 6px 18px 18px 18px; */
    color: #59636e;
    font-size: 13px;
    /* box-shadow:
        0 3px 12px rgba(0, 0, 0, 0.04); */
}


/* AI sparkle */

.thinking-sparkle {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 24px;
    height: 24px;

    flex-shrink: 0;

    border-radius: 50%;

    background: linear-gradient(
        135deg,
        #0a69b1,
        #6759e8
    );

    color: #ffffff;

    font-size: 12px;

    animation: thinkingSparkle 1.5s ease-in-out infinite;
}

@keyframes thinkingSparkle {

    0% {
        transform: rotate(0deg) scale(1);
        box-shadow:
            0 0 0 0 rgba(103, 89, 232, 0.3);
    }

    50% {
        transform: rotate(180deg) scale(1.1);
        box-shadow:
            0 0 0 6px rgba(103, 89, 232, 0.08);
    }

    100% {
        transform: rotate(360deg) scale(1);
        box-shadow:
            0 0 0 0 rgba(103, 89, 232, 0.3);
    }
}


/* Text */

.thinking-content {
    display: flex;
    align-items: center;
    gap: 4px;
}

.thinking-text {
    white-space: nowrap;
}


/* Animated dots */

.thinking-dots {
    display: inline-flex;

    gap: 3px;

    margin-left: 1px;
}

.thinking-dots span {
    width: 3px;
    height: 3px;

    border-radius: 50%;

    background: #7b8794;

    animation: thinkingDots 1.3s infinite ease-in-out;
}

.thinking-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.thinking-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes thinkingDots {

    0%,
    60%,
    100% {
        opacity: 0.25;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-2px);
    }
}

/* =========================================
   USER MESSAGE
========================================= */

.user-message {
    max-width: 82%;
    margin-left: auto;
    margin-bottom: 14px;
    padding: 12px 15px;
    background: #16233A;
    color: #ffffff;
    border-radius: 16px 4px 16px 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    width:fit-content;
}


/* =========================================
   QUICK BUTTONS
========================================= */

.quick-btn {
    display: inline-block;
    margin: 5px 4px 0 0;
    padding: 8px 13px;
    background: #ffffff;
    color: #16233A;
    border: 1px solid #F7B316;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-btn:hover {
    background: #F7B316;
    border-color: #F7B316;
    transform: translateY(-1px);
}


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

.chat-input-area {
    padding: 12px 14px 10px;

    background: #ffffff;

    border-top: 1px solid #eeeeee;
}


/* Input wrapper */

.chat-input-wrapper {
    display: flex;

    align-items: center;

    gap: 8px;

    padding: 5px 5px 5px 15px;

    background: #f5f6f8;

    border: 1px solid #e1e3e7;

    border-radius: 28px;

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

.chat-input-wrapper:focus-within {
    border-color: #F7B316;

    box-shadow:
        0 0 0 3px rgba(247, 179, 22, 0.12);
}


/* Input */

#message {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    color: #263244;
}

#message::placeholder {
    color: #969ca6;
}

@media (max-width: 576px) {

    .chat-bubble img{
        width: 55px;
        height: 55px;
    }

    #chat-box {
        left: 10px;
        right: 10px;
        bottom: 10px;
        width: auto;
        height: calc(100vh - 105px);
        max-height: 650px;
        border-radius: 18px;
    }

}
/* .ai-message-content {
    max-width: 84%;

    padding: 13px 15px;

    background: #ffffff;

    color: #263238;

    border: 1px solid #e8edf3;

    border-radius: 6px 18px 18px 18px;

    font-size: 14px;

    line-height: 1.65;

    box-shadow:
        0 3px 12px rgba(0, 0, 0, 0.04);
} */


/* AI label */

.ai-message-label {
    display: flex;

    align-items: center;

    gap: 5px;

    margin-bottom: 6px;

    color: #0a69b1;

    font-size: 11px;

    font-weight: 700;
}

.ai-message-label::before {
    content: "✦";

    font-size: 12px;
}


/* Response */

.ai-response-text {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.ai-response-text {
    line-height: 1.65;
}

.ai-response-text strong {
    font-weight: 700;
    color: #1f2937;
}

.ai-response-text p {
    margin: 0 0 12px;
}

.ai-response-text p:last-child {
    margin-bottom: 0;
}

.ai-response-text ol,
.ai-response-text ul {
    margin: 10px 0 12px;
    padding-left: 22px;
}

.ai-response-text li {
    margin-bottom: 8px;
}

.ai-response-text li:last-child {
    margin-bottom: 0;
}

.ai-response-text a {
    color: #0a69b1;
    font-weight: 600;
    text-decoration: none;
}

.ai-response-text a:hover {
    text-decoration: underline;
}
.clear-chat-modal {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.35);
    align-items: center;
    justify-content: center;
}

.clear-chat-modal.active {
    display: flex;
}

.clear-chat-dialog {
    width: 85%;
    max-width: 320px;
    padding: 24px;
    background: #fff;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
}

.clear-chat-icon {
    font-size: 28px;
    margin-bottom: 10px;
}

.clear-chat-dialog h3 {
    margin: 0 0 8px;
    font-size: 18px;
}

.clear-chat-dialog p {
    margin: 0 0 20px;
    font-size: 14px;
    color: #666;
}

.clear-chat-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.clear-chat-actions button {
    border: 0;
    padding: 9px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
}

#cancel-clear-chat {
    background: #eee;
}

#confirm-clear-chat {
    background: #d9534f;
    color: #fff;
}
.chat-header-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #ffffff;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}