/* =========================================================
   LMTC CHATBOT
========================================================= */

.lmtc-chatbot {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 99999;

    font-family:
        "Inter",
        "Poppins",
        sans-serif;
}


/* =========================================================
   FLOATING BUTTON
========================================================= */

.chatbot-launcher {
    position: relative;

    width: 60px;
    height: 60px;

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

    border: 0;
    border-radius: 18px;

    color: #ffffff;

    background:
        linear-gradient(
            135deg,
            #0755a2,
            #0d76c8
        );

    font-size: 22px;

    cursor: pointer;

    box-shadow:
        0 14px 35px
        rgba(8, 85, 158, .32);

    transition:
        transform .2s ease,
        box-shadow .2s ease;
}

.chatbot-launcher:hover {
    transform: translateY(-3px);

    box-shadow:
        0 18px 45px
        rgba(8, 85, 158, .40);
}

.launcher-status {
    position: absolute;

    top: 3px;
    right: 3px;

    width: 11px;
    height: 11px;

    background: #35d884;

    border: 2px solid #ffffff;
    border-radius: 50%;
}


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

.chatbot-window {
    position: absolute;

    right: 0;
    bottom: 76px;

    width: 390px;
    height: 560px;

    display: none;
    flex-direction: column;

    overflow: hidden;

    background: #ffffff;

    border: 1px solid #d9e4ed;
    border-radius: 20px;

    box-shadow:
        0 28px 65px
        rgba(31, 56, 78, .24);
}

.chatbot-window.show {
    display: flex;

    animation:
        chatbotOpen .18s ease;
}

@keyframes chatbotOpen {

    from {
        opacity: 0;
        transform: translateY(10px) scale(.97);
    }

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

}


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

.chatbot-header {
    min-height: 76px;

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

    padding: 13px 16px;

    color: #ffffff;

    background:
        linear-gradient(
            135deg,
            #064f91,
            #0a6dbc
        );
}

.chatbot-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chatbot-logo {
    width: 45px;
    height: 45px;

    flex: 0 0 45px;

    padding: 3px;

    background: #ffffff;

    border-radius: 50%;
}

.chatbot-logo img {
    width: 100%;
    height: 100%;

    display: block;

    object-fit: contain;

    border-radius: 50%;
}

.chatbot-brand-info strong {
    display: block;

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

.chatbot-brand-info span {
    display: flex;
    align-items: center;
    gap: 5px;

    margin-top: 4px;

    color: #d9ecfa;

    font-size: 10px;
}

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

    display: block;

    background: #43e08e;

    border-radius: 50%;
}

.chatbot-close {
    width: 36px;
    height: 36px;

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

    border: 0;
    border-radius: 10px;

    color: #ffffff;

    background:
        rgba(255, 255, 255, .13);

    cursor: pointer;
}

.chatbot-close:hover {
    background:
        rgba(255, 255, 255, .23);
}


/* =========================================================
   BODY
========================================================= */

.chatbot-body {
    flex: 1;

    min-height: 0;

    padding: 17px;

    overflow-y: auto;

    background:
        linear-gradient(
            180deg,
            #f6f9fc 0%,
            #f8fafc 100%
        );

    scroll-behavior: smooth;
}

.chatbot-body::-webkit-scrollbar {
    width: 5px;
}

.chatbot-body::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-body::-webkit-scrollbar-thumb {
    background: #aebdca;

    border-radius: 20px;
}


/* =========================================================
   WELCOME
========================================================= */

.bot-row {
    display: flex;
    align-items: flex-start;

    gap: 9px;

    margin-bottom: 13px;
}

.bot-avatar {
    width: 34px;
    height: 34px;

    flex: 0 0 34px;

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

    color: #0872bd;
    background: #e9f5fd;

    border-radius: 50%;

    font-size: 12px;
}

.bot-bubble {
    max-width: 78%;

    padding: 11px 14px;

    color: #35566f;
    background: #ffffff;

    border: 1px solid #d5e1ea;

    border-radius:
        5px 15px 15px 15px;

    font-size: 13px;

    line-height: 1.7;
}


/* =========================================================
   CHAT HISTORY
========================================================= */

.chatbot-conversation {
    display: flex;
    flex-direction: column;

    gap: 10px;

    width: 100%;

    margin-top: 8px;
}

.chatbot-conversation:empty {
    display: none;
}


/* =========================================================
   USER QUESTION
========================================================= */

