<?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">
                        Laporan Alokasi Angsuran
                    </span>
                </h1>
                <p class="text-slate-500 dark:text-slate-400 text-sm pl-1">
                    <i data-lucide="file-text" class="w-4 h-4 inline mr-2"></i>
                    Laporan status angsuran mahasiswa (kecuali angsuran pertama semester pertama)
                </p>
            </div>

            <div class="flex items-center gap-3">
                <button type="button" id="cetakSelectedBtn"
                    class="px-4 py-2.5 bg-red-500 hover:bg-red-600 text-white rounded-xl text-sm font-medium transition-all flex items-center gap-2">
                    <i data-lucide="file-text" class="w-4 h-4"></i>
                    Cetak PDF
                </button>
            </div>
        </div>

        <!-- Filter Section -->
        <div class="bg-white dark:bg-[#1a1a2e] rounded-2xl border border-slate-200 dark:border-white/5 shadow-sm p-6 mb-8">
            <form method="GET" action="<?php echo e(route('laporan.alokasi-angsuran')); ?>" class="space-y-4" id="filterForm">
                <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
                    <div>
                        <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Kampus</label>
                        <select name="kampus_id" id="kampus_filter" class="w-full px-4 py-2 bg-white dark:bg-gray-800 border border-slate-200 dark:border-gray-700 rounded-xl">
                            <option value="">Semua Kampus</option>
                            <?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(); ?>
                        </select>
                    </div>

                    <div>
                        <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Program Studi</label>
                        <select name="prodi_id" id="prodi_filter" class="w-full px-4 py-2 bg-white dark:bg-gray-800 border border-slate-200 dark:border-gray-700 rounded-xl">
                            <option value="">Semua Prodi</option>
                            <?php $__currentLoopData = $prodiOptions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $prodi): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($prodi->id); ?>" <?php echo e((request('prodi_id', '')) == $prodi->id ? 'selected' : ''); ?>><?php echo e($prodi->nama); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>

                    <div>
                        <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Tahun Ajaran</label>
                        <select name="tahun_ajaran" id="tahun_ajaran_filter" class="w-full px-4 py-2 bg-white dark:bg-gray-800 border border-slate-200 dark:border-gray-700 rounded-xl">
                            <option value="">Semua Tahun</option>
                            <?php $__currentLoopData = $tahunAjaranOptions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tahun): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($tahun); ?>" <?php echo e((request('tahun_ajaran', '')) == $tahun ? 'selected' : ''); ?>><?php echo e($tahun); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>

                    <div class="flex items-end gap-2">
                        <button type="submit" class="px-4 py-2 bg-gradient-to-r from-violet-600 to-indigo-700 text-white rounded-xl text-sm font-medium flex items-center gap-2">
                            <i data-lucide="search" class="w-4 h-4"></i> Filter
                        </button>
                        <a href="<?php echo e(route('laporan.alokasi-angsuran')); ?>" class="px-4 py-2 bg-slate-500 text-white rounded-xl text-sm font-medium flex items-center gap-2">
                            <i data-lucide="refresh-cw" class="w-4 h-4"></i> Reset
                        </a>
                    </div>
                </div>

                <!-- Baris kedua untuk Bulan dan Tahun -->
                <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
                    <div>
                        <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Bulan (Filter Tanggal Bayar)</label>
                        <select name="bulan" id="bulan_filter" class="w-full px-4 py-2 bg-white dark:bg-gray-800 border border-slate-200 dark:border-gray-700 rounded-xl">
                            <option value="01" <?php echo e((request('bulan', date('m'))) == '01' ? 'selected' : ''); ?>>Januari</option>
                            <option value="02" <?php echo e((request('bulan', date('m'))) == '02' ? 'selected' : ''); ?>>Februari</option>
                            <option value="03" <?php echo e((request('bulan', date('m'))) == '03' ? 'selected' : ''); ?>>Maret</option>
                            <option value="04" <?php echo e((request('bulan', date('m'))) == '04' ? 'selected' : ''); ?>>April</option>
                            <option value="05" <?php echo e((request('bulan', date('m'))) == '05' ? 'selected' : ''); ?>>Mei</option>
                            <option value="06" <?php echo e((request('bulan', date('m'))) == '06' ? 'selected' : ''); ?>>Juni</option>
                            <option value="07" <?php echo e((request('bulan', date('m'))) == '07' ? 'selected' : ''); ?>>Juli</option>
                            <option value="08" <?php echo e((request('bulan', date('m'))) == '08' ? 'selected' : ''); ?>>Agustus</option>
                            <option value="09" <?php echo e((request('bulan', date('m'))) == '09' ? 'selected' : ''); ?>>September</option>
                            <option value="10" <?php echo e((request('bulan', date('m'))) == '10' ? 'selected' : ''); ?>>Oktober</option>
                            <option value="11" <?php echo e((request('bulan', date('m'))) == '11' ? 'selected' : ''); ?>>November</option>
                            <option value="12" <?php echo e((request('bulan', date('m'))) == '12' ? 'selected' : ''); ?>>Desember</option>
                        </select>
                    </div>

                    <div>
                        <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Tahun (Filter Tanggal Bayar)</label>
                        <select name="tahun" id="tahun_filter" class="w-full px-4 py-2 bg-white dark:bg-gray-800 border border-slate-200 dark:border-gray-700 rounded-xl">
                            <?php for($y = 2020; $y <= 2030; $y++): ?>
                                <option value="<?php echo e($y); ?>" <?php echo e((request('tahun', date('Y'))) == $y ? 'selected' : ''); ?>><?php echo e($y); ?></option>
                            <?php endfor; ?>
                        </select>
                    </div>
                </div>
            </form>
        </div>

        <!-- Statistik Cards -->
        <div class="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-8 gap-4 mb-8">
            <div class="bg-white dark:bg-[#1a1a2e] rounded-2xl border border-slate-200 dark:border-white/5 p-4">
                <p class="text-xs text-slate-500">Total Mahasiswa</p>
                <p class="text-xl font-bold"><?php echo e(number_format($statistik['total_mahasiswa'] ?? 0)); ?></p>
            </div>
            <div class="bg-white dark:bg-[#1a1a2e] rounded-2xl border border-slate-200 dark:border-white/5 p-4">
                <p class="text-xs text-slate-500">Total Angsuran</p>
                <p class="text-xl font-bold"><?php echo e(number_format($statistik['total_angsuran'] ?? 0)); ?></p>
            </div>
            <div class="bg-green-50 dark:bg-green-900/20 rounded-2xl border border-green-200 p-4">
                <p class="text-xs text-green-600">✅ LUNAS</p>
                <p class="text-xl font-bold text-green-700"><?php echo e(number_format($statistik['total_lunas'] ?? 0)); ?></p>
            </div>
            <div class="bg-emerald-50 dark:bg-emerald-900/20 rounded-2xl border border-emerald-200 p-4">
                <p class="text-xs text-emerald-600">✅ Dibayar Bulan Ini</p>
                <p class="text-xl font-bold text-emerald-700"><?php echo e(number_format($statistik['total_dibayar_bulan_ini'] ?? 0)); ?></p>
            </div>
            <div class="bg-amber-50 dark:bg-amber-900/20 rounded-2xl border border-amber-200 p-4">
                <p class="text-xs text-amber-600">📅 Bayar Sebelumnya</p>
                <p class="text-xl font-bold text-amber-700"><?php echo e(number_format($statistik['total_bayar_bulan_sebelumnya'] ?? 0)); ?></p>
            </div>
            <div class="bg-red-50 dark:bg-red-900/20 rounded-2xl border border-red-200 p-4">
                <p class="text-xs text-red-600">⏳ Belum Bayar</p>
                <p class="text-xl font-bold text-red-700"><?php echo e(number_format($statistik['total_belum_bayar'] ?? 0)); ?></p>
            </div>
            <div class="bg-orange-50 dark:bg-orange-900/20 rounded-2xl border border-orange-200 p-4">
                <p class="text-xs text-orange-600">⚠️ Terlambat</p>
                <p class="text-xl font-bold text-orange-700"><?php echo e(number_format($statistik['total_terlambat'] ?? 0)); ?></p>
            </div>
            <div class="bg-purple-50 dark:bg-purple-900/20 rounded-2xl border border-purple-200 p-4">
                <p class="text-xs text-purple-600">📝 Status Cuti</p>
                <p class="text-xl font-bold text-purple-700"><?php echo e(number_format($statistik['total_cuti'] ?? 0)); ?></p>
            </div>
        </div>

        <!-- Detail Mahasiswa dengan Accordion Group per Tahun Ajaran -->
        <div class="bg-white dark:bg-[#1a1a2e] rounded-2xl border border-slate-200 dark:border-white/5 shadow-sm overflow-hidden">
            <div class="p-6 border-b border-slate-200 dark:border-white/10 flex justify-between items-center">
                <h3 class="text-lg font-bold text-gray-900 dark:text-white flex items-center gap-2">
                    <i data-lucide="list" class="w-5 h-5 text-violet-500"></i>
                    Detail Angsuran Mahasiswa
                </h3>
                <div class="flex items-center gap-4">
                    <label class="flex items-center gap-2 text-sm text-slate-600 dark:text-slate-400">
                        <input type="checkbox" id="selectAll" class="rounded border-slate-300 text-violet-600 focus:ring-violet-500">
                        Pilih Semua
                    </label>
                    <span class="text-sm text-slate-500" id="selectedCount">0 dipilih</span>
                </div>
            </div>
            <form id="cetakForm" action="<?php echo e(route('laporan.alokasi-angsuran.preview')); ?>" method="POST" target="_blank">
                <?php echo csrf_field(); ?>
                <input type="hidden" name="kampus_id" value="<?php echo e(request('kampus_id', '')); ?>">
                <input type="hidden" name="prodi_id" value="<?php echo e(request('prodi_id', '')); ?>">
                <input type="hidden" name="tahun_ajaran" value="<?php echo e(request('tahun_ajaran', '')); ?>">
                <input type="hidden" name="bulan" value="<?php echo e(request('bulan', date('m'))); ?>">
                <input type="hidden" name="tahun" value="<?php echo e(request('tahun', date('Y'))); ?>">

                <div class="overflow-x-auto p-4">
                    <?php
                        $groupedByTahun = $mahasiswas->groupBy('tahun_ajaran');
                    ?>

                    <?php $__currentLoopData = $groupedByTahun; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tahunAjaranGroup => $mahasiswaGroup): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <div class="mb-6">
                            <div class="bg-gradient-to-r from-violet-100 to-indigo-100 dark:from-violet-900/30 dark:to-indigo-900/30 px-6 py-3 rounded-t-xl border-b border-slate-200 dark:border-white/10">
                                <h4 class="text-base font-bold text-gray-900 dark:text-white flex items-center gap-2">
                                    <i data-lucide="calendar" class="w-5 h-5 text-violet-500"></i>
                                    Tahun Ajaran: <?php echo e($tahunAjaranGroup ?? 'Tidak Diketahui'); ?>

                                    <span class="text-sm font-normal text-slate-500">(<?php echo e($mahasiswaGroup->count()); ?> Mahasiswa)</span>
                                </h4>
                            </div>

                            <?php $__currentLoopData = $mahasiswaGroup; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $mhs): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <?php $groupId = 'group-' . $mhs->id; ?>
                                <div class="mb-4 bg-white dark:bg-gray-800/50 rounded-2xl border border-slate-200 dark:border-gray-700 overflow-hidden shadow-sm hover:shadow-md transition-all duration-200">
                                    <!-- Accordion Header -->
                                    <div class="accordion-header cursor-pointer bg-gradient-to-r from-slate-50 to-gray-50 dark:from-gray-800 dark:to-gray-900 px-6 py-4 border-b border-slate-200 dark:border-gray-700 transition-all hover:bg-slate-100 dark:hover:bg-gray-700/50"
                                         data-group-id="<?php echo e($groupId); ?>">
                                        <div class="flex flex-col md:flex-row justify-between items-start md:items-center gap-4">
                                            <div class="flex items-center gap-4 flex-1">
                                                <div class="flex items-center gap-2">
                                                    <div class="accordion-icon transition-transform duration-200">
                                                        <i data-lucide="chevron-right" class="w-5 h-5 text-slate-500"></i>
                                                    </div>
                                                    <input type="checkbox" name="selected_ids[]" value="<?php echo e($mhs->id); ?>" class="group-checkbox rounded border-slate-300 text-violet-600" data-group-id="<?php echo e($mhs->id); ?>">
                                                </div>
                                                <div class="flex items-center gap-3">
                                                    <div class="w-10 h-10 rounded-full bg-gradient-to-br from-violet-500/20 to-indigo-600/20 text-violet-600 flex items-center justify-center">
                                                        <i data-lucide="user" class="w-5 h-5"></i>
                                                    </div>
                                                    <div>
                                                        <h3 class="font-semibold text-gray-900 dark:text-white text-lg">
                                                            <?php echo e($mhs->nama); ?>

                                                        </h3>
                                                        <div class="flex flex-wrap items-center gap-3 text-xs text-slate-500 dark:text-slate-400 mt-1">
                                                            <span class="flex items-center gap-1">
                                                                <i data-lucide="id-card" class="w-3 h-3"></i>
                                                                NIM: <?php echo e($mhs->nim ?? '-'); ?>

                                                            </span>
                                                            <span class="flex items-center gap-1">
                                                                <i data-lucide="graduation-cap" class="w-3 h-3"></i>
                                                                <?php echo e($mhs->prodi->nama ?? '-'); ?>

                                                            </span>
                                                            <span class="flex items-center gap-1">
                                                                <i data-lucide="building" class="w-3 h-3"></i>
                                                                <?php echo e($mhs->kampus->nama ?? '-'); ?>

                                                            </span>
                                                            <?php if($mhs->is_cuti): ?>
                                                                <span class="px-2 py-0.5 text-xs rounded-full bg-purple-100 text-purple-700">Cuti</span>
                                                            <?php endif; ?>
                                                            <?php if(($mhs->total_potongan ?? 0) > 0): ?>
                                                                <span class="px-2 py-0.5 text-xs rounded-full bg-red-100 text-red-700">Potongan: Rp <?php echo e(number_format($mhs->total_potongan ?? 0, 0, ',', '.')); ?></span>
                                                            <?php endif; ?>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="flex flex-col items-end">
                                                <div class="text-right">
                                                    <span class="text-xs text-slate-500 dark:text-slate-400">Total Tagihan</span>
                                                    <div class="font-mono font-bold text-emerald-600 dark:text-emerald-400 text-xl">
                                                        Rp <?php echo e(number_format($mhs->total_tagihan, 0, ',', '.')); ?>

                                                    </div>
                                                    <div class="text-xs text-slate-500 dark:text-slate-400">
                                                        Sisa: Rp <?php echo e(number_format($mhs->total_sisa, 0, ',', '.')); ?>

                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <!-- Accordion Body -->
                                    <div id="<?php echo e($groupId); ?>" class="accordion-body hidden">
                                        <div class="overflow-x-auto">
                                            <table class="w-full text-sm">
                                                <thead class="bg-gray-50 dark:bg-gray-900/50">
                                                    <tr class="border-b border-slate-200 dark:border-gray-700">
                                                        <th class="py-2 px-3 text-left text-xs font-semibold">Kode</th>
                                                        <th class="py-2 px-3 text-left text-xs font-semibold">Komponen</th>
                                                        <th class="py-2 px-3 text-center text-xs font-semibold">Sem</th>
                                                        <th class="py-2 px-3 text-right text-xs font-semibold">Total Asli</th>
                                                        <th class="py-2 px-3 text-right text-xs font-semibold">Potongan</th>
                                                        <th class="py-2 px-3 text-right text-xs font-semibold">Total</th>
                                                        <th class="py-2 px-3 text-right text-xs font-semibold">Dibayar</th>
                                                        <th class="py-2 px-3 text-right text-xs font-semibold">Sisa</th>
                                                        <th class="py-2 px-3 text-center text-xs font-semibold">Status</th>
                                                        <th class="py-2 px-3 text-center text-xs font-semibold">Tgl Jatuh Tempo</th>
                                                        <th class="py-2 px-3 text-center text-xs font-semibold">Tgl Bayar</th>
                                                    </tr>
                                                </thead>
                                                <tbody class="divide-y divide-slate-100 dark:divide-gray-800">
                                                    <?php $__empty_1 = true; $__currentLoopData = $mhs->detail_angsuran; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $detail): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                                    <tr class="hover:bg-slate-50 dark:hover:bg-gray-800/30 transition-colors">
                                                        <td class="py-2 px-3 font-mono text-xs"><?php echo e($detail['kode_biaya']); ?></td>
                                                        <td class="py-2 px-3"><?php echo e($detail['komponen']); ?></td>
                                                        <td class="py-2 px-3 text-center"><?php echo e($detail['semester']); ?></td>
                                                        <td class="py-2 px-3 text-right">
                                                            <?php if(($detail['total_asli'] ?? $detail['total']) != $detail['total']): ?>
                                                                <span class="line-through text-slate-400">Rp <?php echo e(number_format($detail['total_asli'] ?? $detail['total'], 0, ',', '.')); ?></span>
                                                            <?php else: ?>
                                                                Rp <?php echo e(number_format($detail['total'], 0, ',', '.')); ?>

                                                            <?php endif; ?>
                                                        </td>
                                                        <td class="py-2 px-3 text-right text-red-600">
                                                            <?php if(($detail['potongan'] ?? 0) > 0): ?>
                                                                -Rp <?php echo e(number_format($detail['potongan'], 0, ',', '.')); ?>

                                                            <?php else: ?>
                                                                -
                                                            <?php endif; ?>
                                                        </td>
                                                        <td class="py-2 px-3 text-right">Rp <?php echo e(number_format($detail['total'], 0, ',', '.')); ?></td>
                                                        <td class="py-2 px-3 text-right">Rp <?php echo e(number_format($detail['dibayar'], 0, ',', '.')); ?></td>
                                                        <td class="py-2 px-3 text-right font-bold text-red-600">Rp <?php echo e(number_format($detail['sisa'], 0, ',', '.')); ?></td>
                                                        <td class="py-2 px-3 text-center">
                                                            <span class="px-2 py-0.5 text-xs rounded-full" style="background: <?php echo e($detail['status_color']); ?>20; color: <?php echo e($detail['status_color']); ?>">
                                                                <?php echo e($detail['status_text']); ?>

                                                            </span>
                                                        </td>
                                                        <td class="py-2 px-3 text-center"><?php echo e($detail['tanggal_angsuran'] ? date('d/m/Y', strtotime($detail['tanggal_angsuran'])) : '-'); ?></td>
                                                        <td class="py-2 px-3 text-center"><?php echo e($detail['tanggal_bayar'] ? date('d/m/Y', strtotime($detail['tanggal_bayar'])) : '-'); ?></td>
                                                    <tr>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                                    <tr>
                                                        <td colspan="11" class="py-4 text-center text-slate-500 text-xs">
                                                            Tidak ada data angsuran (selain angsuran pertama)
                                                        </td>
                                                    </tr>
                                                    <?php endif; ?>
                                                </tbody>
                                                <tfoot class="bg-gray-50 dark:bg-gray-900/50 border-t border-slate-200 dark:border-gray-700 text-xs">
                                                    <tr>
                                                        <td colspan="7" class="py-2 px-3 text-right font-medium">Total Tagihan:</td>
                                                        <td class="py-2 px-3 text-right font-bold">Rp <?php echo e(number_format($mhs->total_tagihan, 0, ',', '.')); ?></td>
                                                        <td colspan="3"></td>
                                                    </tr>
                                                    <tr>
                                                        <td colspan="7" class="py-2 px-3 text-right font-medium">Total Dibayar:</td>
                                                        <td class="py-2 px-3 text-right">Rp <?php echo e(number_format($mhs->total_dibayar, 0, ',', '.')); ?></td>
                                                        <td colspan="3"></td>
                                                    </tr>
                                                    <tr class="bg-red-50 dark:bg-red-900/10">
                                                        <td colspan="7" class="py-2 px-3 text-right font-medium text-red-600">Sisa Tagihan:</td>
                                                        <td class="py-2 px-3 text-right font-bold text-red-600">Rp <?php echo e(number_format($mhs->total_sisa, 0, ',', '.')); ?></td>
                                                        <td colspan="3"></td>
                                                    </tr>
                                                </tfoot>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
                <input type="hidden" name="selected_ids" id="selectedIdsInput">
            </form>
            <div class="p-4 border-t border-slate-200 dark:border-white/10 flex justify-between items-center">
                <div>
                    <?php echo e($mahasiswas->appends(request()->query())->links()); ?>

                </div>
                <button type="button" id="cetakSelectedBtnFooter"
                    class="px-4 py-2 bg-red-500 hover:bg-red-600 text-white rounded-xl text-sm font-medium transition-all flex items-center gap-2">
                    <i data-lucide="file-text" class="w-4 h-4"></i>
                    Cetak PDF
                </button>
            </div>
        </div>
    </div>

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

            // Accordion functionality
            const accordionHeaders = document.querySelectorAll('.accordion-header');

            function toggleAccordion(header) {
                const groupId = header.dataset.groupId;
                const body = document.getElementById(groupId);
                const icon = header.querySelector('.accordion-icon i');

                if (body.classList.contains('hidden')) {
                    body.classList.remove('hidden');
                    if (icon) {
                        icon.setAttribute('data-lucide', 'chevron-down');
                    }
                } else {
                    body.classList.add('hidden');
                    if (icon) {
                        icon.setAttribute('data-lucide', 'chevron-right');
                    }
                }
                lucide.createIcons();
            }

            accordionHeaders.forEach(header => {
                header.addEventListener('click', function(e) {
                    if (e.target.type === 'checkbox' || e.target.closest('.group-checkbox')) {
                        return;
                    }
                    toggleAccordion(this);
                });
            });

            // Select All functionality
            const selectAllTable = document.getElementById('selectAll');
            const rowCheckboxes = document.querySelectorAll('.group-checkbox');
            const selectedCountSpan = document.getElementById('selectedCount');
            const selectedIdsInput = document.getElementById('selectedIdsInput');
            const cetakForm = document.getElementById('cetakForm');

            function updateSelectedCount() {
                const checked = document.querySelectorAll('.group-checkbox:checked');
                const count = checked.length;
                if (selectedCountSpan) {
                    selectedCountSpan.textContent = count + ' dipilih';
                }
                const selectedIds = Array.from(checked).map(cb => cb.value);
                selectedIdsInput.value = selectedIds.join(',');
            }

            if (selectAllTable) {
                selectAllTable.addEventListener('change', function() {
                    rowCheckboxes.forEach(cb => {
                        cb.checked = selectAllTable.checked;
                    });
                    updateSelectedCount();
                });
            }

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

            updateSelectedCount();

            function cetakPDF() {
                const checked = document.querySelectorAll('.group-checkbox:checked');
                const selectedIds = Array.from(checked).map(cb => cb.value);

                if (selectedIds.length === 0) {
                    const allIds = Array.from(rowCheckboxes).map(cb => cb.value);
                    selectedIdsInput.value = allIds.join(',');
                } else {
                    selectedIdsInput.value = selectedIds.join(',');
                }
                cetakForm.submit();
            }

            const cetakBtn = document.getElementById('cetakSelectedBtnFooter');
            if (cetakBtn) {
                cetakBtn.addEventListener('click', cetakPDF);
            }

            const cetakBtnTop = document.getElementById('cetakSelectedBtn');
            if (cetakBtnTop) {
                cetakBtnTop.addEventListener('click', cetakPDF);
            }

            // Auto submit filter untuk Kampus, Prodi, Tahun Ajaran SAJA (Bulan dan Tahun tidak auto submit)
            const filterForm = document.getElementById('filterForm');
            const autoSubmitFilters = ['kampus_filter', 'prodi_filter', 'tahun_ajaran_filter'];

            autoSubmitFilters.forEach(filterId => {
                const element = document.getElementById(filterId);
                if (element) {
                    element.addEventListener('change', function() {
                        filterForm.submit();
                    });
                }
            });

            // Filter Prodi by Kampus
            const kampusFilter = document.getElementById('kampus_filter');
            const prodiFilter = document.getElementById('prodi_filter');
            const originalProdiHtml = prodiFilter ? prodiFilter.innerHTML : '';

            if (kampusFilter && prodiFilter) {
                kampusFilter.addEventListener('change', function() {
                    const kampusId = this.value;
                    if (kampusId) {
                        prodiFilter.disabled = true;
                        prodiFilter.innerHTML = '<option value="">Memuat...</option>';

                        fetch(`/get-prodi/${kampusId}`)
                            .then(response => response.json())
                            .then(data => {
                                prodiFilter.innerHTML = '<option value="">Semua Prodi</option>';
                                if (data && data.length > 0) {
                                    data.forEach(prodi => {
                                        const option = document.createElement('option');
                                        option.value = prodi.id;
                                        option.textContent = prodi.nama;
                                        prodiFilter.appendChild(option);
                                    });
                                }
                                prodiFilter.disabled = false;
                            })
                            .catch(error => {
                                console.error('Error:', error);
                                prodiFilter.innerHTML = '<option value="">Semua Prodi</option>';
                                prodiFilter.disabled = false;
                            });
                    } else {
                        prodiFilter.innerHTML = originalProdiHtml;
                        prodiFilter.disabled = false;
                    }
                });
            }
        });
    </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 C:\Users\User\Documents\K2-PROJECTS\k2-sipema\resources\views/laporan/alokasi-angsuran.blade.php ENDPATH**/ ?>