/* ==========================================================
   1. CẤU HÌNH CHUNG & BỐ CỤC KHUNG CHÍNH (CONTAINER)
   ========================================================== */
body {
    font-family: "Times New Roman", Times, serif; /* ĐỔI FONT: Sang phong cách học thuật, trang trọng */
    background: #f5f5f5;
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden; /* Ngăn chặn toàn bộ trang sinh ra thanh cuộn ngang */
}

.container {
    max-width: 850px; /* Tự động co giãn linh hoạt trên mọi kích thước màn hình */
    width: 100%;
    margin: 40px auto 0 auto;
    box-sizing: border-box;
}

/* --- TIÊU ĐỀ NỔI BẬT --- */
h1 {
    text-align: center;
    font-size: 32px;
    font-weight: 800;
    color: #1e3c72; /* Xanh công nghệ */
    letter-spacing: 1.5px;
    margin-bottom: 35px;
    position: relative;
    padding-bottom: 15px;
}

/* Đường gạch dưới trang trí tiêu đề */
h1::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(90deg, #1e3c72, #2a5298);
    border-radius: 2px;
}

h3 {
    text-align: center;
    color: #444;
    margin-top: 0;
    font-size: 18px;
}

/* ==========================================================
   2. KHU VỰC NẠP FILE (UPLOAD GRID & CARDS)
   ========================================================== */
.upload-grid {
    display: flex;
    gap: 20px; /* Khoảng cách giữa 2 card */
    margin-bottom: 20px;
}

.card {
    flex: 1; /* Hai card có độ rộng bằng nhau */
    background: white;
    padding: 25px 20px;
    border-radius: 12px; /* Bo góc mịn */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    
    /* Canh giữa tất cả mọi thứ bên trong card */
    display: flex;
    flex-direction: column;
    align-items: center; 
    text-align: center;
    box-sizing: border-box; /* Ngăn padding làm phình card */
}

/* Định dạng input file */
input[type="file"] {
    max-width: 100%;
    font-size: 14px;
    margin-top: 10px;
    font-family: inherit; /* Kế thừa font Times New Roman */
}

/* --- HIỆU ỨNG LINK TẢI MẪU / TÀI LIỆU --- */
a { 
    display: inline-block;
    margin: 5px auto 15px auto;
    text-decoration: none; 
    color: #0066cc;
    font-weight: bold;
    font-size: 14px;
    position: relative;
    padding-bottom: 2px;
    transition: color 0.3s ease;
}

a:hover {
    color: #0025cc;
}

a::after {
    content: '';
    position: absolute;
    width: 100%;
    transform: scaleX(0);
    height: 2px;
    bottom: 0;
    left: 0;
    background-color: #0025cc;
    transform-origin: bottom center;
    transition: transform 0.25s ease-out;
}

a:hover::after {
    transform: scaleX(1);
}

/* ==========================================================
   3. HỆ THỐNG NÚT BẤM (BUTTONS)
   ========================================================== */
/* Nút chính: Đọc dữ liệu và chấm bài (Độ rộng cố định) */
#btnProcess {
    display: block;
    margin: 35px auto;
    width: 260px; /* SỬA: Đặt độ rộng cố định tinh tế trên Desktop */
    padding: 14px 0; /* Padding dọc, ngang bằng 0 vì width đã cố định */
    font-size: 18px;
    font-weight: bold;
    font-family: inherit;
    color: #fff;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    border: none;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(42, 82, 152, 0.3);
    transition: all 0.3s ease;
    text-align: center;
}

#btnProcess:hover {
    background: linear-gradient(135deg, #2a5298 0%, #1e3c72 100%);
    box-shadow: 0 6px 20px rgba(42, 82, 152, 0.4);
    transform: translateY(-2px);
}

#btnProcess:active {
    transform: translateY(1px);
    box-shadow: 0 2px 10px rgba(42, 82, 152, 0.3);
}

/* Định dạng chung cho tất cả các nút bấm phụ/xuất file */
button {
    padding: 12px 25px;
    font-size: 16px;
    font-family: inherit;
    border-radius: 6px;
    border: 1px solid #1e3c72;
    background: #fff;
    color: #1e3c72;
    cursor: pointer;
    transition: all 0.2s;
}

button:not(:disabled):hover {
    background: #1e3c72;
    color: #fff;
}

button:disabled {
    background: #e0e0e0;
    color: #999;
    cursor: not-allowed;
    box-shadow: none;
    border: 1px solid #ccc;
}

/* Khối bao quanh các nút xuất file - Dùng Flexbox cố định hàng ngang */
.export-actions {
    display: flex;
    justify-content: center;
    gap: 15px; /* Khoảng cách cố định giữa 2 nút */
    margin-top: 20px;
}

/* Định dạng riêng cho 2 nút xuất file với độ rộng cố định */
.export-actions button {
    width: 180px; /* Chiều rộng cố định hoàn hảo trên Desktop */
    padding: 12px 0; /* Đặt padding ngang bằng 0 vì width đã cố định */
    margin: 0; 
    box-sizing: border-box;
    text-align: center;
}