.user-row {
    width: 100%;

    display: flex;
    justify-content: flex-end;

    margin: 3px 0;
}

.user-bubble {
    max-width: 80%;

    padding: 11px 14px;

    color: #ffffff;

    background:
        linear-gradient(
            135deg,
            #075ca9,
            #0877ca
        );

    border-radius:
        15px 15px 5px 15px;

    font-size: 13px;

    line-height: 1.65;

    white-space: pre-line;
    word-break: break-word;
}


/* =========================================================
   BOT ANSWER
========================================================= */

.answer-row {
    width: 100%;

    display: flex;
    align-items: flex-start;

    gap: 9px;

    margin: 3px 0 9px;
}

.answer-bubble {
    max-width: 80%;

    padding: 11px 14px;

    color: #35566f;
    background: #ffffff;

    border: 1px solid #d5e1ea;

    border-radius:
        5px 15px 15px 15px;

    font-size: 13px;

    line-height: 1.72;

    white-space: pre-line;
    word-break: break-word;
}


/* =========================================================
   TYPING INDICATOR
========================================================= */

.chatbot-typing-row {
    width: 100%;

    display: flex;
    align-items: flex-start;

    gap: 9px;

    margin: 3px 0 9px;
}

.chatbot-typing-bubble {
    min-width: 58px;
    height: 42px;

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

    gap: 5px;

    padding: 0 13px;

    background: #ffffff;

    border: 1px solid #d5e1ea;

    border-radius:
        5px 15px 15px 15px;
}

.chatbot-typing-bubble span {
    width: 7px;
    height: 7px;

    display: block;

    background: #8398aa;

    border-radius: 50%;

    animation:
        chatbotTypingDot
        1.15s
        infinite
        ease-in-out;
}

.chatbot-typing-bubble span:nth-child(2) {
    animation-delay: .15s;
}

.chatbot-typing-bubble span:nth-child(3) {
    animation-delay: .30s;
}

@keyframes chatbotTypingDot {

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

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

}


/* =========================================================
   MENU TITLE
========================================================= */

.chatbot-menu-title {
    margin-top: 19px;
    margin-bottom: 10px;

    color: #50697d;

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

    text-transform: uppercase;

    letter-spacing: .4px;
}


/* =========================================================
   BACK BUTTON
========================================================= */

.chatbot-back-button {
    display: none;

    align-items: center;

    gap: 6px;

    margin: 4px 0 11px;

    padding: 8px 11px;

    color: #0870b9;
    background: #eaf6fd;

    border: 0;
    border-radius: 8px;

    font-family: inherit;
    font-size: 11px;

    cursor: pointer;
}

.chatbot-back-button.show {
    display: inline-flex;
}

.chatbot-back-button:hover {
    background: #dceffc;
}


/* =========================================================
   QUESTION LIST
========================================================= */

.chatbot-question-list {
    display: flex;
    flex-direction: column;

    gap: 9px;
}

.chatbot-question-button {
    width: 100%;

    display: flex;
    align-items: center;

    gap: 11px;

    padding: 11px 12px;

    color: #173f61;
    background: #ffffff;

    border: 1px solid #d3e0ea;
    border-radius: 12px;

    font-family: inherit;
    text-align: left;

    cursor: pointer;
}

.chatbot-question-button:hover {
    background: #f7fbff;
    border-color: #0874c9;
}

.chatbot-question-button:disabled {
    pointer-events: none;
}


/* =========================================================
   QUESTION ICON
========================================================= */

.question-icon {
    width: 36px;
    height: 36px;

    flex: 0 0 36px;

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

    color: #0872bd;
    background: #edf7ff;

    border-radius: 9px;

    font-size: 12px;
}


/* =========================================================
   QUESTION TEXT
========================================================= */

.question-text {
    flex: 1;

    min-width: 0;

    color: #254a68;

    font-size: 12px;

    line-height: 1.6;
}


/* =========================================================
   ARROW
========================================================= */

.question-arrow {
    flex: 0 0 auto;

    color: #91a7b7;

    font-size: 10px;
}


/* =========================================================
   LOADING / EMPTY
========================================================= */

.chatbot-loading {
    display: flex;
    align-items: center;
    justify-content: center;

    gap: 8px;

    padding: 14px;

    color: #8295a5;
    background: #ffffff;

    border: 1px dashed #d7e2eb;
    border-radius: 10px;

    font-size: 11px;
}

