<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
    <div class="mb-12">
        <div class="flex flex-col md:flex-row justify-between items-start md:items-center gap-6 mb-8">
            <div class="relative">
                <div
                    class="absolute -left-3 -top-3 w-20 h-20 bg-gradient-to-br from-violet-500/10 to-indigo-600/10 rounded-full blur-xl">
                </div>
                <h1 class="text-4xl font-black tracking-tight dark:text-white relative z-10 mb-2">
                    <span class="bg-gradient-to-r from-violet-600 to-indigo-600 bg-clip-text text-transparent">
                        Validasi Pengajuan Status Akademik
                    </span>
                </h1>
                <p class="text-slate-500 dark:text-slate-400 text-sm pl-1">
                    <i data-lucide="check-circle" class="w-4 h-4 inline mr-2"></i>
                    Validasi pengajuan perubahan status akademik
                </p>
            </div>

            <div class="flex items-center gap-4">
                <a href="<?php echo e(route('dashboard')); ?>"
                    class="px-4 py-2.5 bg-white dark:bg-gray-800 border border-slate-200 dark:border-gray-700 rounded-xl text-sm font-medium text-slate-600 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-gray-700 transition-all flex items-center gap-2 shadow-sm">
                    <i data-lucide="arrow-left" class="w-4 h-4"></i>
                    <span>Kembali</span>
                </a>
            </div>
        </div>

        <!-- Flash Messages -->
        <?php if(session('success')): ?>
            <div
                class="mb-6 p-4 bg-gradient-to-r from-green-500/10 to-emerald-600/10 border border-green-500/20 rounded-2xl flex items-center gap-3">
                <div class="w-10 h-10 rounded-xl bg-green-500/10 text-green-500 flex items-center justify-center">
                    <i data-lucide="check-circle" class="w-5 h-5"></i>
                </div>
                <div class="flex-1">
                    <p class="font-medium text-green-700 dark:text-green-400"><?php echo e(session('success')); ?></p>
                </div>
                <button onclick="this.parentElement.remove()" class="text-green-500 hover:text-green-600">
                    <i data-lucide="x" class="w-4 h-4"></i>
                </button>
            </div>
        <?php endif; ?>

        <?php if(session('error')): ?>
            <div
                class="mb-6 p-4 bg-gradient-to-r from-red-500/10 to-rose-600/10 border border-red-500/20 rounded-2xl flex items-center gap-3">
                <div class="w-10 h-10 rounded-xl bg-red-500/10 text-red-500 flex items-center justify-center">
                    <i data-lucide="alert-triangle" class="w-5 h-5"></i>
                </div>
                <div class="flex-1">
                    <p class="font-medium text-red-700 dark:text-red-400"><?php echo e(session('error')); ?></p>
                </div>
                <button onclick="this.parentElement.remove()" class="text-red-500 hover:text-red-600">
                    <i data-lucide="x" class="w-4 h-4"></i>
                </button>
            </div>
        <?php endif; ?>

        <!-- Statistics Cards -->
        <div class="grid grid-cols-2 md:grid-cols-6 gap-4 mb-6">
            <div class="bg-white dark:bg-[#1a1a2e] rounded-xl border border-slate-200 dark:border-white/5 p-4">
                <div class="text-center">
                    <p class="text-2xl font-bold text-purple-600"><?php echo e($statistics['total'] ?? 0); ?></p>
                    <p class="text-xs text-slate-500">Total Pengajuan</p>
                </div>
            </div>
            <div class="bg-white dark:bg-[#1a1a2e] rounded-xl border border-slate-200 dark:border-white/5 p-4">
                <div class="text-center">
                    <p class="text-2xl font-bold text-green-600"><?php echo e($statistics['aktif'] ?? 0); ?></p>
                    <p class="text-xs text-slate-500">Aktif</p>
                </div>
            </div>
            <div class="bg-white dark:bg-[#1a1a2e] rounded-xl border border-slate-200 dark:border-white/5 p-4">
                <div class="text-center">
                    <p class="text-2xl font-bold text-yellow-600"><?php echo e($statistics['cuti'] ?? 0); ?></p>
                    <p class="text-xs text-slate-500">Cuti</p>
                </div>
            </div>
            <div class="bg-white dark:bg-[#1a1a2e] rounded-xl border border-slate-200 dark:border-white/5 p-4">
                <div class="text-center">
                    <p class="text-2xl font-bold text-red-600"><?php echo e($statistics['drop_out'] ?? 0); ?></p>
                    <p class="text-xs text-slate-500">Drop Out</p>
                </div>
            </div>
            <div class="bg-white dark:bg-[#1a1a2e] rounded-xl border border-slate-200 dark:border-white/5 p-4">
                <div class="text-center">
                    <p class="text-2xl font-bold text-blue-600"><?php echo e($statistics['lulus'] ?? 0); ?></p>
                    <p class="text-xs text-slate-500">Lulus</p>
                </div>
            </div>
            <div class="bg-white dark:bg-[#1a1a2e] rounded-xl border border-slate-200 dark:border-white/5 p-4">
                <div class="text-center">
                    <p class="text-2xl font-bold text-gray-600"><?php echo e($statistics['tidak_aktif'] ?? 0); ?></p>
                    <p class="text-xs text-slate-500">Tidak Aktif</p>
                </div>
            </div>
        </div>

        <!-- Filter Section -->
        <div class="mb-6 bg-white dark:bg-[#1a1a2e] rounded-xl border border-slate-200 dark:border-white/5 p-4">
            <form method="GET" action="<?php echo e(route('validasi-pengajuan.index')); ?>" class="space-y-4">
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4">
                    <?php if(auth()->user()->role->name == 'superadmin' || auth()->user()->role->name == 'admin'): ?>
                        <div>
                            <label
                                class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Kampus</label>
                            <select name="kampus_id" id="kampusFilter"
                                class="w-full px-4 py-2 bg-white dark:bg-gray-800 border border-slate-200 dark:border-gray-700 rounded-lg text-sm focus:ring-2 focus:ring-violet-500">
                                <option value="all">Semua Kampus</option>
                                <?php if(isset($kampusList) && $kampusList->isNotEmpty()): ?>
                                    <?php $__currentLoopData = $kampusList; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $kampus): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($kampus->id); ?>"
                                            <?php echo e(request('kampus_id') == $kampus->id ? 'selected' : ''); ?>>
                                            <?php echo e($kampus->nama); ?>

                                        </option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                <?php endif; ?>
                            </select>
                        </div>
                    <?php endif; ?>

                    <div>
                        <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Jenis
                            Pengajuan</label>
                        <select name="jenis"
                            class="w-full px-4 py-2 bg-white dark:bg-gray-800 border border-slate-200 dark:border-gray-700 rounded-lg text-sm focus:ring-2 focus:ring-violet-500">
                            <option value="all">Semua Jenis</option>
                            <option value="aktif" <?php echo e(request('jenis') == 'aktif' ? 'selected' : ''); ?>>Aktif</option>
                            <option value="cuti" <?php echo e(request('jenis') == 'cuti' ? 'selected' : ''); ?>>Cuti</option>
                            <option value="drop_out" <?php echo e(request('jenis') == 'drop_out' ? 'selected' : ''); ?>>Drop Out
                            </option>
                            <option value="lulus" <?php echo e(request('jenis') == 'lulus' ? 'selected' : ''); ?>>Lulus</option>
                            <option value="tidak_aktif" <?php echo e(request('jenis') == 'tidak_aktif' ? 'selected' : ''); ?>>Tidak
                                Aktif</option>
                        </select>
                    </div>

                    <div class="md:col-span-2">
                        <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Pencarian</label>
                        <div class="relative">
                            <i data-lucide="search"
                                class="absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-slate-400"></i>
                            <input type="text" name="search" value="<?php echo e(request('search')); ?>"
                                placeholder="Cari NIM atau Nama Mahasiswa..."
                                class="w-full pl-10 pr-4 py-2 bg-white dark:bg-gray-800 border border-slate-200 dark:border-gray-700 rounded-lg text-sm focus:ring-2 focus:ring-violet-500">
                        </div>
                    </div>
                </div>

                <div class="flex justify-end gap-2">
                    <button type="submit"
                        class="px-4 py-2 bg-gradient-to-r from-violet-600 to-indigo-700 text-white rounded-lg text-sm font-medium hover:shadow-lg hover:shadow-violet-500/25 transition-all flex items-center gap-2">
                        <i data-lucide="filter" class="w-4 h-4"></i> Filter
                    </button>
                    <a href="<?php echo e(route('validasi-pengajuan.index')); ?>"
                        class="px-4 py-2 bg-white dark:bg-gray-800 border border-slate-200 dark:border-gray-700 rounded-lg text-sm font-medium text-slate-600 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-gray-700 transition-all flex items-center gap-2">
                        <i data-lucide="x" class="w-4 h-4"></i> Reset
                    </a>
                </div>
            </form>
        </div>

        <!-- Bulk Actions -->
        <div class="mb-4 p-4 bg-white dark:bg-[#1a1a2e] rounded-xl border border-slate-200 dark:border-white/5">
            <div class="flex flex-wrap items-center gap-4">
                <div class="flex items-center gap-2">
                    <span class="text-sm text-slate-600 dark:text-slate-400" id="selectedCount">0 pengajuan
                        dipilih</span>
                    <button type="button" onclick="clearSelection()"
                        class="text-xs text-violet-600 hover:underline">Hapus pilihan</button>
                </div>

                <div class="flex items-center gap-2 ml-auto">
                    <select id="bulkAction"
                        class="px-3 py-2 bg-white dark:bg-gray-800 border border-slate-200 dark:border-gray-700 rounded-lg text-sm focus:ring-2 focus:ring-violet-500">
                        <option value="">Pilih Aksi</option>
                        <option value="approve">Setujui Semua</option>
                        <option value="reject">Tolak Semua</option>
                    </select>
                    <button type="button" onclick="bulkAction()"
                        class="px-4 py-2 bg-violet-600 text-white rounded-lg text-sm font-medium hover:bg-violet-700 transition-all disabled:opacity-50 disabled:cursor-not-allowed"
                        id="bulkActionBtn" disabled>
                        <i data-lucide="check-circle" class="w-4 h-4 inline mr-1"></i>
                        Proses
                    </button>
                </div>
            </div>
        </div>

        <!-- Table -->
        <div class="bg-white dark:bg-[#1a1a2e] rounded-xl border border-slate-200 dark:border-white/5 overflow-hidden">
            <div class="overflow-x-auto">
                <table class="w-full">
                    <thead>
                        <tr class="bg-slate-50/50 dark:bg-white/5 border-b">
                            <th class="py-4 px-6 w-12">
                                <input type="checkbox" id="selectAll" class="w-4 h-4 text-violet-600 rounded">
                            </th>
                            <th class="text-left py-4 px-6 text-xs font-semibold text-slate-500 uppercase">No</th>
                            <th class="text-left py-4 px-6 text-xs font-semibold text-slate-500 uppercase">NIM</th>
                            <th class="text-left py-4 px-6 text-xs font-semibold text-slate-500 uppercase">Nama</th>
                            <th class="text-left py-4 px-6 text-xs font-semibold text-slate-500 uppercase">Kampus/Prodi
                            </th>
                            <th class="text-left py-4 px-6 text-xs font-semibold text-slate-500 uppercase">Status Saat
                                Ini</th>
                            <th class="text-left py-4 px-6 text-xs font-semibold text-slate-500 uppercase">Pengajuan
                            </th>
                            <th class="text-left py-4 px-6 text-xs font-semibold text-slate-500 uppercase">Semester
                                Cuti</th>
                            <th class="text-left py-4 px-6 text-xs font-semibold text-slate-500 uppercase">Tgl
                                Pengajuan</th>
                            <th class="text-left py-4 px-6 text-xs font-semibold text-slate-500 uppercase">Aksi
                                Validasi</th>
                        </tr>
                    </thead>
                    <tbody class="divide-y">
                        <?php $__empty_1 = true; $__currentLoopData = $pengajuan; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <?php
                                $statusAkademikClass = match ($item->status_akademik ?? '') {
                                    'aktif' => 'bg-green-500/10 text-green-600',
                                    'cuti' => 'bg-yellow-500/10 text-yellow-600',
                                    'drop_out' => 'bg-red-500/10 text-red-600',
                                    'lulus' => 'bg-blue-500/10 text-blue-600',
                                    'tidak_aktif' => 'bg-gray-500/10 text-gray-600',
                                    default => 'bg-slate-500/10 text-slate-600',
                                };

                                $statusAkademikText = match ($item->status_akademik ?? '') {
                                    'aktif' => 'Aktif',
                                    'cuti' => 'Cuti',
                                    'drop_out' => 'Drop Out',
                                    'lulus' => 'Lulus',
                                    'tidak_aktif' => 'Tidak Aktif',
                                    default => $item->status_akademik ?? '-',
                                };

                                $pengajuanClass = match ($item->pengajuan_jenis ?? '') {
                                    'aktif' => 'bg-green-500/10 text-green-600',
                                    'cuti' => 'bg-yellow-500/10 text-yellow-600',
                                    'drop_out' => 'bg-red-500/10 text-red-600',
                                    'lulus' => 'bg-blue-500/10 text-blue-600',
                                    'tidak_aktif' => 'bg-gray-500/10 text-gray-600',
                                    default => 'bg-slate-500/10 text-slate-600',
                                };

                                $pengajuanText = match ($item->pengajuan_jenis ?? '') {
                                    'aktif' => 'Aktif',
                                    'cuti' => 'Cuti',
                                    'drop_out' => 'Drop Out',
                                    'lulus' => 'Lulus',
                                    'tidak_aktif' => 'Tidak Aktif',
                                    default => $item->pengajuan_jenis ?? '-',
                                };
                            ?>
                            <tr class="hover:bg-slate-50/50 dark:hover:bg-white/5">
                                <td class="py-4 px-6">
                                    <input type="checkbox" name="pengajuan_ids[]" value="<?php echo e($item->id); ?>"
                                        class="pengajuan-checkbox w-4 h-4 text-violet-600 rounded">
                                </td>
                                <td class="py-4 px-6 font-mono text-sm"><?php echo e($pengajuan->firstItem() + $index); ?></td>
                                <td class="py-4 px-6 font-mono text-sm"><?php echo e($item->nim ?? '-'); ?></td>
                                <td class="py-4 px-6 font-medium"><?php echo e($item->nama ?? '-'); ?></td>
                                <td class="py-4 px-6">
                                    <div class="text-sm"><?php echo e($item->kampus->nama ?? '-'); ?></div>
                                    <div class="text-xs text-slate-500"><?php echo e($item->prodi->nama ?? '-'); ?></div>
                                </td>
                                <td class="py-4 px-6">
                                    <span class="px-2 py-1 text-xs rounded-lg <?php echo e($statusAkademikClass); ?>">
                                        <?php echo e($statusAkademikText); ?>

                                    </span>
                                </td>
                                <td class="py-4 px-6">
                                    <span class="px-2 py-1 text-xs rounded-lg <?php echo e($pengajuanClass); ?>">
                                        <?php echo e($pengajuanText); ?>

                                    </span>
                                    <?php if($item->pengajuan_jenis === 'cuti' && ($item->pengajuan_file || $item->bukti_bayar_file)): ?>
                                        <button type="button" onclick="showDetail(<?php echo e($item->id); ?>)"
                                            class="ml-2 text-xs text-blue-600 hover:underline">
                                            Lihat File
                                        </button>
                                    <?php endif; ?>
                                </td>
                                <td class="py-4 px-6 text-sm">
                                    <?php if($item->pengajuan_jenis === 'cuti' && $item->cuti_semester): ?>
                                        <span class="px-2 py-1 text-xs rounded-lg bg-purple-500/10 text-purple-600">
                                            <?php
                                                $cutiSemester = is_array($item->cuti_semester)
                                                    ? $item->cuti_semester
                                                    : json_decode($item->cuti_semester, true);
                                                $cutiText = is_array($cutiSemester)
                                                    ? implode(', ', $cutiSemester)
                                                    : $item->cuti_semester;
                                            ?>
                                            Semester <?php echo e($cutiText); ?>

                                        </span>
                                    <?php else: ?>
                                        -
                                    <?php endif; ?>
                                </td>
                                <td class="py-4 px-6 text-sm">
                                    <?php echo e($item->pengajuan_at ? $item->pengajuan_at->format('d/m/Y H:i') : '-'); ?>

                                </td>
                                <td class="py-4 px-6">
                                    <div class="flex items-center gap-2">
                                        <button type="button"
                                            onclick="approvePengajuan(<?php echo e($item->id); ?>, '<?php echo e($item->nama); ?>')"
                                            class="p-2 text-green-600 hover:bg-green-50 dark:hover:bg-green-900/20 rounded-lg transition"
                                            title="Setujui">
                                            <i data-lucide="check-circle" class="w-4 h-4"></i>
                                        </button>
                                        <button type="button"
                                            onclick="rejectPengajuan(<?php echo e($item->id); ?>, '<?php echo e($item->nama); ?>')"
                                            class="p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition"
                                            title="Tolak">
                                            <i data-lucide="x-circle" class="w-4 h-4"></i>
                                        </button>
                                    </div>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr>
                                <td colspan="10" class="py-12 text-center text-slate-500">
                                    <i data-lucide="inbox" class="w-12 h-12 mx-auto mb-3 text-slate-400"></i>
                                    <p>Tidak ada pengajuan pending</p>
                                </td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>

            <!-- Pagination -->
            <?php if($pengajuan->hasPages()): ?>
                <div class="p-4 border-t">
                    <?php echo e($pengajuan->withQueryString()->links('vendor.pagination.tailwind')); ?>

                </div>
            <?php endif; ?>
        </div>
    </div>

    <!-- Modal Detail File -->
    <div id="detailModal" class="fixed inset-0 z-50 hidden overflow-y-auto">
        <div class="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
            <div class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" onclick="closeDetailModal()">
            </div>
            <div
                class="inline-block align-bottom bg-white dark:bg-[#1a1a2e] rounded-3xl text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full">
                <div class="p-6">
                    <div class="flex justify-between items-center mb-4">
                        <h3 class="text-lg font-bold">Detail Pengajuan</h3>
                        <button onclick="closeDetailModal()" class="text-slate-400 hover:text-slate-500">
                            <i data-lucide="x" class="w-5 h-5"></i>
                        </button>
                    </div>
                    <div id="detailModalContent" class="space-y-4">
                        <div class="text-center py-8" id="detailLoading">
                            <div
                                class="inline-block animate-spin rounded-full h-8 w-8 border-4 border-violet-500 border-t-transparent">
                            </div>
                            <p class="mt-2 text-sm text-slate-500">Memuat...</p>
                        </div>
                        <div id="detailData" class="hidden"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            lucide.createIcons();

            // Select All
            const selectAll = document.getElementById('selectAll');
            const checkboxes = document.querySelectorAll('.pengajuan-checkbox');
            const bulkActionBtn = document.getElementById('bulkActionBtn');
            const selectedCount = document.getElementById('selectedCount');

            function updateSelectedCount() {
                const checked = document.querySelectorAll('.pengajuan-checkbox:checked').length;
                selectedCount.textContent = checked + ' pengajuan dipilih';
                if (bulkActionBtn) {
                    bulkActionBtn.disabled = checked === 0;
                }
            }

            if (selectAll) {
                selectAll.addEventListener('change', function() {
                    checkboxes.forEach(cb => cb.checked = this.checked);
                    updateSelectedCount();
                });
            }

            checkboxes.forEach(cb => {
                cb.addEventListener('change', updateSelectedCount);
            });

            window.clearSelection = function() {
                checkboxes.forEach(cb => cb.checked = false);
                if (selectAll) selectAll.checked = false;
                updateSelectedCount();
            };
        });

        // ========== SHOW DETAIL MODAL ==========
        function showDetail(id) {
            const modal = document.getElementById('detailModal');
            const loading = document.getElementById('detailLoading');
            const data = document.getElementById('detailData');

            modal.classList.remove('hidden');
            loading.classList.remove('hidden');
            data.classList.add('hidden');

            fetch(`/validasi-pengajuan/${id}`)
                .then(response => response.json())
                .then(m => {
                    loading.classList.add('hidden');

                    let html = `
                        <div class="space-y-4">
                            <div class="grid grid-cols-2 gap-4">
                                <div>
                                    <p class="text-xs text-slate-500">NIM</p>
                                    <p class="font-medium">${m.nim || '-'}</p>
                                </div>
                                <div>
                                    <p class="text-xs text-slate-500">Nama</p>
                                    <p class="font-medium">${m.nama || '-'}</p>
                                </div>
                                <div>
                                    <p class="text-xs text-slate-500">Kampus</p>
                                    <p class="font-medium">${m.kampus || '-'}</p>
                                </div>
                                <div>
                                    <p class="text-xs text-slate-500">Prodi</p>
                                    <p class="font-medium">${m.prodi || '-'}</p>
                                </div>
                                <div>
                                    <p class="text-xs text-slate-500">Angkatan</p>
                                    <p class="font-medium">${m.angkatan || '-'}</p>
                                </div>
                                <div>
                                    <p class="text-xs text-slate-500">Status Saat Ini</p>
                                    <p class="font-medium">${m.status_akademik_text || '-'}</p>
                                </div>
                                <div>
                                    <p class="text-xs text-slate-500">Pengajuan Menjadi</p>
                                    <p class="font-medium">${m.pengajuan_jenis_text || '-'}</p>
                                </div>
                    `;

                    if (m.cuti_semester) {
                        html += `
                                <div>
                                    <p class="text-xs text-slate-500">Semester Cuti</p>
                                    <p class="font-medium">Semester ${m.cuti_semester}</p>
                                </div>
                        `;
                    }

                    html += `
                                <div>
                                    <p class="text-xs text-slate-500">Tanggal Pengajuan</p>
                                    <p class="font-medium">${m.pengajuan_at || '-'}</p>
                                </div>
                                <div>
                                    <p class="text-xs text-slate-500">Diajukan Oleh</p>
                                    <p class="font-medium">${m.pengajuan_by || '-'}</p>
                                </div>
                            </div>
                    `;

                    // File Pengajuan
                    if (m.pengajuan_file) {
                        html += `
                            <div class="border-t pt-3">
                                <p class="text-sm font-medium mb-2">File Pengajuan</p>
                                <a href="/validasi-pengajuan/${m.id}/download-pengajuan"
                                   class="inline-flex items-center gap-2 px-3 py-2 bg-blue-50 text-blue-600 rounded-lg hover:bg-blue-100 transition text-sm">
                                    <i data-lucide="file-text" class="w-4 h-4"></i>
                                    Download File Pengajuan
                                </a>
                            </div>
                        `;
                    }

                    // Bukti Bayar
                    if (m.bukti_bayar_file) {
                        html += `
                            <div class="border-t pt-3">
                                <p class="text-sm font-medium mb-2">Bukti Pembayaran</p>
                                <a href="/validasi-pengajuan/${m.id}/download-bukti"
                                   class="inline-flex items-center gap-2 px-3 py-2 bg-green-50 text-green-600 rounded-lg hover:bg-green-100 transition text-sm">
                                    <i data-lucide="receipt" class="w-4 h-4"></i>
                                    Download Bukti Bayar
                                </a>
                            </div>
                        `;
                    }

                    html += `</div>`;
                    data.innerHTML = html;
                    data.classList.remove('hidden');
                    lucide.createIcons();
                })
                .catch(error => {
                    console.error('Error:', error);
                    loading.classList.add('hidden');
                    data.innerHTML = '<p class="text-center text-red-500">Gagal memuat data</p>';
                    data.classList.remove('hidden');
                });
        }

        function closeDetailModal() {
            document.getElementById('detailModal').classList.add('hidden');
        }

        // ========== APPROVE INDIVIDUAL ==========
        function approvePengajuan(id, nama) {
            Swal.fire({
                title: 'Konfirmasi',
                html: `Setujui pengajuan dari <strong>${nama}</strong>?`,
                icon: 'question',
                showCancelButton: true,
                confirmButtonColor: '#10b981',
                cancelButtonColor: '#64748b',
                confirmButtonText: 'Ya, Setujui!',
                cancelButtonText: 'Batal'
            }).then((result) => {
                if (result.isConfirmed) {
                    fetch(`/validasi-pengajuan/${id}/approve`, {
                            method: 'POST',
                            headers: {
                                'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
                                'Content-Type': 'application/json',
                                'Accept': 'application/json'
                            }
                        })
                        .then(response => response.json())
                        .then(data => {
                            if (data.success) {
                                Swal.fire('Berhasil!', data.message, 'success').then(() => {
                                    window.location.reload();
                                });
                            } else {
                                Swal.fire('Gagal!', data.message, 'error');
                            }
                        })
                        .catch(error => {
                            console.error('Error:', error);
                            Swal.fire('Error!', 'Terjadi kesalahan', 'error');
                        });
                }
            });
        }

        // ========== REJECT INDIVIDUAL ==========
        function rejectPengajuan(id, nama) {
            Swal.fire({
                title: 'Konfirmasi',
                html: `Tolak pengajuan dari <strong>${nama}</strong>?`,
                icon: 'warning',
                showCancelButton: true,
                confirmButtonColor: '#ef4444',
                cancelButtonColor: '#64748b',
                confirmButtonText: 'Ya, Tolak!',
                cancelButtonText: 'Batal'
            }).then((result) => {
                if (result.isConfirmed) {
                    fetch(`/validasi-pengajuan/${id}/reject`, {
                            method: 'POST',
                            headers: {
                                'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
                                'Content-Type': 'application/json',
                                'Accept': 'application/json'
                            }
                        })
                        .then(response => response.json())
                        .then(data => {
                            if (data.success) {
                                Swal.fire('Berhasil!', data.message, 'success').then(() => {
                                    window.location.reload();
                                });
                            } else {
                                Swal.fire('Gagal!', data.message, 'error');
                            }
                        })
                        .catch(error => {
                            console.error('Error:', error);
                            Swal.fire('Error!', 'Terjadi kesalahan', 'error');
                        });
                }
            });
        }

        // ========== BULK ACTION ==========
        let selectedIds = [];

        function bulkAction() {
            selectedIds = Array.from(document.querySelectorAll('.pengajuan-checkbox:checked')).map(cb => cb.value);
            const action = document.getElementById('bulkAction').value;

            if (selectedIds.length === 0) {
                Swal.fire('Peringatan', 'Pilih minimal 1 pengajuan', 'warning');
                return;
            }

            if (!action) {
                Swal.fire('Peringatan', 'Pilih aksi yang akan dilakukan', 'warning');
                return;
            }

            let title = action === 'approve' ? 'Setujui' : 'Tolak';
            let color = action === 'approve' ? '#10b981' : '#ef4444';
            let message = action === 'approve' ? `Setujui ${selectedIds.length} pengajuan?` :
                `Tolak ${selectedIds.length} pengajuan?`;

            Swal.fire({
                title: 'Konfirmasi',
                text: message,
                icon: 'question',
                showCancelButton: true,
                confirmButtonColor: color,
                confirmButtonText: `Ya, ${title}!`,
                cancelButtonText: 'Batal'
            }).then((result) => {
                if (result.isConfirmed) {
                    submitBulkAction(action);
                }
            });
        }

        function submitBulkAction(action) {
            fetch('<?php echo e(route('validasi-pengajuan.bulk-action')); ?>', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                        'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
                        'Accept': 'application/json'
                    },
                    body: JSON.stringify({
                        ids: selectedIds,
                        action: action
                    })
                })
                .then(response => response.json())
                .then(data => {
                    if (data.success) {
                        Swal.fire('Berhasil!', data.message, 'success').then(() => {
                            window.location.reload();
                        });
                    } else {
                        Swal.fire('Gagal!', data.message, 'error');
                    }
                })
                .catch(error => {
                    console.error('Error:', error);
                    Swal.fire('Error!', 'Terjadi kesalahan', 'error');
                });
        }
    </script>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php /**PATH /home/edunesiaserver/public_html/K2/WEB_INTERNAL/SIMA/DEVELOPMENT/resources/views/validasi/pengajuan-status.blade.php ENDPATH**/ ?>