<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <title>Pusat Verifikasi Dokumen</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
</head>
<body class="bg-slate-900 text-slate-200 min-h-screen p-8 font-sans">

    <div class="max-w-7xl mx-auto">
        <div class="flex justify-between items-center mb-8 border-b border-slate-700 pb-6">
            <div>
                <h1 class="text-3xl font-black text-white">Console Verifikasi Dokumen</h1>
                <p class="text-sm text-slate-400 mt-1">Petugas saat ini: Bapak/Ibu Ichsan (Pusat Administrasi)</p>
            </div>
            <a href="/logout" class="bg-slate-800 hover:bg-slate-700 text-white px-4 py-2 rounded-lg text-sm font-bold border border-slate-700 transition">Log Out Sistem</a>
        </div>

        <div class="bg-slate-950 border border-slate-800 rounded-2xl shadow-xl overflow-hidden">
            <table class="w-full text-left text-sm">
                <thead class="bg-slate-900 text-slate-400 text-xs uppercase tracking-wider border-b border-slate-800">
                    <tr>
                        <th class="p-5">Asal Pengirim</th>
                        <th class="p-5">Identitas Siswa</th>
                        <th class="p-5">Berkas Asli</th>
                        <th class="p-5 text-right">Tindakan Eksekusi</th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-slate-800/50">
                    <?php foreach($dokumen_masuk as $dok): ?>
                    <tr class="hover:bg-slate-900/50">
                        <td class="p-5 font-bold text-indigo-400"><?= $dok['nama_instansi'] ?></td>
                        <td class="p-5">
                            <p class="text-white font-semibold"><?= $dok['nama_siswa'] ?></p>
                            <p class="text-xs text-slate-500 mt-1">NISN: <?= $dok['nisn'] ?> &bull; <?= $dok['nama_prestasi'] ?></p>
                        </td>
                        <td class="p-5">
                            <a href="/uploads/sertifikat/<?= $dok['file_sertifikat'] ?>" target="_blank" class="text-xs bg-slate-800 text-slate-300 px-3 py-1.5 rounded-lg hover:bg-slate-700 flex items-center inline-flex gap-2 w-fit">
                                <i class="fa fa-file-pdf text-red-400"></i> Buka File
                            </a>
                        </td>
                        <td class="p-5">
                            <div class="flex items-center justify-end gap-2">
                                <form action="/kantor/proses_validasi/<?= $dok['id'] ?>" method="POST" class="flex gap-2">
                                    <?= csrf_field() ?>
                                    <button type="submit" name="keputusan" value="valid" class="bg-emerald-500/10 text-emerald-500 border border-emerald-500/20 hover:bg-emerald-500 hover:text-white px-3 py-1.5 rounded text-xs font-bold transition">Setujui Berkas</button>
                                    <button type="submit" name="keputusan" value="revisi" class="bg-red-500/10 text-red-500 border border-red-500/20 hover:bg-red-500 hover:text-white px-3 py-1.5 rounded text-xs font-bold transition">Tolak</button>
                                </form>

                                <?php if($dok['status_verifikasi'] == 'valid'): ?>
                                    <a href="/kantor/cetak_surat/<?= $dok['id'] ?>" target="_blank" class="bg-indigo-600 text-white px-3 py-1.5 rounded text-xs font-bold hover:bg-indigo-700 shadow-lg ml-2">
                                        <i class="fa fa-print mr-1"></i> Cetak SK
                                    </a>
                                <?php endif; ?>
                            </div>
                        </td>
                    </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
        </div>
    </div>

</body>
</html>