/* ==============================================
   FILE: CSS/chat.css
   STYLE CHO HỘP CHAT (CHAT BOX POPUP)
   ============================================== */

/* Khung Hộp chat */
.chat-popup {
    display: none; /* Mặc định ẩn */
    position: fixed;
    bottom: 20px; /* Cách đáy */
    right: 90px;  /* Cách phải 90px (để tránh hàng icon nổi bên phải) */
    width: 320px;
    height: 400px; /* Chiều cao cố định */
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    z-index: 9999;
    overflow: hidden;
    border: 1px solid #ddd;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    flex-direction: column; /* Xếp header, body, footer dọc */
    animation: slideIn 0.3s ease;
}

/* Hiệu ứng trượt lên khi mở */
@keyframes slideIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- 1. HEADER --- */
.chat-header {
    background: #002d72; /* Màu xanh thương hiệu */
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #001f52;
}
.chat-header h4 {
    margin: 0;
    font-size: 1em;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.chat-header-actions { display: flex; align-items: center; gap: 8px; }
.chat-header-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.05em;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, background 0.2s;
}
.chat-header-btn:hover {
    opacity: 0.95;
    background: rgba(255,255,255,0.18);
}

/* --- 2. BODY (DANH SÁCH TIN NHẮN) --- */
.chat-body {
    flex: 1; /* Chiếm toàn bộ không gian còn lại */
    overflow-y: auto; /* Cho phép cuộn */
    padding: 15px;
    background: #f5f7fb; /* Màu nền xám nhạt */
    display: flex;
    flex-direction: column;
    gap: 12px; /* Khoảng cách giữa các tin nhắn */
}

/* --- 3. FOOTER (Ô NHẬP LIỆU) --- */
.chat-footer {
    display: flex;
    padding: 10px;
    background: white;
    border-top: 1px solid #eee;
    align-items: center;
}
.chat-footer input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-size: 0.95em;
    transition: border-color 0.2s;
}
.chat-footer input:focus {
    border-color: #007bff;
}
.chat-footer button {
    background: none;
    border: none;
    color: #002d72;
    font-size: 1.4em;
    margin-left: 10px;
    cursor: pointer;
    transition: transform 0.2s;
}
.chat-footer button:hover {
    transform: scale(1.1);
    color: #0056b3;
}

.chat-footer .emoji-btn {
    font-size: 1.3em;
    margin-left: 8px;
    opacity: 0.9;
}

.emoji-picker {
    position: absolute;
    right: 12px;
    bottom: 64px;
    width: 260px;
    max-width: calc(100% - 24px);
    background: #ffffff;
    border: 1px solid #e6e9ef;
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.14);
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 6px;
    z-index: 10000;
}

.emoji-item {
    border: none;
    background: #f4f6f9;
    border-radius: 10px;
    cursor: pointer;
    padding: 6px 0;
    font-size: 16px;
}

.emoji-item:hover { background: #e9edf3; }

/* --- 4. STYLE TIN NHẮN (MESSAGE BUBBLES) --- */

/* Bao quanh tin nhắn (để căn lề) */
.msg-wrapper-me { 
    align-self: flex-end; 
    display: flex; 
    flex-direction: column; 
    align-items: flex-end; 
    max-width: 85%; 
}
.msg-wrapper-you { 
    align-self: flex-start; 
    display: flex; 
    flex-direction: column; 
    align-items: flex-start; 
    max-width: 85%; 
}

/* Bong bóng tin nhắn */
.msg-bubble-me {
    background: #007bff; /* Màu xanh cho user */
    color: white;
    padding: 8px 12px;
    border-radius: 15px 15px 0 15px;
    font-size: 0.95em;
    line-height: 1.4;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    word-wrap: break-word;
}

.msg-bubble-you {
    background: #e4e6eb; /* Màu xám cho admin */
    color: #050505;
    padding: 8px 12px;
    border-radius: 15px 15px 15px 0;
    font-size: 0.95em;
    line-height: 1.4;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    word-wrap: break-word;
}

/* Thời gian tin nhắn */
.msg-time {
    font-size: 0.7em;
    color: #999;
    margin-top: 4px;
    margin-right: 2px;
}