/* Container chính của chatbot đặt cố định ở góc dưới bên phải */
.dti-chatbot-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 10000;
    font-family: inherit; /* Thừa kế font của ứng dụng */
}

/* Nút bấm để mở/đóng chat */
.dti-chatbot-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #5867dd; /* Màu primary mặc định của metronic/DTI, có thể chỉnh lại cho phù hợp */
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.dti-chatbot-toggle-btn i {
    font-size: 24px;
}

.dti-chatbot-toggle-btn:hover {
    transform: scale(1.1);
    background-color: #384ad7;
}

/* Cửa sổ chat */
.dti-chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background-color: #fff;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    transform-origin: bottom right;
    transition: all 0.3s ease;
    opacity: 1;
    transform: scale(1);
}

/* Trạng thái ẩn của cửa sổ chat */
.dti-chatbot-window.d-none {
    display: flex !important; /* Ghi đè d-none của Bootstrap để dùng hiệu ứng opacity/scale */
    opacity: 0;
    transform: scale(0.5);
    pointer-events: none;
    visibility: hidden;
}

/* Header */
.dti-chatbot-header {
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.btn-transparent-white {
    background: transparent;
    border: none;
    color: white;
}

.btn-transparent-white:hover {
    color: #e0e0e0;
}

/* Body: Chứa danh sách tin nhắn */
.dti-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background-color: #f8f9fa;
}

/* Tin nhắn */
.chat-message {
    margin-bottom: 15px;
    display: flex;
}

/* Tin nhắn của Bot */
.bot-message {
    justify-content: flex-start;
}

/* Tin nhắn của User */
.user-message {
    justify-content: flex-end;
}

.user-message .chat-bubble {
    background-color: #5867dd !important; /* Màu Primary */
    color: white !important;
    border-bottom-right-radius: 4px !important;
}

.bot-message .chat-bubble {
    border-bottom-left-radius: 4px !important;
}

/* Hiệu ứng loading "đang gõ..." */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 10px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: #90949c;
    border-radius: 50%;
    margin: 0 2px;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Footer: Ô nhập text */
.dti-chatbot-footer {
    background-color: #fff;
}

#dti-chatbot-input:focus {
    box-shadow: none;
    background-color: #fff !important;
    border-color: #5867dd;
}

/* Responsive cho mobile */
@media (max-width: 576px) {
    .dti-chatbot-window {
        position: fixed;
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    
    .dti-chatbot-header {
        border-radius: 0;
    }
    
    .dti-chatbot-container {
        bottom: 15px;
        right: 15px;
    }
}


.custom-chatbot-wrapper {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    font-family: Arial, sans-serif;
}

.custom-chatbot-button {
    width: 60px;
    height: 60px;
    background-color: #5867dd;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: transform 0.2s ease;
}

    .custom-chatbot-button:hover {
        transform: scale(1.05);
    }

.custom-chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.custom-chatbot-header {
    background-color: #5867dd;
    color: white;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.custom-chatbot-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.custom-chatbot-logo {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: white;
    padding: 2px;
    object-fit: contain;
}

.custom-chatbot-title {
    font-weight: bold;
    font-size: 15px;
}

.custom-chatbot-header-right {
    display: flex;
    gap: 5px;
}

.custom-chatbot-action-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
}

    .custom-chatbot-action-btn:hover {
        background-color: rgba(255,255,255,0.2);
    }

.custom-chatbot-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background-color: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chatbot-msg {
    display: flex;
    max-width: 80%;
}

.chatbot-msg-bot {
    align-self: flex-start;
}

.chatbot-msg-user {
    align-self: flex-end;
}

.chatbot-msg-content {
    padding: 10px 15px;
    border-radius: 15px;
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word;
}

.chatbot-msg-bot .chatbot-msg-content {
    background-color: #ffffff;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

.chatbot-msg-user .chatbot-msg-content {
    background-color: #5867dd;
    color: white;
    border-bottom-right-radius: 4px;
}

.chatbot-msg-content p {
    margin: 0;
    white-space: pre-wrap;
}

.chatbot-msg-content a {
    color: #007bff;
    text-decoration: underline;
}

.chatbot-msg-user .chatbot-msg-content a {
    color: #cce5ff;
}

.custom-chatbot-input-area {
    display: flex;
    padding: 10px;
    background-color: white;
    border-top: 1px solid #e0e0e0;
    gap: 10px;
}

    .custom-chatbot-input-area input {
        flex: 1;
        border: 1px solid #e0e0e0;
        border-radius: 20px;
        padding: 8px 15px;
        outline: none;
        font-size: 14px;
    }

        .custom-chatbot-input-area input:focus {
            border-color: #5867dd;
        }

    .custom-chatbot-input-area button {
        background-color: #5867dd;
        border: none;
        color: white;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        display: flex;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        font-size: 16px;
        flex-shrink: 0;
    }

        .custom-chatbot-input-area button:hover {
            background-color: #4a58c2;
        }

/* Hiệu ứng typing */
.chatbot-typing {
    display: flex;
    gap: 4px;
    padding: 5px 10px;
}

.chatbot-typing-dot {
    width: 6px;
    height: 6px;
    background-color: #999;
    border-radius: 50%;
    animation: chatbot-typing 1.4s infinite both;
}

    .chatbot-typing-dot:nth-child(1) {
        animation-delay: -0.32s;
    }

    .chatbot-typing-dot:nth-child(2) {
        animation-delay: -0.16s;
    }

@keyframes chatbot-typing {
    0%, 80%, 100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}