/* --- RESET & CHUNG --- */
* {
    box-sizing: border-box; /* Đảm bảo padding không làm tràn khung */
}

body {
    background-color: #f4f6f8;
    font-family: 'Inter', sans-serif;
    margin: 0;
    overflow-x: hidden; /* Chống tràn ngang trên mobile */
}

/* Navbar Style */
.navbar {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    padding: 10px 20px; 
    background: white; 
    border-bottom: 1px solid #eee;
}

.logo { font-weight: bold; font-size: 18px; color: #ffafff; }

.menu { display: none; } /* Ẩn menu chữ trên mobile cho gọn, hiện lại ở desktop */

/* Dropdown Header */
.user-dropdown-container { position: relative; cursor: pointer; }
#user-name-header { 
    color: #8b5cf6; 
    font-weight: bold; 
    padding: 5px 12px; 
    background: #f3f0ff; 
    border-radius: 20px; 
    font-size: 12px;
    white-space: nowrap; 
}

/* Layout chính - Sử dụng Flex-wrap để tự xuống dòng */
.history-container {
    max-width: 1100px; 
    margin: 20px auto;
    display: flex; 
    flex-wrap: wrap; /* Tự động xuống hàng khi không đủ chỗ */
    gap: 20px; 
    padding: 0 15px;
}

/* Sidebar - Tự thích nghi chiều rộng */
.sidebar {
    width: 260px; 
    background: white; 
    padding: 20px;
    border-radius: 8px; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    height: fit-content;
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%; /* Trên mobile, sidebar chiếm 100% chiều ngang */
    }
    .navbar { padding: 10px; }
    .menu { display: none; } 
}

.menu-title { 
    font-size: 0.85rem; 
    color: #333; 
    border-left: 3px solid #26c2bc; 
    padding-left: 10px; 
    margin: 10px 0; 
    font-weight: 600;
}

.menu-list { list-style: none; padding: 0; margin: 0; }
.menu-list li { padding: 12px 0; border-bottom: 1px solid #f8f8f8; }
.menu-list li a { text-decoration: none; color: #666; font-size: 0.9rem; display: flex; align-items: center; gap: 8px; }
.menu-list li.active a { color: #26c2bc; font-weight: 600; }

/* Main Content - Phần chứa danh sách lịch sử */
.history-content { 
    flex: 1; 
    min-width: 300px; /* Không cho phép nhỏ hơn 300px để tránh vỡ card */
}

.section-title { 
    font-size: 1.2rem; 
    color: #333; 
    border-bottom: 3px solid #ed145b; 
    padding-bottom: 5px; 
    display: inline-block; 
    margin-bottom: 20px; 
}

/* Accordion Card - Tối ưu cho Mobile */
.history-card {
    background: white; 
    border: 1px solid #eee;
    border-radius: 12px; 
    margin-bottom: 15px;
    overflow: hidden; 
    transition: 0.3s;
    width: 100%; /* Luôn rộng bằng khung chứa */
}

.card-header {
    padding: 15px; 
    cursor: pointer;
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    flex-wrap: wrap; /* Cho phép tag và thời gian xuống dòng nếu cần */
    gap: 10px;
}

.category-tag { 
    background: #f3f0ff; 
    color: #8b5cf6; 
    padding: 4px 10px; 
    border-radius: 12px; 
    font-size: 11px; 
    font-weight: bold; 
}

.time-text { font-size: 0.75rem; color: #888; }

/* Trạng thái mở */
.history-card.active { border-color: #26c2bc; box-shadow: 0 4px 15px rgba(0,0,0,0.08); }

.card-body {
    display: none; 
    padding: 15px;
    background: #fafafa; 
    border-top: 1px solid #f0f0f0;
}

.history-card.active .card-body { display: block; }

.info-line { 
    margin-bottom: 12px; 
    font-size: 0.9rem; 
    color: #444; 
    word-break: break-word; /* Tự xuống dòng nếu nội dung quá dài */
}

.info-line strong { color: #333; font-weight: 600; }

/* Box chứa câu trả lời của AI */
.ai-box {
    margin-top: 15px; 
    padding: 15px;
    background: white; 
    border-radius: 10px;
    border-left: 5px solid #ed145b;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.ai-label { 
    font-weight: bold; 
    margin-bottom: 10px; 
    color: #ed145b; 
    display: flex; 
    align-items: center; 
    gap: 5px; 
    font-size: 0.95rem;
}

.ai-text { 
    color: #444; 
    line-height: 1.7; 
    font-size: 0.88rem; 
    text-align: justify;
}

/* Hiển thị trên màn hình lớn */
@media (min-width: 769px) {
    .menu { display: block; }
    .history-container { padding: 0 20px; margin: 40px auto; }
}