/* ==================================
   Chatbot Stylings
   ================================== */

.chatbot-toggler {
    position: fixed;
    bottom: 100px; /* ลอยอยู่บนปุ่ม Back to top (ถ้า Back to top อยู่ที่ 30-40px) */
    right: 30px;
    background-color: #f9d800; /* สีเหลือง warning ของ bootstrap ปรับเข้ากับสีเว็บ */
    color: #141414;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

.chatbot-toggler:hover {
    transform: scale(1.1);
}

.chatbot-toggler.hide {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

.chatbot-container {
    position: fixed;
    bottom: 150px;
    right: 30px;
    width: 350px;
    max-width: 90vw;
    height: 500px;
    max-height: 80vh;
    background: #fff;
    border-radius: 15px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 9998;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.chatbot-container.show {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.chatbot-header {
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

.chatbot-body {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Scrollbar สำหรับกล่องแชท */
.chatbot-body::-webkit-scrollbar {
    width: 6px;
}
.chatbot-body::-webkit-scrollbar-track {
    background: #f1f1f1; 
}
.chatbot-body::-webkit-scrollbar-thumb {
    background: #ccc; 
    border-radius: 10px;
}

.chat-message {
    display: flex;
    max-width: 85%;
    animation: messageFadeIn 0.3s ease-out forwards;
}

@keyframes messageFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.bot-message {
    align-self: flex-start;
}

.chat-message.user-message {
    align-self: flex-end;
}

.message-content {
    padding: 10px 15px;
    border-radius: 15px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.bot-message .message-content {
    background: #e9ecef;
    color: #212529;
    border-top-left-radius: 0;
}

.user-message .message-content {
    background: #f9d800;
    color: #141414;
    border-top-right-radius: 0;
}

/* รองรับการแสดงผลรูปภาพและลิงก์จาก Summernote/HTML */
.bot-message .message-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin-top: 10px;
}

.bot-message .message-content a {
    color: #f9d800;
    text-decoration: underline;
    word-break: break-all;
}

.bot-message .message-content p {
    margin-bottom: 0.5rem;
}
.bot-message .message-content p:last-child {
    margin-bottom: 0;
}

.chatbot-footer {
    padding: 15px;
    background: #fff;
    border-top: 1px solid rgba(0,0,0,0.1);
}

/* Typing Indicator Animation */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #e9ecef;
    border-radius: 15px;
    border-top-left-radius: 0;
    width: fit-content;
    align-self: flex-start;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #6c757d;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* สำหรับจอมือถือ */
@media (max-width: 576px) {
    .chatbot-container {
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100% !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        bottom: 0 !important;
        right: 0 !important;
        top: 0 !important;
        left: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        z-index: 10005 !important;
    }

    /* Prevent iOS Auto-Zoom and increase touch target size for input */
    #chatbotInput {
        font-size: 16px !important;
        padding: 12px 16px !important;
        height: 48px !important;
    }

    /* Optimize send button touch target */
    #chatbotSendBtn {
        height: 48px !important;
        width: 48px !important;
        font-size: 16px !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Optimize close button in header */
    .chatbot-close {
        width: 40px !important;
        height: 40px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 18px !important;
        padding: 0 !important;
    }

    /* Expand option buttons for easier tapping */
    .chatbot-option-btn {
        padding: 10px 18px !important;
        font-size: 14px !important;
    }

    /* Toggler position adjustment for mobile (when closed) */
    .chatbot-toggler {
        bottom: 80px !important;
        right: 20px !important;
        width: 55px !important;
        height: 55px !important;
        font-size: 24px !important;
    }
}

/* Quick FAQ Options Container */
.chatbot-options-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 5px;
    align-self: flex-start;
    max-width: 90%;
    animation: fadeIn 0.3s ease-in-out;
}

.chatbot-option-btn {
    background-color: #ffffff;
    color: #212529;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
    word-break: break-word;
    text-align: left;
}

.chatbot-option-btn:hover {
    background-color: #f8f9fa;
    border-color: #f9d800; /* matching warning yellow */
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.chatbot-option-btn:active {
    transform: translateY(0);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