/* ==========================================================
   4. HIỂN THỊ KẾT QUẢ, BẢNG DỮ LIỆU & SPINNING
   ========================================================== */
hr {
    border: 0;
    height: 1px;
    background: #ddd;
    margin: 30px 0;
}

/* Khung bọc bảng hỗ trợ cuộn ngang mượt mà */
.table-wrapper {
    overflow-x: auto; 
    margin-top: 20px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

table {
    border-collapse: collapse;
    width: 100%;
    background: #fff;
}

th, td {
    border: 1px solid #eee;
    padding: 12px 10px;
    text-align: center;
}

th {
    background-color: #1e3c72;
    color: #ffffff;
    font-weight: 600;
    font-size: 15px;
}

td {
    color: #444;
    font-size: 14px;
    border-bottom: 1px solid #eee;
}

/* Hiệu ứng nổi bật dòng khi di chuột qua */
tbody tr:hover {
    background-color: #f1f5f9;
    transition: background-color 0.2s ease;
}

/* Định dạng màu sắc cho trạng thái Đạt / Không đạt của CLO */
.status-pass {
    color: #2e7d32;
    background: #e8f5e9;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 12px;
}
.status-fail {
    color: #c62828;
    background: #ffebee;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 12px;
}

/* Khối giả lập Loading khi đang chấm bài */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 20px 0;
    color: #1e3c72;
    font-weight: bold;
}
.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: #1e3c72;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Khối tóm tắt thống kê nhanh (Summary Cards) */
.summary-container {
    display: flex;
    gap: 15px;
    margin: 25px 0;
}
.summary-item {
    flex: 1;
    background: #f8f9fa;
    border-left: 4px solid #1e3c72;
    padding: 15px;
    border-radius: 6px;
    text-align: left;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}
.summary-item h4 {
    margin: 0 0 5px 0;
    color: #666;
    font-size: 13px;
    text-transform: uppercase;
}
.summary-item .value {
    font-size: 22px;
    font-weight: bold;
    color: #333;
}

/* ==========================================================
   5. CHÂN TRANG (FOOTER) - ĐÃ CĂN CHỈNH KHOẢNG CÁCH
   ========================================================== */
.footer {
    margin-top: 60px;
    padding: 20px 0;
    text-align: center;
    font-size: 13px;
    color: #888;
    border-top: 1px solid #eaeaea;
    line-height: 1.4;
}

.footer div {
    margin: 0;
    padding: 0;
}

.footer a {
    display: inline-block;
    margin: 0 0 5px 0;
    padding: 0;
    font-weight: 600;
    color: #0066cc;
    text-decoration: none;
    position: relative;
}

.footer a:hover {
    text-decoration: none;
    color: #0025cc;
}

.footer a::after {
    content: '';
    position: absolute;
    width: 100%;
    transform: scaleX(0);
    height: 2px;
    bottom: -2px;
    left: 0;
    background-color: #0025cc;
    transform-origin: bottom center;
    transition: transform 0.2s ease-out;
}

.footer a:hover::after {
    transform: scaleX(1);
}

.footer-info, .footer-copyright {
    margin-bottom: 2px;
}

/* ==========================================================
   6. HỆ THỐNG ĐÁP ỨNG DI ĐỘNG (MEDIA QUERIES) & THU NHỎ TAB
   ========================================================== */
@media (max-width: 768px) {
    /* Thêm lề trái/phải thống nhất và ngăn chặn container tràn viền */
    .container,
    .footer {
        padding-left: 20px !important;
        padding-right: 20px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }

    /* Đẩy 2 khối nạp file thành hàng dọc */
    .upload-grid {
        flex-direction: column;
        gap: 15px;
        width: 100%;
    }

    /* Đảm bảo các card con co giãn 100% theo lề của container */
    .card {
        width: 100% !important;
        box-sizing: border-box;
    }

    /* Nút xử lý chính: Co giãn linh hoạt hơn trên mobile nhưng giới hạn max-width để không bị phình to */
    #btnProcess {
        width: 100% !important;
        max-width: 280px; /* Khống chế không cho nút quá dài trên màn hình di động lớn */
        box-sizing: border-box;
        margin: 8px auto !important;
    }

    /* 2 Nút xuất dữ liệu: Ép giữ nguyên hàng ngang và giữ độ rộng cố định tinh tế */
    .export-actions {
        flex-direction: row !important; /* Không cho rớt dòng */
        justify-content: center;
        gap: 10px; /* Thu hẹp nhẹ khoảng cách trên màn hình nhỏ */
    }

    .export-actions button {
        width: 145px !important; /* Co nhẹ để vừa khít cả các dòng điện thoại màn hình hẹp */
        font-size: 14px; /* Thu nhỏ chữ 1px để không bị rớt dòng chữ trong nút */
        margin: 0 !important;
    }

    /* Khung kết quả co giãn thông minh không tràn viền */
    #result {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        box-sizing: border-box;
    }
}
