<%- include("navbar") %>

    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap" rel="stylesheet">

    <style>
        body {
            font-family: 'Poppins', sans-serif;
            background: #0f172a;
        }

        /* Container */
        .admin-container {
            padding: 30px;
        }

        /* Header */
        .page-header {
            background: linear-gradient(135deg, #1e293b, #334155);
            padding: 25px;
            border-radius: 12px;
            margin-bottom: 25px;
            color: white;
        }

        .page-header h2 {
            margin: 0;
            font-weight: 600;
            color: white;
        }

        /* Table Card */
        .table-card {
            background: #1e293b;
            border-radius: 12px;
            padding: 20px;
        }

        /* Table */
        table {
            width: 100%;
            border-collapse: collapse;
            color: white;
        }

        thead {
            background: #334155;
        }

        th {
            padding: 12px;
            font-size: 13px;
            text-align: left;
        }

        td {
            padding: 12px;
            border-bottom: 1px solid #334155;
        }

        tr:hover {
            background: #273449;
        }

        /* Score Badge */
        .score {
            padding: 6px 12px;
            border-radius: 8px;
            font-size: 12px;
            font-weight: 500;
        }

        .high {
            background: #16a34a;
        }

        .medium {
            background: #f59e0b;
        }

        .low {
            background: #ef4444;
        }

        /* Rank Badge */
        .rank {
            background: #6366f1;
            padding: 4px 10px;
            border-radius: 6px;
            font-size: 12px;
        }

        /* Empty message */
        .empty {
            text-align: center;
            padding: 40px;
            color: #94a3b8;
        }
    </style>

    <div class="admin-container">

        <!-- Header -->
        <div class="page-header">
            <h2>📊 Quiz Results</h2>
        </div>

        <div class="table-card">

            <table>

                <thead>
                    <tr>
                        <th>#</th>
                        <th>Student</th>
                        <th>Course</th>
                        <th>Quiz</th>
                        <th>Score</th>
                    </tr>
                </thead>

                <tbody>

                    <% if(results.length> 0){ %>

                        <% results.forEach((r,i)=>{ %>

                            <tr>

                                <td>
                                    <span class="rank">
                                        <%= i+1 %>
                                    </span>
                                </td>

                                <td>
                                    <%= r.full_name %>
                                </td>

                                <td>
                                    <%= r.course_name %>
                                </td>

                                <td>
                                    <%= r.quiz_title %>
                                </td>

                                <td>

                                    <% if(r.score>= 80){ %>
                                        <span class="score high">
                                            <%= r.score %>
                                        </span>
                                        <% } else if(r.score>= 40){ %>
                                            <span class="score medium">
                                                <%= r.score %>
                                            </span>
                                            <% } else { %>
                                                <span class="score low">
                                                    <%= r.score %>
                                                </span>
                                                <% } %>

                                </td>

                            </tr>

                            <% }) %>

                                <% } else { %>

                                    <tr>
                                        <td colspan="5" class="empty">
                                            No quiz results found
                                        </td>
                                    </tr>

                                    <% } %>

                </tbody>

            </table>

        </div>

    </div>

    <%- include("footer") %>