/* File: /public/style.css - ĐÃ HỢP NHẤT TẤT CẢ CSS CHAT VÀO ĐÂY */

/* Thiết lập cơ bản */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: Arial, sans-serif; line-height: 1.6; background-color: #f4f4f4; }

/* Bố cục chính */
.container { display: flex; min-height: 100vh; }

/* Menu bên trái (chung) */
.menu {
    flex: 0 0 250px;
    background-color: #2c3e50;
    color: #ecf0f1;
    padding: 20px;
}
.menu h2 { text-align: center; margin-bottom: 20px; }
.menu ul { list-style: none; }
.menu ul li a {
    display: block;
    color: #ecf0f1;
    text-decoration: none;
    padding: 12px 15px;
    margin-bottom: 5px;
    border-radius: 5px;
    transition: background-color 0.3s;
    position: relative;
}
.menu ul li a:hover { background-color: #34495e; }
.menu ul li a.active { background-color: #3498db; font-weight: bold; }

/* === PHONG CÁCH CHO MENU BỊ KHÓA === */
.menu ul li a.locked {
    background-color: #7f8c8d;
    color: #bdc3c7;
    cursor: not-allowed; /* Con trỏ không cho phép */
}
.menu ul li a.locked::after {
    content: '🔒'; /* Biểu tượng khóa */
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
}

/* Nội dung bên phải (chung) */
.content { flex: 1; padding: 30px; background-color: #fff; }
.content-panel { display: none; animation: fadeIn 0.5s; }
.content-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.video-container { margin-bottom: 30px; }
.quiz-container { margin-top: 20px; border-top: 2px solid #eee; padding-top: 20px;}
.question { background-color: #f9f9f9; border: 1px solid #e7e7e7; padding: 15px; margin-bottom: 8px; border-radius: 5px; }
.question p { font-weight: bold; margin-bottom: 6px; }
.question label { display: block; margin-bottom: 1px; font-size: 0.95em; }
.fill-in-the-blank { width: 250px; padding: 8px; border: 1px solid #ccc; border-radius: 4px; }

/* Nút và thông báo (chung) */
.check-btn { display: inline-block; background-color: #27ae60; color: #fff; padding: 12px 25px; border: none; border-radius: 5px; cursor: pointer; font-size: 16px; margin-top: 10px; }
.check-btn:hover { background-color: #2ecc71; }
.feedback { margin-top: 15px; padding: 10px; border-radius: 5px; font-weight: bold; }
.feedback.success { background-color: #d4edda; color: #155724; }
.feedback.error { background-color: #f8d7da; color: #721c24; }


/* ======================================================= */
/* === KHUNG CHAT - CHAT CONTAINER (CHUNG CHO TẤT CẢ CÁC TRANG) === */
/* ======================================================= */

/* Nút bấm nổi ở góc màn hình */
#chat-toggle-button {
    position: fixed !important; /* ĐÃ SỬA: Đảm bảo vị trí cố định */
    bottom: 20px !important;    /* ĐÃ SỬA: Đảm bảo vị trí dưới */
    right: 20px !important;     /* ĐÃ SỬA: Đảm bảo vị trí phải */
    left: auto !important;      /* ĐÃ SỬA: Đảm bảo không bị đẩy sang trái */
    width: 60px;
    height: 60px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    cursor: pointer;
    z-index: 999;
    transition: transform 0.2s;
}

#chat-toggle-button:hover {
    transform: scale(1.1);
}

/* Lớp để ẩn/hiện khung chat */
#chat-container.chat-hidden {
    display: none !important; /* Dùng !important để đảm bảo ẩn */
}

/* Khung chat chính */
#chat-container { 
    position: fixed !important; /* ĐÃ SỬA: Đảm bảo vị trí cố định */
    bottom: 0 !important;       /* ĐÃ SỬA: Đảm bảo vị trí dưới */
    right: 20px !important;     /* ĐÃ SỬA: Đảm bảo vị trí phải */
    left: auto !important;      /* ĐÃ SỬA: Đảm bảo không bị đẩy sang trái */
    width: 550px; 
    height: 400px;
    display: flex !important; /* ĐÃ SỬA: Đảm bảo display là flex */
    box-shadow: 0 0 20px rgba(0,0,0,0.2);
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    /* ĐÃ SỬA: Loại bỏ viền ở đây để tránh trùng lặp với #chat-panel */
    /* border: 1px solid #ccc; */ 
    overflow: hidden;
    z-index: 1000;
    flex-direction: column; 
    transition: height 0.3s ease;
}

#chat-panel { 
    flex-grow: 1; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
}
#chat-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 10px 15px; 
    height: 50px;
    font-weight: bold;
    background: #007bff; 
    color: white;
    border-bottom: 1px solid #ddd; 
    flex-shrink: 0; 
}
#chat-partner-name {
    text-align: center;
    flex-grow: 1; 
}
#toggle-chat-btn {
    background: none;
    border: none;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    color: white; 
    padding: 0 10px;
    line-height: 1;
}
#chat-form { 
    background: #f1f1f1; 
    padding: 8px; 
    display: flex; 
    border-top: 1px solid #ccc; 
    flex-shrink: 0;
    min-height: 56px; /* BỔ SUNG: Đảm bảo form luôn có chiều cao tối thiểu*/
    box-sizing: border-box; /* Đảm bảo padding được tính vào chiều cao */
}
#chat-input { 
    border: 1px solid #ccc; 
    padding: 10px; 
    flex-grow: 1; 
    margin-right: 8px; 
    border-radius: 5px; 
    min-height: 40px; 
}
#chat-input:focus { outline: none; }
#chat-form > button { 
    background: #007bff; 
    border: none; 
    padding: 0 15px; 
    color: white; 
    border-radius: 5px; 
    cursor: pointer; 
}
#chat-form > button:hover {
    background: #0056b3;
}

