<!DOCTYPE html>
<html>
<head>
    <title>Form Penilaian - {{ $p4->nim_mahasiswa }}</title>
    <style>
        @page { margin: 1cm 2cm; }
        body { font-family: 'Times New Roman', Times, serif; font-size: 11pt; line-height: 1.4; margin: 0; padding: 0; }
        .header { width: 100%; margin-bottom: 5px; }
        .logo-box { width: 85px; height: 85px; border: 1px solid black; text-align: center; vertical-align: middle; font-size: 8pt; font-weight: bold; }
        .header-text { text-align: center; vertical-align: middle; }
        .header-text h3 { margin: 0; font-size: 14pt; font-weight: normal; }
        .header-text h2 { margin: 0; font-size: 15pt; font-weight: bold; }
        .header-text h2.fakultas { margin: 0; font-size: 13pt; font-weight: bold; }
        .address { text-align: center; font-size: 9pt; margin-top: 5px; font-weight: normal; }
        .line { border-bottom: 4px double black; margin-top: 5px; margin-bottom: 20px; }
        
        .title { text-align: center; font-weight: bold; text-decoration: underline; margin-bottom: 20px; text-transform: uppercase; }
        
        .student-table { width: 100%; margin-bottom: 20px; }
        .student-table td { vertical-align: top; padding: 2px 0; }
        
        .score-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; text-align: center; }
        .score-table th, .score-table td { border: 1px solid black; padding: 5px; }
        .score-table th { background-color: #f2f2f2; }
        .score-table .left { text-align: left; }
        
        .catatan { width: 100%; border: 1px solid black; padding: 10px; margin-bottom: 20px; min-height: 60px; }
        
        .footer { margin-top: 40px; position: relative; }
        .signature { position: absolute; right: 0; width: 300px; text-align: left; }
    </style>
</head>
<body>
    <table class="header">
        <tr>
            <td class="logo-box">FAKULTAS<br>HUKUM<br>UNCEN</td>
            <td class="header-text">
                <h3>KEMENTERIAN PENDIDIKAN, KEBUDAYAAN,<br>RISET, DAN TEKNOLOGI</h3>
                <h2>UNIVERSITAS CENDERAWASIH</h2>
                <h2 class="fakultas">FAKULTAS HUKUM</h2>
                <div class="address">
                    Jalan Kampwolker  Kelurahan Yabansai Distrik Heram Jayapura – PAPUA<br>
                    surel – <u style="color: blue;">fh@uncen.ac.id</u>
                </div>
            </td>
        </tr>
    </table>
    <div class="line"></div>

    <div class="title">LEMBAR PENILAIAN UJIAN SKRIPSI</div>

    <table class="student-table">
        <tr><td width="150">Nama Mahasiswa</td><td width="10">:</td><td>{{ $p4->nama_mahasiswa }}</td></tr>
        <tr><td>NIM</td><td>:</td><td>{{ $p4->nim_mahasiswa }}</td></tr>
        <tr><td>Program Studi</td><td>:</td><td>Ilmu Hukum</td></tr>
        <tr><td>Judul Skripsi</td><td>:</td><td style="font-style: italic; text-align: justify;">“{{ $p4->judul_skripsi }}“</td></tr>
    </table>

    <table class="score-table">
        <thead>
            <tr>
                <th width="40">No</th>
                <th>Kriteria Penilaian</th>
                <th width="80">Bobot (%)</th>
                <th width="80">Nilai Angka</th>
                <th width="100">Bobot x Nilai</th>
            </tr>
        </thead>
        <tbody>
            @php $total_bobot = 0; $total_hasil = 0; @endphp
            @foreach($kriteria as $index => $k)
                @php
                    $detail = null;
                    if($penilaian) {
                        $detail = $penilaian->detail->where('kriteria_id', $k->id)->first();
                    }
                    $nilai_angka = $detail ? $detail->nilai_angka : 0;
                    $hasil = $detail ? $detail->hasil_bobot : 0;
                    
                    $total_bobot += $k->bobot;
                    $total_hasil += $hasil;
                @endphp
            <tr>
                <td>{{ $index + 1 }}</td>
                <td class="left">{{ $k->nama_kriteria }}</td>
                <td>{{ $k->bobot }}</td>
                <td>{{ $nilai_angka }}</td>
                <td>{{ number_format($hasil, 2) }}</td>
            </tr>
            @endforeach
            <tr>
                <th colspan="2" style="text-align: right;">Total Nilai Rata-rata = (Total Bobot x Nilai) / {{ $total_bobot }}</th>
                <th colspan="3">{{ $penilaian ? number_format($penilaian->nilai_total, 2) : 0 }}</th>
            </tr>
            <tr>
                <th colspan="2" style="text-align: right;">Nilai Huruf (Kualifikasi)</th>
                <th colspan="3">{{ $huruf }}</th>
            </tr>
        </tbody>
    </table>

    <strong>Catatan / Saran Penguji:</strong>
    <div class="catatan">
        {{ $penilaian ? $penilaian->catatan : '' }}
    </div>

    <div class="footer">
        <div class="signature">
            <p>Jayapura, {{ \Carbon\Carbon::now()->translatedFormat('d F Y') }}</p>
            <p>Penguji {{ $penguji->penguji_ke }},</p>
            <p style="margin-bottom: 70px;"></p>
            <p><strong>{{ $penguji->nama }}</strong><br>
            NIP. {{ $penguji->nip }}</p>
        </div>
    </div>
</body>
</html>
