<!DOCTYPE html>
<html>
<head>
    <title>SK Tim Penguji (P4) - {{ $p4->nim_mahasiswa }}</title>
    <style>
        @page { size: legal landscape; margin: 1cm 1.5cm; }
        body { font-family: 'Times New Roman', Times, serif; font-size: 10.5pt; line-height: 1.2; margin: 0; padding: 0; }
        
        .lampiran-header { margin-bottom: 20px; text-align: left; line-height: 1.3; }

        .main-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; clear: both; }
        .main-table th, .main-table td { border: 1px solid black; padding: 5px; text-align: left; vertical-align: top; }
        .main-table th { text-align: center; }
        
        .footer { margin-top: 30px; position: relative; width: 100%; }
        .signature { position: absolute; right: 0; width: 300px; text-align: left; font-size: 10.5pt; }
    </style>
</head>
<body>
    <div class="lampiran-header">
        LAMPIRAN<br>
        KEPUTUSAN DEKAN FAKULTAS HUKUM<br>
        UNIVERSITAS CENDERAWASIH<br>
        NOMOR : {{ $p4->nosrt }}<br>
        TANGGAL : {{ strtoupper(\Carbon\Carbon::parse($p4->created_at)->translatedFormat('l, d F Y')) }}<br>
        TENTANG<br>
        PENUNJUKAN TIM PENGUJI UJIAN SKRIPSI
    </div>

    <table class="main-table">
        <thead>
            <tr>
                <th rowspan="2" width="30">No.</th>
                <th rowspan="2" width="200">Nama Penguji</th>
                <th rowspan="2" width="150">NIP</th>
                <th colspan="3">TIM PENGUJI UJIAN SKRIPSI</th>
            </tr>
            <tr>
                <th width="200">Nama Mahasiswa/NIM</th>
                <th width="120">Program Kekhususan</th>
                <th>Judul Skripsi</th>
            </tr>
            <tr style="font-size: 8pt; text-align: center;">
                <th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th>
            </tr>
        </thead>
        <tbody>
            @php 
                $examiners = [];
                for($i=1; $i<=5; $i++) {
                    $nipField = "nip_penguji$i";
                    $namaField = "nama_penguji$i";
                    if($p4->$nipField) {
                        $examiners[] = [
                            'nama' => $p4->$namaField,
                            'nip' => $p4->$nipField
                        ];
                    }
                }
                $count = count($examiners);
            @endphp

            @foreach($examiners as $index => $ex)
            <tr>
                <td @style([
                    'text-align: center',
                    'border-top: none' => $index !== 0,
                    'border-bottom: none' => $index !== $count - 1
                ])>{{ $index + 1 }}</td>
                <td @style([
                    'border-top: none' => $index !== 0,
                    'border-bottom: none' => $index !== $count - 1
                ])>{{ $ex['nama'] }}</td>
                <td @style([
                    'border-top: none' => $index !== 0,
                    'border-bottom: none' => $index !== $count - 1
                ])>NIP. {{ $ex['nip'] }}</td>
                @if($index === 0)
                <td rowspan="{{ $count }}">{{ $p4->nama_mahasiswa ?? $p4->mahasiswa->nama }}<br>NIM. {{ $p4->nim_mahasiswa }}</td>
                <td rowspan="{{ $count }}" style="text-align: center;">{{ $p4->mahasiswa->bagian ?? 'Hukum Pidana' }}</td>
                <td rowspan="{{ $count }}" style="text-align: justify;">{{ $p4->judul_skripsi }}</td>
                @endif
            </tr>
            @endforeach
        </tbody>
    </table>

    <div class="footer">
        <div class="signature">
            <p>Ditetapkan di Jayapura</p>
            <p style="margin-bottom: 70px;">DEKAN FAKULTAS HUKUM,</p>
            <p><strong>Dr. YUSTUS PONDAYAR, S.H., M.H</strong><br>
            NIP 19730519 200312 1 001</p>
        </div>
    </div>
</body>
</html>