/* Bố cục tin nhắn trong #messages */
#messages { 
    /* ĐÃ SỬA: Xóa flex-grow để kiểm soát chiều cao chặt chẽ hơn */
    /* flex-grow: 1; */ 
    padding: 15px; 
    overflow-y: auto; 
    list-style-type: none; 
    margin: 0; 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
    /* ĐÃ BỔ SUNG: Đặt chiều cao cố định để đảm bảo ô nhập liệu không bị che */
    /* Chiều cao tổng của chat-panel (400px) - header (50px) - typing-indicator (20px) - chat-form (56px) */
    height: 274px; 
}

#messages > li { 
    padding: 8px 12px; 
    word-wrap: break-word; 
    border-radius: 10px; 
    max-width: 80%; 
    line-height: 1.4;
}

/* Tin nhắn của người khác (mặc định) */
#messages > li {
    background-color: #e2e8f0; 
    align-self: flex-start; 
    text-align: left;
}

/* Tin nhắn của mình */
#messages > li.my-message { 
    background-color: #007bff; 
    color: white; 
    align-self: flex-end; 
    text-align: left; 
}

#chat-container.minimized {
    height: 50px;
}
#chat-container.minimized #online-users-panel,
#chat-container.minimized #messages,
#chat-container.minimized #chat-form,
#chat-container.minimized #typing-indicator {
    display: none;
}
#typing-indicator {
    padding: 0 10px 5px;
    height: 20px;
    font-style: italic;
    color: #888;
    font-size: 13px;
}

/* Styles cho badge tin nhắn chưa đọc */
.unread-badge {
    background-color: #e74c3c; 
    color: white;
    font-size: 10px; 
    font-weight: bold;
    padding: 2px 6px; 
    border-radius: 10px; 
    min-width: 10px;
    text-align: center;
    line-height: normal;
    margin-left: auto; 
    display: none; 
}

/* Styles cho tin nhắn đã bị thu hồi */
li.recalled-message {
    font-style: italic;
    color: #888;
    background-color: #f0f0f0;
    border-left: 3px solid #ccc;
    padding-left: 10px;
}

/* Styles cho menu ngữ cảnh (chuột phải) */
.context-menu {
    display: none;
    position: absolute; 
    background-color: #fff;
    border: 1px solid #ddd;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-radius: 5px;
    z-index: 99999; 
    padding: 0; 
    margin: 0; 
}

.context-menu ul {
    list-style: none;
    padding: 5px 0;
    margin: 0;
}

.context-menu ul li {
    padding: 8px 15px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    white-space: nowrap; 
}

.context-menu ul li:hover {
    background-color: #f0f0f0;
}

/* Responsive cho chat container */
@media (max-width: 768px) {
    #chat-toggle-button, #chat-container {
        display: none !important; /* Ẩn chat trên mobile cho trang này */
    }
}