:root {
    --primary: #4318ff;
    --bg: #f4f7fe;
    --sidebar: #ffffff;
    --text: #1b2559;
    --grey: #a3aed0;
    --shadow: 0px 18px 40px rgba(112, 144, 176, 0.12);
    --pass: #01b574;
    --fail: #ee5d50;
}

* { box-sizing: border-box; font-family: 'Inter', sans-serif; }
body { margin: 0; display: flex; height: 100vh; background: var(--bg); color: var(--text); }

/* Sidebar */
.sidebar { width: 280px; background: var(--sidebar); padding: 40px 20px; display: flex; flex-direction: column; border-right: 1px solid #e0e5f2; }
.logo { font-size: 24px; font-weight: 800; color: var(--primary); margin-bottom: 50px; text-align: center; }

.nav-btn {
    width: 100%; padding: 15px; margin-bottom: 10px; border: none; background: none;
    text-align: left; font-size: 16px; font-weight: 600; color: var(--grey);
    cursor: pointer; border-radius: 12px; transition: 0.3s;
}
.nav-btn.active { background: var(--primary); color: white; box-shadow: 0px 10px 20px rgba(67, 24, 255, 0.2); }
.page-headern p{
    font-size: 14px;
    flex-grow: 1;
    margin: 0;
    color: #2d3748;
    
}
/* Content */
.content { flex: 1; padding: 40px; overflow-y: auto; }
.page { display: none; }
.page.active { display: block; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.card { background: white; border-radius: 20px; padding: 30px; box-shadow: var(--shadow); margin-bottom: 25px; }

/* Components */
.subject-checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 15px; background: #f8f9ff; border-radius: 12px; }
.roll-input { padding: 12px; border-radius: 10px; border: 1px solid #e0e5f2; width: 140px; margin: 5px; }
.btn { padding: 12px 25px; border-radius: 10px; border: none; font-weight: 700; cursor: pointer; transition: 0.2s; }
.primary { background: var(--primary); color: white; }
.secondary { background: #e0e5f2; color: var(--text); }

/* Metrics */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-top: 20px; }
.metric-card { background: white; padding: 20px; border-radius: 15px; box-shadow: var(--shadow); border-top: 4px solid var(--primary); text-align: center; }
.metric-card h3 { font-size: 12px; color: var(--grey); text-transform: uppercase; margin-bottom: 10px; }
.metric-value { font-size: 20px; font-weight: 800; }
.pass-text { color: var(--pass); }
.fail-text { color: var(--fail); }

.upload-section { margin-top: auto; }
.custom-file-upload { display: block; padding: 15px; background: #eef2ff; color: var(--primary); text-align: center; border-radius: 12px; cursor: pointer; font-weight: bold; border: 2px dashed var(--primary); }
#fileInput { display: none; }
canvas { min-height: 350px; }
/* Modal Styling */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0; top: 0; 
    width: 100%; height: 100%; 
    background-color: rgba(0,0,0,0.5); 
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 25px;
    border-radius: 20px;
    width: 400px;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #eee; padding-bottom: 15px; }
.close-btn { font-size: 28px; font-weight: bold; cursor: pointer; color: var(--grey); }

.student-list {
    max-height: 300px;
    overflow-y: auto;
    margin-top: 15px;
}

.student-item {
    padding: 10px;
    border-bottom: 1px solid #f4f7fe;
    display: flex;
    justify-content: space-between;
}

.student-item:last-child { border: none; }

/* Clickable Metric Card */
.metric-card { cursor: pointer; transition: transform 0.2s; }
.metric-card:hover { transform: scale(1.03); }
/* Results Table Styling */
.results-table-container {
    width: 100%;
    overflow-x: auto;
}

#resultsTable {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

#resultsTable th {
    padding: 15px;
    border-bottom: 2px solid #f4f7fe;
    color: var(--grey);
    font-size: 13px;
    text-transform: uppercase;
}

#resultsTable td {
    padding: 15px;
    border-bottom: 1px solid #f4f7fe;
    font-weight: 600;
}

/* Rank Badge */
.rank-badge {
    background: var(--bg);
    padding: 5px 12px;
    border-radius: 8px;
    color: var(--primary);
}

.status-pill {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
}

.status-pass { background: #e6f7f0; color: var(--pass); }
.status-fail { background: #fdeeee; color: var(--fail); }
/* Results Table */
.results-table-container { width: 100%; overflow-x: auto; }
#resultsTable { width: 100%; border-collapse: collapse; margin-top: 10px; }
#resultsTable th { 
    text-align: left; padding: 15px; background: #f8f9ff; 
    color: var(--grey); font-size: 12px; text-transform: uppercase; 
}
#resultsTable td { padding: 30px; border-bottom: 1px solid #f4f7fe; font-weight: 600; }

/* Rank Circle */
.rank-circle {
    display: inline-block; width: 35px; height: 35px; line-height: 35px;
    text-align: center; border-radius: 50%; background: var(--bg);
    color: var(--primary); font-weight: 800;
}

/* Status Labels */
.status-pill { padding: 5px 12px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.status-pass { background: #e6f7f0; color: #01b574; }
.status-fail { background: #fdeeee; color: #ee5d50; }
/* Sidebar Bottom Section */
.upload-section {
    margin-top: auto; /* Pushes to bottom of sidebar */
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.custom-file-upload {
    display: block;
    padding: 12px;
    background: #eef2ff;
    color: var(--primary);
    text-align: center;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    border: 2px dashed var(--primary);
    transition: 0.3s;
}

.custom-file-upload:hover {
    background: var(--primary);
    color: white;
}

.manual-entry-btn {
    width: 100%;
    padding: 12px;
    background: #f0f2f8;
    color: var(--text);
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: 0.3s;
}

.manual-entry-btn:hover {
    background: #e0e5f2;
}
/* Make the Grade (O, A+) stand out inside the percentage cell */
#resultsBody td:nth-child(4) {
    font-family: 'Courier New', monospace;
    color: var(--primary);
    letter-spacing: 0.5px;
}

/* Add a "Topper" glow for Rank 1 */
tr:nth-child(1) {
    background-color: rgba(255, 215, 0, 0.05);
}

/* Ensure the status pill for U/UE looks very clear */
.status-fail {
    background: #fff5f5;
    color: #e53e3e;
    border: 1px solid #feb2b2;
}
:root {
    --primary-blue: #4a3aff;
    --bg-light: #f4f7fe;
    --text-main: #2d3748;
    --success-bg: #e6fffa;
    --success-text: #2c7a7b;
    --danger-bg: #fff5f5;
    --danger-text: #c53030;
}

.view-result-container {
    padding: 30px;
    background-color: var(--bg-light);
}

/* Header & Stats */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    display: flex;
    flex-direction: column;
}

.stat-card .label { color: #718096; font-size: 0.9rem; }
.stat-card .value { font-size: 1.5rem; font-weight: 700; color: var(--text-main); }

/* The Modern Table with Row Gaps */
.modern-table {
    width: 100%;
    border-collapse: separate; /* Required for vertical gaps */
    border-spacing: 0 12px;    /* This creates the 12px gap between rows */
}

.modern-table th {
    padding: 10px 20px;
    text-align: left;
    color: #a0aec0;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
}

.modern-table tbody tr {
    background-color: white;
    transition: transform 0.2s;
}

.modern-table tbody tr:hover {
    transform: scale(1.005);
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

.modern-table td {
    padding: 20px;
    border-top: 1px solid transparent; /* Keeps spacing consistent */
    border-bottom: 1px solid transparent;
}

/* Rounding the corners of individual rows */
.modern-table td:first-child { border-radius: 12px 0 0 12px; }
.modern-table td:last-child { border-radius: 0 12px 12px 0; }

/* Elements inside cells */
.rank-number {
    font-weight: 800;
    color: var(--primary-blue);
}

.grade {
    color: #a0aec0;
    font-size: 0.85rem;
}

.badge {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge.passed { background: var(--success-bg); color: var(--success-text); }
.badge.failed { background: var(--danger-bg); color: var(--danger-text); }

.text-muted { color: #cbd5e0; }
.text-success { color: var(--success-text); }
#results table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

#results th {
    background: #4318ff;
    color: white;
    padding: 10px;
}

#results td {
    padding: 10px;
    border-bottom: 1px solid #ddd;
    text-align: center;
}

.pass {
    color: green;
    font-weight: bold;
}

.fail {
    color: red;
    font-weight: bold;
}

#report {
    padding: 30px;
    font-family: 'Inter', sans-serif;
}

/* Search Bar Styling */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

#searchInput {
    flex: 1;
    max-width: 400px;
    padding: 12px 18px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
}

#searchInput:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-bar button {
    padding: 12px 24px;
    background: #6366f1; /* Your primary purple */
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
}

.search-bar button:hover {
    background: #4f46e5;
}

/* Report Card Box */
.report-box {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    padding: 25px;
    border-top: 6px solid #6366f1;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Header Info */
.student-info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 20px;
    margin-bottom: 20px;
}

.student-info-header h3 { margin: 0; font-size: 22px; color: #1e293b; }
.student-info-header p { margin: 5px 0 0; color: #64748b; font-size: 14px; }

/* Result Table */
.report-table {
    width: 100%;
    border-collapse: collapse;
}

.report-table th {
    text-align: left;
    padding: 12px;
    background: #f8fafc;
    color: #64748b;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.report-table td {
    padding: 15px 12px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    font-size: 14px;
}

/* Grade Badges */
.grade-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 12px;
    display: inline-block;
}

.o { background: #f5f3ff; color: #7c3aed; border: 1px solid #ddd6fe; }      /* Outstanding */
.aplus { background: #eff6ff; color: #2563eb; }                            /* A+ */
.a { background: #ecfeff; color: #0891b2; }                                /* A */
.bplus { background: #ecfdf5; color: #059669; }                            /* B+ */
.b { background: #fffbeb; color: #d97706; }                                /* B */
.c { background: #f3f4f6; color: #4b5563; }                                /* C */
.f { background: #fef2f2; color: #dc2626; }                                /* Fail */
/* ============================= */
/* 📱 RESPONSIVE DESIGN */
/* ============================= */

/* Tablets (≤ 1024px) */
@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
        padding: 30px 15px;
    }

    .content {
        padding: 25px;
    }

    .card {
        padding: 20px;
    }
}

/* Mobile (≤ 768px) */
@media (max-width: 768px) {

    body {
        flex-direction: column;
    }

    /* Sidebar becomes top navbar */
    .sidebar {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
        padding: 10px;
        border-right: none;
        border-bottom: 1px solid #e0e5f2;
    }

    .logo {
        display: none;
    }

    .sidebar nav {
        display: flex;
        gap: 10px;
    }

    .nav-btn {
        min-width: 160px;
        font-size: 14px;
        padding: 10px;
        text-align: center;
    }

    /* ✅ FIXED: Upload visible as bottom button */
    .upload-section {
        display: block;
        position: fixed;
        bottom: 10px;
        left: 10px;
        right: 10px;
        z-index: 999;
    }

    .custom-file-upload {
        width: 100%;
        padding: 14px;
        font-size: 14px;
        border-radius: 12px;
        text-align: center;
        background: var(--primary);
        color: white;
        border: none;
        box-shadow: 0 10px 20px rgba(67, 24, 255, 0.3);
    }

    /* Content */
    .content {
        padding: 15px;
        padding-bottom: 80px; /* prevent overlap with upload button */
    }

    /* Header stack */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    /* Inputs */
    .roll-input {
        width: 100%;
    }

    .input-group {
        flex-direction: column;
    }

    .btn-group {
        flex-direction: column;
        width: 100%;
    }

    .btn {
        width: 100%;
    }

    /* Charts */
    canvas {
        min-height: 250px;
    }

    /* Tables scroll */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    /* Metrics grid */
    .metrics-grid {
        grid-template-columns: 1fr;
    }

    /* Subject grid */
    .subject-checkbox-grid {
        grid-template-columns: 1fr 1fr;
    }
}
/* Small Mobile (≤ 480px) */
@media (max-width: 480px) {

    .nav-btn {
        min-width: 130px;
        font-size: 12px;
    }

    .subject-checkbox-grid {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 15px;
    }

    .page-header h1 {
        font-size: 18px;
    }
}
.sidebar::-webkit-scrollbar {
    display: none;
}
.sidebar {
    position: sticky;
    top: 0;
    z-index: 100;
}