/* =========================================
   1. SETUP & VARIABLES
   ========================================= */
:root {
    /* Color Palette */
    --primary-color: #24db24;       /* Xanh thương hiệu */
    --primary-hover: #1eb81e;       /* Xanh đậm hơn khi hover */
    --secondary-color: #1f2937;     /* Màu tối cho Header/Hero */
    
    /* Text Colors */
    --text-main: #1f2937;           /* Chữ chính (Đen xám) */
    --text-muted: #6b7280;          /* Chữ phụ (Xám nhạt) */
    --text-light: #ffffff;          /* Chữ trắng */
    
    /* Backgrounds */
    --bg-body: #F5F7FA;             /* Nền website (Xám xanh rất nhạt) */
    --bg-card: #ffffff;             /* Nền thẻ trắng */
    --bg-input: #f3f4f6;            /* Nền ô input */
    
    /* Leaderboard Colors */
    --rank-gold: #fbbf24;
    --rank-silver: #9ca3af;
    --rank-bronze: #d97706;
    
    /* Effects */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    /* Typography */
    --font-main: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* Reset cơ bản */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: var(--font-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; transition: 0.2s; }
ul { list-style: none; }
button { font-family: inherit; }

/* =========================================
   2. HEADER / NAVBAR
   ========================================= */
.site-header {
    background-color: var(--bg-card);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 12px 0;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-main);
}

.logo-icon {
    background-color: var(--primary-color);
    color: #fff;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: 900;
}

.logo small {
    color: var(--primary-color);
    font-size: 0.8em;
}

/* Nav Links */
.nav-links {
    display: flex;
    gap: 30px;
}

.nav-links a {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.95rem;
    padding: 5px 0;
    position: relative;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--primary-color);
}

/* Auth Buttons */
.auth-buttons {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn-login {
    font-weight: 600;
    color: var(--text-main);
}

.btn-login:hover { color: var(--primary-color); }

.btn-register {
    background-color: var(--primary-color);
    color: #fff;
    padding: 10px 24px;
    border-radius: 50px;
    font-weight: 600;
    box-shadow: 0 4px 6px rgba(36, 219, 36, 0.25);
}

.btn-register:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

/* =========================================
   3. HERO BANNER
   ========================================= */
.hero-banner {
    /* Gradient tối màu xanh đen để tạo chiều sâu */
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: var(--text-light);
    text-align: center;
    padding: 80px 20px;
    margin-bottom: 40px;
    /* Bo góc dưới */
    border-bottom-left-radius: 30px;
    border-bottom-right-radius: 30px;
}

.hero-title {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 16px;
    line-height: 1.2;
}

.hero-title .highlight {
    color: var(--primary-color);
}

.hero-subtitle {
    font-size: 1.1rem;
    color: #94a3b8; /* Xám xanh nhạt */
    max-width: 700px;
    margin: 0 auto 40px auto;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 50px;
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid rgba(255,255,255,0.1);
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.1rem;
}

.stat-item i { color: var(--primary-color); }

/* =========================================
   4. MAIN LAYOUT (GRID SYSTEM)
   ========================================= */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 60px;
    display: grid;
    /* Chia cột: Nội dung chính 2 phần, Sidebar 1 phần */
    grid-template-columns: 2fr 1fr; 
    gap: 40px;
}

/* --- LEFT COLUMN: EXAM LIST --- */

/* Tools (Header & Search) */
.section-tools {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 15px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.green-bar {
    width: 6px;
    height: 28px;
    background-color: var(--primary-color);
    border-radius: 4px;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.tag-year {
    background-color: #d1fae5;
    color: #065f46;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
}

/* Search Box */
.search-box {
    background: var(--bg-card);
    border: 1px solid #e5e7eb;
    padding: 10px 16px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 300px;
    transition: all 0.3s;
}

.search-box:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(36, 219, 36, 0.1);
}

.search-box input {
    border: none;
    outline: none;
    background: transparent;
    width: 100%;
    font-size: 0.95rem;
}

.search-box i { color: var(--text-muted); }

/* Exam Grid Cards */
.exam-grid {
    display: grid;
    /* Tự động chia cột, tối thiểu 300px */
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.exam-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
    position: relative;
    border: 1px solid transparent;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.exam-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
    border-color: #e2e8f0;
}

.tag-new {
    position: absolute;
    top: 20px;
    right: 20px;
    background-color: #ecfccb; /* Xanh lá mạ nhạt */
    color: #4d7c0f;
    font-size: 0.75rem;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 6px;
    text-transform: uppercase;
}

.card-category {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-main);
    line-height: 1.4;
    flex-grow: 1; /* Để đẩy nút xuống đáy nếu text ngắn */
}

.card-meta {
    display: flex;
    gap: 16px;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px dashed #e5e7eb;
}

