<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <title>Laporan Nilai - {{ $ujian->nama }}</title>
    <style>
        body { font-family: Arial, sans-serif; font-size: 11px; margin: 20px; }
        h2 { text-align: center; margin-bottom: 4px; }
        .sub { text-align: center; margin-bottom: 16px; color: #444; }
        table { width: 100%; border-collapse: collapse; margin-top: 10px; }
        th { background-color: #2563EB; color: white; padding: 6px 8px; text-align: center; }
        td { padding: 5px 8px; border: 1px solid #ddd; text-align: center; }
        tr:nth-child(even) { background-color: #f3f4f6; }
        .footer { margin-top: 20px; text-align: right; font-size: 10px; color: #888; }
        .lulus { color: #16a34a; font-weight: bold; }
        .tidak-lulus { color: #dc2626; font-weight: bold; }
    </style>
</head>
<body>
    <h2>LAPORAN NILAI UJIAN</h2>
    <p class="sub">
        {{ $ujian->nama }} | {{ $ujian->mataPelajaran->nama }} | Kelas {{ $ujian->kelas->nama }}<br>
        Tahun Ajaran {{ $ujian->tahunAjaran->nama }} Semester {{ $ujian->tahunAjaran->semester }}
    </p>

    <table>
        <thead>
            <tr>
                <th>No</th>
                <th>NIS</th>
                <th>Nama Siswa</th>
                <th>Nilai PG</th>
                <th>Nilai BS</th>
                <th>Nilai Essay</th>
                <th>Nilai Murni</th>
                <th>Nilai Final</th>
                <th>Keterangan</th>
            </tr>
        </thead>
        <tbody>
            @foreach($nilaiList as $i => $nilai)
            <tr>
                <td>{{ $i + 1 }}</td>
                <td>{{ $nilai->siswa->nis ?? '-' }}</td>
                <td style="text-align:left">{{ $nilai->siswa->nama }}</td>
                <td>{{ $nilai->nilai_pg ?? '-' }}</td>
                <td>{{ $nilai->nilai_bs ?? '-' }}</td>
                <td>{{ $nilai->nilai_essay ?? '-' }}</td>
                <td>{{ $nilai->nilai_murni ?? '-' }}</td>
                <td><strong>{{ $nilai->nilai_final ?? '-' }}</strong></td>
                <td>
                    @if($nilai->nilai_final !== null)
                        @if($nilai->nilai_final >= 75)
                            <span class="lulus">Lulus</span>
                        @else
                            <span class="tidak-lulus">Belum Lulus</span>
                        @endif
                    @else
                        -
                    @endif
                </td>
            </tr>
            @endforeach
        </tbody>
    </table>

    <div class="footer">
        Dicetak pada: {{ now()->format('d/m/Y H:i:s') }}
    </div>
</body>
</html>