.chatbot-empty,
.chatbot-empty-questions {
    width: 100%;

    display: flex;
    align-items: center;

    gap: 10px;

    padding: 13px 14px;

    color: #4d697d;
    background: #f5fafc;

    border: 1px solid #d6e5ef;
    border-radius: 11px;

    font-size: 12px;
}

.chatbot-empty-questions i {
    color: #20aa6b;
}


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

.chatbot-footer {
    min-height: 41px;

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

    gap: 5px;

    color: #8a9baa;
    background: #ffffff;

    border-top: 1px solid #e3ebf2;

    font-size: 9px;
}

.chatbot-footer strong {
    color: #1870b8;
}


/* =========================================================
   KHMER
========================================================= */

html[lang="km"] .lmtc-chatbot {
    font-family:
        "Noto Sans Khmer",
        sans-serif;
}

html[lang="km"] .bot-bubble,
html[lang="km"] .user-bubble,
html[lang="km"] .answer-bubble,
html[lang="km"] .question-text,
html[lang="km"] .chatbot-menu-title,
html[lang="km"] .chatbot-back-button {
    font-family:
        "Noto Sans Khmer",
        sans-serif;

    line-height: 1.8;
}

html[lang="km"] .chatbot-menu-title {
    text-transform: none;
}


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

@media (max-width: 480px) {

    .lmtc-chatbot {
        right: 12px;
        bottom: 12px;
    }

    .chatbot-window {
        position: fixed;

        top: 10px;
        left: 10px;
        right: 10px;
        bottom: 78px;

        width: auto;
        height: auto;
    }

}

/* Chatbot window */
#chatbotWindow {
    position: fixed !important;
    top: auto !important;
    left: auto !important;
    right: 24px !important;
    bottom: 100px !important;

    width: min(380px, calc(100vw - 32px)) !important;
    height: min(520px, calc(100vh - 116px)) !important;
    height: min(520px, calc(100dvh - 116px)) !important;
    min-height: 0 !important;

    box-sizing: border-box;
    border-radius: 18px;
    overflow: hidden;
}

/* Header */
#chatbotWindow .chatbot-header {
    flex: 0 0 auto;
    min-height: 68px;
    padding: 10px 14px;
    box-sizing: border-box;
    gap: 10px;
}

#chatbotWindow .chatbot-brand {
    min-width: 0;
    gap: 9px;
}

#chatbotWindow .chatbot-logo {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    box-sizing: border-box;
}

#chatbotWindow .chatbot-brand-info strong {
    font-size: 15px;
}

#chatbotWindow .chatbot-close {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
}

/* Scroll តែក្នុងតំបន់សារ និងសំណួរ */
#chatbotBody {
    flex: 1 1 0;
    min-height: 0;
    padding: 12px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
}

#chatbotWindow .chatbot-footer {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 6px 10px;
    box-sizing: border-box;
}

/* Mobile */
@media (max-width: 600px) {
    #chatbotWindow {
        right: 12px !important;
        bottom: 86px !important;

        width: min(380px, calc(100vw - 24px)) !important;
        height: min(480px, calc(100vh - 102px)) !important;
        height: min(480px, calc(100dvh - 102px)) !important;
    }
}

/* អេក្រង់កម្ពស់ទាប */
@media (max-height: 500px) {
    #chatbotWindow {
        bottom: 12px !important;
        height: calc(100vh - 24px) !important;
        height: calc(100dvh - 24px) !important;
    }
}

html[lang="km"] #chatbotWindow,
html[lang="km"] #chatbotWindow .bot-bubble,
html[lang="km"] #chatbotWindow .user-bubble,
html[lang="km"] #chatbotWindow .answer-bubble,
html[lang="km"] #chatbotWindow .question-text,
html[lang="km"] #chatbotWindow .chatbot-menu-title,
html[lang="km"] #chatbotWindow .chatbot-back-button,
html[lang="km"] #chatbotWindow .chatbot-brand-info,
html[lang="km"] #chatbotWindow .chatbot-footer {
    font-family: "Battambang", "Khmer OS Battambang", sans-serif !important;
}

html[lang="km"] #chatbotWindow .bot-bubble,
html[lang="km"] #chatbotWindow .user-bubble,
html[lang="km"] #chatbotWindow .answer-bubble,
html[lang="km"] #chatbotWindow .question-text {
    font-size: 14px;
    font-weight: 400;
    line-height: 1.9;
}