.card-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-start {
    background-color: var(--primary-color);
    color: #fff;
    border: none;
    width: 100%;
    padding: 14px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.btn-start:hover {
    background-color: var(--primary-hover);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 40px;
}

.page-item {
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
    transition: 0.2s;
}

.page-item.active, .page-item:hover {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* --- RIGHT COLUMN: LEADERBOARD --- */
.content-right {
    /* Đảm bảo sidebar không bị dãn quá mức */
    min-width: 0;
}

/* Leaderboard Card - Style giống Dashboard */
.leaderboard-card {
    background-color: #fffbf0; /* Nền vàng kem nhạt */
    border: 1px solid #fde68a;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.leaderboard-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.leaderboard-header i {
    font-size: 1.5rem;
}

.text-gold { color: #d97706; }

.leaderboard-header h3 {
    font-size: 1.1rem;
    text-transform: uppercase;
    color: #92400e; /* Màu nâu vàng đậm */
    margin: 0;
    font-weight: 800;
}

.leader-item {
    display: flex;
    align-items: center;
    background: #fff;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    transition: transform 0.2s;
}

.leader-item:hover {
    transform: translateX(5px);
}

/* Rank Badges */
.rank-badge {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    margin-right: 12px;
    flex-shrink: 0;
}

.rank-1 { background-color: var(--rank-gold); color: #fff; box-shadow: 0 2px 5px rgba(251, 191, 36, 0.4); }
.rank-2 { background-color: var(--rank-silver); color: #fff; }
.rank-3 { background-color: var(--rank-bronze); color: #fff; }
.rank-other { background-color: #f3f4f6; color: var(--text-muted); }

/* User Info in Leaderboard */
.user-avatar {
    width: 36px;
    height: 36px;
    background-color: #e5e7eb;
    color: var(--text-muted);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-right: 12px;
    font-size: 0.9rem;
}

.top-1 .user-avatar {
    background-color: #fffbeb;
    color: var(--rank-gold);
    border: 1px solid #fcd34d;
}

.user-info {
    flex-grow: 1;
    overflow: hidden;
}

.user-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-score {
    font-size: 0.8rem;
    color: var(--primary-color);
    font-weight: 700;
    margin-top: 2px;
}

.leader-footer {
    text-align: center;
    margin-top: 20px;
}

.leader-footer a {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.leader-footer a:hover {
    text-decoration: underline;
}

/* Promo Card */
.promo-card {
    background: linear-gradient(135deg, #24db24 0%, #16a34a 100%);
    color: white;
    padding: 24px;
    border-radius: var(--radius-lg);
    margin-top: 30px;
    text-align: center;
    box-shadow: 0 10px 15px -3px rgba(36, 219, 36, 0.3);
}

.promo-card h4 {
    margin: 0 0 10px 0;
    font-size: 1.2rem;
}

.promo-card p {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* =========================================
   5. FOOTER
   ========================================= */
.site-footer {
    background-color: #fff;
    border-top: 1px solid #e5e7eb;
    padding: 30px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: auto;
}

/* =========================================
   6. RESPONSIVE DESIGN (MOBILE)
   ========================================= */
@media (max-width: 992px) {
    .main-container {
        grid-template-columns: 1fr; /* Chuyển thành 1 cột */
    }
    
    .content-right {
        order: -1; /* Đưa bảng xếp hạng lên trên (nếu muốn) hoặc để dưới */
    }
}

@media (max-width: 768px) {
    .hero-title { font-size: 2rem; }
    .hero-stats { flex-direction: column; gap: 15px; }
    .search-box { width: 100%; }
    .nav-links { display: none; /* Nên làm hamburger menu cho mobile sau này */ }
    
    .header-content {
        padding: 0 15px;
    }
}

/* =========================================
   HERO BANNER PRO (NÂNG CẤP)
   ========================================= */
.hero-banner {
    background-color: #0f172a; /* Màu nền tối Slate-900 */
    color: white;
    padding: 80px 20px 100px; /* Padding dưới rộng hơn để chứa stats */
    position: relative;
    overflow: hidden;
    text-align: center;
    border-bottom-left-radius: 40px;
    border-bottom-right-radius: 40px;
    /* Tạo hiệu ứng lưới mờ ở nền */
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 40px 40px; /* Kích thước ô lưới */
}

/* Đốm sáng xanh nền (Glow Effect) */
.hero-glow {
    position: absolute;
    top: -50%;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(36, 219, 36, 0.15) 0%, rgba(0, 0, 0, 0) 70%);
    z-index: 1;
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 800px;
    margin: 0 auto;
}

/* Badge nhỏ trên cùng */
.hero-badge {
    display: inline-block;
    background: rgba(36, 219, 36, 0.1);
    color: var(--primary-color);
    border: 1px solid rgba(36, 219, 36, 0.3);
    padding: 6px 16px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 24px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    animation: fadeInDown 0.8s ease-out;
}

/* Tiêu đề chính */
.hero-title {
    font-size: 3.5rem; /* To hơn bản cũ */
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 20px;
    letter-spacing: -1px;
    text-shadow: 0 4px 20px rgba(0,0,0,0.5); /* Bóng chữ để nổi trên nền */
}

/* Hiệu ứng chữ Tin Học (Gradient Text) */
.text-highlight {
    background: linear-gradient(to right, #24db24, #a3e635);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    position: relative;
    display: inline-block;
}

/* Thêm gạch chân phát sáng dưới chữ Tin Học */
.text-highlight::after {
    content: '';
    position: absolute;
    bottom: 5px;
    left: 0;
    width: 100%;
    height: 6px;
    background: rgba(36, 219, 36, 0.4);
    border-radius: 4px;
    z-index: -1;
    filter: blur(4px);
}

.hero-subtitle {
    font-size: 1.15rem;
    color: #cbd5e1; /* Màu xám sáng hơn chút */
    margin-bottom: 40px;
    line-height: 1.6;
    max-width: 650px;
    margin-left: auto;
    margin-right: auto;
}

/* Các nút bấm (Actions) */
.hero-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 60px;
}

.btn-primary-glow {
    background-color: var(--primary-color);
    color: #064e3b; /* Chữ xanh đậm trên nền xanh sáng */
    border: none;
    padding: 14px 32px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(36, 219, 36, 0.4); /* Bóng phát sáng */
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary-glow:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(36, 219, 36, 0.6);
    background-color: #4ade80;
}

.btn-secondary-outline {
    background: transparent;
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 14px 32px;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary-outline:hover {
    border-color: white;
    background: rgba(255,255,255,0.1);
}

/* --- KHU VỰC THỐNG KÊ (GLASSMORPHISM) --- */
.hero-stats-glass {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05); /* Nền cực mờ */
    backdrop-filter: blur(12px); /* Hiệu ứng làm mờ nền sau lưng */
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 20px 40px;
    gap: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    animation: floatUp 3s ease-in-out infinite; /* Animation trôi nhẹ */
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 15px;
    text-align: left;
}

.stat-icon {
    width: 48px;
    height: 48px;
    background: rgba(36, 219, 36, 0.15);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 1.4rem;
}

.stat-info strong {
    display: block;
    font-size: 1.4rem;
    font-weight: 800;
    color: white;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-info span {
    font-size: 0.85rem;
    color: #94a3b8;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.stat-divider {
    width: 1px;
    height: 40px;
    background: rgba(255,255,255,0.1);
}

/* Animations */
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes floatUp {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Responsive cho Mobile */
@media (max-width: 768px) {
    .hero-title { font-size: 2.5rem; }
    .hero-stats-glass {
        flex-direction: column;
        gap: 20px;
        width: 100%;
        padding: 20px;
    }
    .stat-divider { display: none; }
    .hero-actions { flex-direction: column; }
    .hero-banner { padding-bottom: 60px; }
}

/* =========================================
   BINARY MOUSE EFFECT (Hiệu ứng 0 1)
   ========================================= */

/* Class cho hạt số 0 và 1 */
.binary-particle {
    position: absolute;
    color: var(--primary-color); /* Màu xanh #24db24 */
    font-family: 'Courier New', Courier, monospace; /* Font kiểu code */
    font-weight: bold;
    pointer-events: none; /* Không chặn click chuột vào nút bên dưới */
    z-index: 1; /* Nằm trên nền nhưng dưới nội dung chính */
    opacity: 0;
    user-select: none;
    text-shadow: 0 0 5px var(--primary-color); /* Phát sáng nhẹ */
    animation: binaryFloat 1s ease-out forwards; /* Chạy animation 1s rồi biến mất */
}

/* Animation bay lên và mờ dần */
@keyframes binaryFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) scale(1.5); /* Bay lên 50px và to ra chút */
    }
}
/* --- CSS DANH SÁCH ĐỀ THI --- */

/* Bố cục lưới: 3 cột trên máy tính, 1 cột trên điện thoại */
.exam-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

/* Thẻ bài thi */
.exam-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    border: 1px solid #f1f5f9;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Hiệu ứng khi di chuột vào thẻ */
.exam-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px -5px rgba(36, 219, 36, 0.15); /* Bóng màu xanh lá nhạt */
    border-color: #24db24;
}

/* Nhãn "MỚI" */
.tag-new {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #ef4444; /* Màu đỏ */
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 12px;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

/* Loại đề thi (THPTQG, Ôn tập...) */
.card-category {
    font-size: 0.8rem;
    color: #24db24;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 10px;
    background: #f0fdf4;
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    width: fit-content;
}

/* Tên đề thi */
.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 15px 0;
    line-height: 1.4;
    flex-grow: 1; /* Đẩy nút xuống đáy */
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Cắt dòng nếu tên quá dài */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Thông tin phụ (Thời gian, số câu) */
.card-meta {
    display: flex;
    gap: 15px;
    color: #64748b;
    font-size: 0.9rem;
    margin-bottom: 20px;
    border-top: 1px solid #f1f5f9;
    padding-top: 15px;
}
.card-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Nút làm bài */
.btn-start {
    width: 100%;
    padding: 12px;
    background: white;
    color: #24db24;
    border: 2px solid #24db24;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn-start:hover {
    background: #24db24;
    color: white;
}
/* Đảm bảo nội dung chính đè lên số 0 1 */
.hero-content {
    position: relative;
    z-index: 10; /* Z-index cao hơn particle */
}