<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Semua Hasil Perhitungan</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            line-height: 1.6;
            color: #333;
            margin: 20px;
        }
        .header {
            text-align: center;
            margin-bottom: 30px;
        }
        .header h1 {
            margin-bottom: 5px;
            font-size: 24px;
        }
        .session-header {
            background-color: #f8f9fa;
            padding: 15px;
            margin-top: 30px;
            margin-bottom: 20px;
            border-radius: 5px;
            border-left: 5px solid #007bff;
        }
        .session-header h2 {
            margin: 0;
            font-size: 18px;
        }
        .sub-header {
            margin-bottom: 20px;
            border-bottom: 1px solid #ddd;
            padding-bottom: 10px;
        }
        .sub-header p {
            margin: 5px 0;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 30px;
        }
        table, th, td {
            border: 1px solid #ddd;
        }
        th, td {
            padding: 8px;
            text-align: left;
            font-size: 12px;
        }
        th {
            background-color: #f2f2f2;
        }
        .section-title {
            font-weight: bold;
            font-size: 14px;
            margin-top: 20px;
            margin-bottom: 10px;
            border-bottom: 1px solid #ddd;
            padding-bottom: 5px;
        }
        .footer {
            margin-top: 50px;
            text-align: center;
            font-size: 12px;
            color: #777;
        }
        .page-break {
            page-break-after: always;
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>LAPORAN SEMUA HASIL PERHITUNGAN</h1>
        <p>Laporan Lengkap Hasil Perhitungan dan Rekomendasi</p>
    </div>
    
    @foreach($data as $index => $item)
    <div class="session-header">
        <h2>Sesi #{{ $index + 1 }}: {{ $item['sesi']->nama }}</h2>
    </div>
    
    <div class="sub-header">
        <p><strong>Nama Siswa:</strong> {{ $item['sesi']->nama }}</p>
        <p><strong>Sekolah:</strong> {{ $item['sesi']->sekolah }}</p>
        <p><strong>Kelas:</strong> {{ $item['sesi']->kelas }}</p>
        <p><strong>Kurikulum:</strong> {{ $item['sesi']->kurikulum->nama }}</p>
        <p><strong>Tanggal:</strong> {{ $item['sesi']->created_at->format('d/m/Y H:i:s') }}</p>
    </div>
    
    <div class="section-title">Hasil Perhitungan</div>
    <table>
        <thead>
            <tr>
                <th>Peringkat</th>
                <th>Alternatif</th>
                <th>Total Skor</th>
                <th>Skor Normalisasi</th>
            </tr>
        </thead>
        <tbody>
            @foreach($item['hasil'] as $hasil)
            <tr>
                <td>{{ $hasil->peringkat }}</td>
                <td>{{ $hasil->alternatif->nama }}</td>
                <td>{{ number_format($hasil->total_skor, 2) }}</td>
                <td>{{ number_format($hasil->skor_normalisasi, 2) }}</td>
            </tr>
            @endforeach
        </tbody>
    </table>
    
    <div class="section-title">Jawaban Pengguna</div>
    <table>
        <thead>
            <tr>
                <th>Subkriteria</th>
                <th>Opsi Dipilih</th>
            </tr>
        </thead>
        <tbody>
            @foreach($item['jawaban'] as $jawaban)
            <tr>
                <td>{{ $jawaban->subkriteria->pertanyaan }}</td>
                <td>{{ $jawaban->opsi_dipilih }}</td>
            </tr>
            @endforeach
        </tbody>
    </table>
    
    @if(!$loop->last)
    <div class="page-break"></div>
    @endif
    @endforeach
    
    <div class="footer">
        <p>Dicetak pada: {{ now()->format('d/m/Y H:i:s') }}</p>
    </div>
</body>
</html>