/* --- CÀI ĐẶT CHUNG --- */
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    background-color: #f0f2f5;
    font-size: 14px;
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

.main-content-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* --- SIDEBAR --- */
.sidebar {
    width: 240px; /* Tăng nhẹ độ rộng */
    flex-shrink: 0;
    background-color: #262626;
    color: #fff;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    justify-content: center; /* Căn giữa logo */
    border-bottom: 1px solid #424242;
}

.sidebar-logo {
    max-width: 80%; /* Thu nhỏ logo cho hợp lý */
    height: auto;
}

.sidebar-nav {
    padding-top: 15px;
}

/* Mục nav chung */
.nav-item,
.nav-item-toggle {
    display: flex; /* Dùng flex để căn icon và chữ */
    align-items: center;
    gap: 12px; /* Khoảng cách giữa icon và chữ */
    padding: 14px 20px;
    color: #a6a6a6;
    text-decoration: none;
    font-size: 15px;
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box; /* Quan trọng cho button */
}

/* Icon trên sidebar */
.nav-item i,
.nav-item-toggle i {
    width: 20px; /* Cố định độ rộng icon */
    text-align: center;
    font-size: 16px;
}

.nav-item:hover,
.nav-item-toggle:hover {
    background-color: #3a3a3a;
    color: #fff;
}

/* Trạng thái Active cho mục cha */
.nav-item.active,
.nav-item-toggle.active {
    background-color: #1677ff;
    color: #fff;
    font-weight: 600;
}

/* --- SIDEBAR DROPDOWN (MỚI) --- */
.nav-item-dropdown {
    width: 100%;
}

.nav-item-toggle {
    background-color: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    justify-content: space-between; /* Đẩy mũi tên ra xa */
}

.nav-item-toggle .arrow {
    font-size: 12px;
    transition: transform 0.2s;
}

.nav-submenu {
    padding-left: 20px; /* Thụt vào so với menu cha */
    background-color: #1f1f1f; /* Nền tối hơn */
    overflow: hidden; /* Ẩn khi display:none */
}

.nav-sub-item {
    display: block;
    padding: 12px 20px 12px 22px; /* Thụt vào thêm */
    color: #a6a6a6;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s ease;
}

.nav-sub-item:hover {
    color: #fff;
}

.nav-sub-item.active {
    font-weight: bold;
    color: #fff;
    background-color: #1677ff; /* Trùng màu active của cha */
}

/* --- HEADER --- */
.header {
    background: #fff;
    padding: 0 24px;
    border-bottom: 1px solid #f0f0f0;
    height: 64px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.header h1 {
    margin: 0;
    font-size: 20px;
}

.user-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 15px;
}

/* --- NỘI DUNG CHÍNH --- */
.content {
    margin: 24px;
    padding: 24px;
    background: #fff;
    border-radius: 8px;
    flex-grow: 1; /* Tự co giãn theo chiều cao */
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.content h2 {
    margin-top: 0;
}

.toolbar {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
}

/* --- BUTTON --- */
button, .button {
    padding: 8px 15px;
    border-radius: 6px;
    border: 1px solid #d9d9d9;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-flex; /* Căn icon (nếu có) */
    align-items: center;
    gap: 6px;
}

button.primary, .button.primary {
    background: #1677ff;
    color: #fff;
    border-color: #1677ff;
}
button.primary:hover, .button.primary:hover {
    background: #4096ff;
    border-color: #4096ff;
}

button.danger, .button.danger {
    background: #ff4d4f;
    color: #fff;
    border-color: #ff4d4f;
}
button.danger:hover, .button.danger:hover {
    background: #ff7875;
    border-color: #ff7875;
}

/* --- BẢNG BIỂU --- */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid #f0f0f0; /* Thêm viền cho div bọc ngoài */
    border-radius: 8px; /* Bo góc cho đẹp */
    margin-top: 20px;
    
    /* [SỬA LỖI 1] THÊM 2 DÒNG NÀY ĐỂ DIV CO LẠI */
    width: fit-content;
    max-width: 100%;
}

table {
    width: auto; /* Dòng này đã đúng (lần trước bạn sửa) */
    border-collapse: collapse; 
    table-layout: auto;
}

th, td {
    padding: 14px 18px; /* Tăng padding (lề trong) */
    border-bottom: 1px solid #f0f0f0;
    text-align: left;
    vertical-align: top; /* Căn nội dung lên trên */
    line-height: 1.5; /* Giãn dòng cho dễ đọc */
    
    /* [SỬS LỖI 3] XÓA DÒNG "white-space: nowrap;" */
}

/* Hàng cuối cùng không có viền đáy */
tbody tr:last-child td {
    border-bottom: none;
}

/* Tiêu đề bảng */
th {
    background-color: #fafafa;
    font-weight: 600;
    color: #333;
}

/* Hiệu ứng hover cho hàng */
tbody tr:hover {
    background-color: #f9f9f9;
}

/* --- ĐỊNH DẠNG CỘT (QUAN TRỌNG) --- */
/* (Chúng ta sẽ thêm các class này vào HTML ở Bước 2) */

/* Cột cho phép xuống dòng (Tên, Ghi chú, Thành viên) */
.col-wrap {
    white-space: normal; /* Cho phép xuống dòng */
    width: 220px; /* [SỬA] Đặt chiều rộng cố định */
}

/* Cột cho các Mã (MSSV, Mã MH, Tiến độ, Quyết định) */
.col-code {
    width: 120px; /* [SỬA] Tăng nhẹ chiều rộng */
}

/* Cột cho SĐT, Email */
.col-contact {
    width: 160px; /* Rộng vừa đủ */
}

/* Cột cho Hành động (Sửa/Xóa) */
.col-action {
    width: 200px; /* Rộng vừa đủ cho 2 nút */
    text-align: center; /* Căn giữa tiêu đề */
}

/* Căn giữa 2 nút Sửa/Xóa */
td.col-action div {
    justify-content: center;
}
/* --- MODAL (POPUP) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #fff;
    padding: 24px;
    border-radius: 8px;
    width: 500px; /* Tăng độ rộng */
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.modal-content h2 {
    margin-top: 0;
}

/* --- FORM --- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

/* Hiệu ứng khi focus vào input */
.form-group input:focus,
.form-group select:focus {
    border-color: #1677ff;
    box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.2);
    outline: none;
}

.modal-actions {
    text-align: right;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* --- TRANG ĐĂNG NHẬP --- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
}

.login-container {
    width: 360px;
    padding: 30px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.login-container h2 {
    text-align: center;
    margin-top: 0;
}

.error-message {
    background-color: #fff1f0;
    border: 1px solid #ffccc7;
    color: #cf1322;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 15px;
    text-align: center;
}

.hidden {
    display: none !important;
}

blockquote {
    background-color: #fafafa;
    border-left: 4px solid #1677ff;
    padding: 10px 15px;
    margin-left: 0;
    border-radius: 0 4px 4px 0;
}