/* Tổng thể Widget Chat */
#chat-widget {
    position: fixed;
    /* Đẩy toàn bộ cụm chat lên cao để không bị nút cuộn trang (ở mức 70px-110px) đè lên */
    bottom: 130px !important; 
    right: 20px;
    z-index: 9999; /* Đảm bảo nằm trên cùng để dễ thao tác */
    font-family: Arial, sans-serif;
}

/* Nút tròn dùng để mở/đóng chat */
#chat-toggle {
    background: #28a745;
    color: white;
    width: 55px;
    height: 55px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

#chat-toggle:hover {
    transform: scale(1.05);
}

/* Hộp thoại chat (Chat Box) */
#chat-box {
    width: 300px;
    height: 400px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 10px; /* Khoảng cách với nút tròn phía dưới */
}

/* Header của chat box */
#chat-header {
    background: #28a745;
    color: white;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Khu vực hiển thị nội dung tin nhắn */
#chat-messages {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    background: #f5f5f5;
    display: flex;
    flex-direction: column;
}

/* Định dạng tin nhắn của Bot và Người dùng */
.bot-msg {
    background: #e2ffc7;
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 8px;
    max-width: 80%;
    align-self: flex-start;
}

.user-msg {
    background: #c7eaff;
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 8px;
    max-width: 80%;
    align-self: flex-end;
}

/* Khu vực nhập tin nhắn */
#chat-input {
    display: flex;
    padding: 10px;
    border-top: 1px solid #ddd;
    background: white;
    align-items: center; /* Căn giữa input và button theo chiều dọc */
}

/* Ô nhập văn bản */
#chat-input input {
    flex: 1;
    border: 1px solid #eee;
    outline: none;
    padding: 8px 12px;
    font-size: 14px;
    height: 35px;
    /* QUAN TRỌNG: Xóa bỏ margin-bottom 30px từ style.css để không làm lệch nút gửi */
    margin-bottom: 0 !important; 
    border-radius: 4px;
}

/* Nút gửi tin nhắn */
#send-btn {
    background: #28a745;
    color: white;
    border: none;
    height: 35px; /* Khớp chiều cao với ô input */
    padding: 0 15px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    margin-left: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#send-btn:hover {
    background: #218838;
}

/* Nút đóng chat (X) */
#chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
}

/* Tùy chỉnh thanh cuộn cho khu vực tin nhắn */
#chat-messages::-webkit-scrollbar {
    width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

/* Trạng thái ẩn */
.hidden {
    display: none !important;
}