﻿
body {
    background: #f4f4f4;
    font-family: "Segoe UI", sans-serif;
    margin: 0;
}

/* Wrapper cố định Chatbot ở góc dưới bên phải */
.chat-widget-wrapper {
    position: fixed;
    bottom: 80px;
    right: 20px;
    z-index: 1000;
}

/* Hộp Chat (Container) */
.chat-container {
    width: 400px;
    height: 500px;
    margin: 0;
    position: relative;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    padding: 0;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out, transform 0.3s ease-in-out;
}

/* Thanh tiêu đề màu xanh (Header) */
.chat-header-bar { 
    background: #0078D7;
    color: white;
    font-size: 1.1em;
    font-weight: 600;
    padding: 12px 20px;
    text-align: center;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}
/* Nút Mở (Icon Toggle) */
.chat-toggle-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #0078D7;
    color: white;
    border: none;
    font-size: 24px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    display: none;
    position: absolute;
    bottom: 0;
    right: 0;
}


/* Điều khiển hiển thị khi đóng/mở */
/* Khi hộp chat ĐÓNG: */
.chat-widget-wrapper.closed .chat-container,
.chat-widget-wrapper.closed .chat-close-btn {
    /* Ẩn hộp chat và nút X */
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    display: none;
}

/* Khi hộp chat ĐÓNG: HIỆN NÚT MỞ (Toggle Button) */
.chat-widget-wrapper.closed .chat-toggle-btn {
    display: flex; /* Hiển thị nút mở */
}

/* Nút ĐÓNG (X) */
.chat-close-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #0078D7;
    color: white;
    border: none;
    font-size: 20px;
    position: absolute;
    bottom: 0;
    right: 0;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(100%);
    margin-right: -10px;
    margin-bottom: -10px;
}

/* Class để ẩn toàn bộ widget khi đóng */
.chat-widget-wrapper.closed .chat-container {
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
}

.chat-widget-wrapper.closed .chat-close-btn {
    display: none;
}


/* ------------------------------------------- */
/* HIỂN THỊ TIN NHẮN VÀ INPUT */
/* ------------------------------------------- */
.chat-box {
    height: 380px;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    background-color: #fcfcfc;
    border: none;
    margin-bottom: 0;
}

    /* Base style cho tin nhắn */
    .chat-box > div {
        max-width: 80%;
        padding: 10px 15px;
        border-radius: 18px;
        margin: 8px 10px;
        word-wrap: break-word;
        line-height: 1.4;
        transition: opacity 0.3s ease-in, transform 0.3s ease-in;
    }

/* Tin nhắn Người dùng */
.user-msg {
    color: white;
    background: #0078D7;
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

/* Tin nhắn Bot */
.bot-msg {
    color: #333;
    background: #e9e9e9;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

/* Hiệu ứng Animation */
@keyframes fadeInSlideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-new, .bot-new {
    animation: fadeInSlideUp 0.3s ease-out;
}

/* Khu vực Input */
.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 10px;
}

    .chat-input-area input {
        flex: 1;
        padding: 10px;
        border: 1px solid #ccc;
        border-radius: 20px;
        font-size: 16px;
    }

    /* Nút Gửi */
    .chat-input-area button {
        padding: 10px 18px;
        background: #0078D7;
        color: white;
        border: none;
        border-radius: 20px;
        cursor: pointer;
        font-size: 16px;
    }

        .chat-input-area button:hover {
            background: #005EA6;
        }
