<?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([]); ?>
    <!-- Dynamic Header -->
    <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">
                        Daftar Mahasiswa
                    </span>
                </h1>
                <p class="text-slate-500 dark:text-slate-400 text-sm pl-1">
                    <i data-lucide="users" class="w-4 h-4 inline mr-2"></i>
                    Kelola data mahasiswa dan rencana angsurannya
                </p>
            </div>

            <div class="flex items-center gap-4">
                <?php
                    $userRole = Auth::user()->role->name;
                    $canCreateMahasiswa = in_array($userRole, ['superadmin', 'admin', 'marketing', 'telemarketing']);
                    $canEditMahasiswa = in_array($userRole, ['superadmin', 'admin', 'validator']);
                ?>

                <?php if($canCreateMahasiswa): ?>
                    <a href="<?php echo e(route('mahasiswa.create')); ?>"
                        class="px-4 py-2.5 bg-gradient-to-r from-violet-600 to-indigo-700 text-white rounded-xl text-sm font-medium hover:shadow-lg hover:shadow-violet-500/25 transition-all flex items-center gap-2 shadow-sm">
                        <i data-lucide="plus" class="w-4 h-4"></i>
                        <span>Tambah Mahasiswa</span>
                    </a>
                <?php endif; ?>
            </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 animate-fade-in">
                <div
                    class="w-10 h-10 rounded-xl bg-green-500/10 text-green-500 flex items-center justify-center flex-shrink-0">
                    <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 animate-fade-in">
                <div
                    class="w-10 h-10 rounded-xl bg-red-500/10 text-red-500 flex items-center justify-center flex-shrink-0">
                    <i data-lucide="alert-circle" 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; ?>

        <!-- Main Card -->
        <div class="group relative">
            <div
                class="absolute -inset-1 bg-gradient-to-r from-violet-600/10 to-indigo-600/10 rounded-3xl blur opacity-0 group-hover:opacity-30 transition duration-500">
            </div>
            <div
                class="relative bg-white dark:bg-[#1a1a2e] rounded-3xl border border-slate-200 dark:border-white/5 shadow-xl overflow-hidden">

                <!-- Card Header -->
                <div class="p-6 border-b border-slate-100 dark:border-white/5">
                    <div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
                        <div>
                            <h3 class="text-xl font-bold text-gray-900 dark:text-white">Data Mahasiswa</h3>
                            <p class="text-sm text-slate-500 dark:text-slate-400 mt-1">Kelola data mahasiswa dan rencana
                                angsurannya</p>
                        </div>
                        <div class="text-sm text-slate-500 dark:text-slate-400">
                            Total: <span
                                class="font-bold text-violet-600 dark:text-violet-400"><?php echo e($mahasiswas->total()); ?></span>
                            mahasiswa
                        </div>
                    </div>
                </div>

                <!-- Filter Section -->
                <div class="p-6 border-b border-slate-100 dark:border-white/5 bg-slate-50/50 dark:bg-white/5">
                    <form method="GET" action="<?php echo e(route('mahasiswa.index')); ?>" class="space-y-4">
                        <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                            <!-- Search Input -->
                            <div>
                                <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
                                    Cari Mahasiswa
                                </label>
                                <div class="relative">
                                    <i data-lucide="search"
                                        class="absolute left-4 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, nama, prodi, atau kampus..."
                                        class="w-full pl-12 pr-4 py-3 bg-white dark:bg-gray-800 border border-slate-200 dark:border-gray-700 rounded-xl text-gray-700 dark:text-gray-300 placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-violet-500 focus:border-transparent transition-all"
                                        onkeyup="this.form.dispatchEvent(new Event('input', { bubbles: true }))">
                                </div>
                            </div>

                            <!-- Kampus Filter - Hanya untuk role selain marketing -->
                            <?php if(Auth::user()->role->name != 'marketing'): ?>
                                <div>
                                    <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
                                        Filter Kampus
                                    </label>
                                    <div class="relative">
                                        <i data-lucide="school"
                                            class="absolute left-4 top-1/2 transform -translate-y-1/2 w-4 h-4 text-slate-400"></i>
                                        <select name="kampus_id" id="filterKampus" onchange="this.form.submit()"
                                            class="w-full pl-12 pr-4 py-3 bg-white dark:bg-gray-800 border border-slate-200 dark:border-gray-700 rounded-xl text-gray-700 dark:text-gray-300 placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-violet-500 focus:border-transparent transition-all appearance-none cursor-pointer">
                                            <option value="">Semua Kampus</option>
                                            <?php $__currentLoopData = $kampus; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $k): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option value="<?php echo e($k->id); ?>"
                                                    <?php echo e(request('kampus_id') == $k->id ? 'selected' : ''); ?>>
                                                    <?php echo e($k->nama); ?>

                                                </option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </select>
                                        <i data-lucide="chevron-down"
                                            class="absolute right-4 top-1/2 transform -translate-y-1/2 w-4 h-4 text-slate-400 pointer-events-none"></i>
                                    </div>
                                </div>
                            <?php endif; ?>

                            <!-- Prodi Filter -->
                            <div>
                                <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
                                    Filter Program Studi
                                </label>
                                <div class="relative">
                                    <i data-lucide="book-open"
                                        class="absolute left-4 top-1/2 transform -translate-y-1/2 w-4 h-4 text-slate-400"></i>
                                    <select name="prodi_id" id="filterProdi" onchange="this.form.submit()"
                                        class="w-full pl-12 pr-4 py-3 bg-white dark:bg-gray-800 border border-slate-200 dark:border-gray-700 rounded-xl text-gray-700 dark:text-gray-300 placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-violet-500 focus:border-transparent transition-all appearance-none cursor-pointer">
                                        <option value="">Semua Program Studi</option>
                                        <?php $__currentLoopData = $prodi; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $p): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <option value="<?php echo e($p->id); ?>"
                                                <?php echo e(request('prodi_id') == $p->id ? 'selected' : ''); ?>>
                                                <?php echo e($p->nama); ?>

                                            </option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                    <i data-lucide="chevron-down"
                                        class="absolute right-4 top-1/2 transform -translate-y-1/2 w-4 h-4 text-slate-400 pointer-events-none"></i>
                                </div>
                            </div>
                        </div>

                        <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                            <!-- Angkatan Filter -->
                            <div>
                                <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
                                    Filter Angkatan
                                </label>
                                <div class="relative">
                                    <i data-lucide="calendar"
                                        class="absolute left-4 top-1/2 transform -translate-y-1/2 w-4 h-4 text-slate-400"></i>
                                    <select name="angkatan" onchange="this.form.submit()"
                                        class="w-full pl-12 pr-4 py-3 bg-white dark:bg-gray-800 border border-slate-200 dark:border-gray-700 rounded-xl text-gray-700 dark:text-gray-300 placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-violet-500 focus:border-transparent transition-all appearance-none cursor-pointer">
                                        <option value="">Semua Angkatan</option>
                                        <?php $__currentLoopData = $angkatanList; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $year): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <option value="<?php echo e($year); ?>"
                                                <?php echo e(request('angkatan') == $year ? 'selected' : ''); ?>>
                                                <?php echo e($year); ?>

                                            </option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                    <i data-lucide="chevron-down"
                                        class="absolute right-4 top-1/2 transform -translate-y-1/2 w-4 h-4 text-slate-400 pointer-events-none"></i>
                                </div>
                            </div>

                            <!-- Status Rencana Filter -->
                            <div>
                                <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
                                    Filter Status Rencana
                                </label>
                                <div class="relative">
                                    <i data-lucide="clock"
                                        class="absolute left-4 top-1/2 transform -translate-y-1/2 w-4 h-4 text-slate-400"></i>
                                    <select name="status_rencana" onchange="this.form.submit()"
                                        class="w-full pl-12 pr-4 py-3 bg-white dark:bg-gray-800 border border-slate-200 dark:border-gray-700 rounded-xl text-gray-700 dark:text-gray-300 placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-violet-500 focus:border-transparent transition-all appearance-none cursor-pointer">
                                        <option value="">Semua Status</option>
                                        <option value="belum_ada"
                                            <?php echo e(request('status_rencana') == 'belum_ada' ? 'selected' : ''); ?>>
                                            Belum Ada Rencana
                                        </option>
                                        <option value="pending"
                                            <?php echo e(request('status_rencana') == 'pending' ? 'selected' : ''); ?>>
                                            Menunggu Validasi
                                        </option>
                                        <option value="valid"
                                            <?php echo e(request('status_rencana') == 'valid' ? 'selected' : ''); ?>>
                                            Rencana Valid
                                        </option>
                                    </select>
                                    <i data-lucide="chevron-down"
                                        class="absolute right-4 top-1/2 transform -translate-y-1/2 w-4 h-4 text-slate-400 pointer-events-none"></i>
                                </div>
                            </div>

                            <!-- Action Buttons -->
                            <div class="flex items-end gap-2">
                                <button type="submit"
                                    class="h-[42px] px-4 bg-gradient-to-r from-violet-600 to-indigo-700 text-white rounded-xl 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>
                                    <span>Terapkan Filter</span>
                                </button>

                                <?php if(request()->hasAny(['search', 'kampus_id', 'prodi_id', 'angkatan', 'status_rencana'])): ?>
                                    <a href="<?php echo e(route('mahasiswa.index')); ?>"
                                        class="h-[42px] px-4 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">
                                        <i data-lucide="x" class="w-4 h-4"></i>
                                        <span>Reset Filter</span>
                                    </a>
                                <?php endif; ?>
                            </div>
                        </div>

                        <!-- Active Filters -->
                        <?php if(request()->hasAny(['search', 'kampus_id', 'prodi_id', 'angkatan', 'status_rencana'])): ?>
                            <div class="flex items-center gap-3">
                                <span class="text-sm font-medium text-slate-500 dark:text-slate-400">Filter
                                    Aktif:</span>
                                <div class="flex flex-wrap gap-2">
                                    <?php if(request('search')): ?>
                                        <span
                                            class="inline-flex items-center gap-1 px-3 py-1 bg-violet-500/10 text-violet-600 dark:text-violet-400 rounded-lg text-xs font-medium">
                                            <i data-lucide="search" class="w-3 h-3"></i>
                                            "<?php echo e(request('search')); ?>"
                                            <a href="<?php echo e(route('mahasiswa.index', array_merge(request()->except('search'), ['search' => '']))); ?>"
                                                class="text-violet-400 hover:text-violet-500">
                                                <i data-lucide="x" class="w-3 h-3"></i>
                                            </a>
                                        </span>
                                    <?php endif; ?>

                                    <?php if(request('kampus_id')): ?>
                                        <?php
                                            $selectedKampus = $kampus->firstWhere('id', request('kampus_id'));
                                        ?>
                                        <?php if($selectedKampus): ?>
                                            <span
                                                class="inline-flex items-center gap-1 px-3 py-1 bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-lg text-xs font-medium">
                                                <i data-lucide="school" class="w-3 h-3"></i>
                                                <?php echo e($selectedKampus->nama); ?>

                                                <a href="<?php echo e(route('mahasiswa.index', array_merge(request()->except('kampus_id'), ['kampus_id' => '']))); ?>"
                                                    class="text-blue-400 hover:text-blue-500">
                                                    <i data-lucide="x" class="w-3 h-3"></i>
                                                </a>
                                            </span>
                                        <?php endif; ?>
                                    <?php endif; ?>

                                    <?php if(request('prodi_id')): ?>
                                        <?php
                                            $selectedProdi = $prodi->firstWhere('id', request('prodi_id'));
                                        ?>
                                        <?php if($selectedProdi): ?>
                                            <span
                                                class="inline-flex items-center gap-1 px-3 py-1 bg-purple-500/10 text-purple-600 dark:text-purple-400 rounded-lg text-xs font-medium">
                                                <i data-lucide="book-open" class="w-3 h-3"></i>
                                                <?php echo e($selectedProdi->nama); ?>

                                                <a href="<?php echo e(route('mahasiswa.index', array_merge(request()->except('prodi_id'), ['prodi_id' => '']))); ?>"
                                                    class="text-purple-400 hover:text-purple-500">
                                                    <i data-lucide="x" class="w-3 h-3"></i>
                                                </a>
                                            </span>
                                        <?php endif; ?>
                                    <?php endif; ?>

                                    <?php if(request('angkatan')): ?>
                                        <span
                                            class="inline-flex items-center gap-1 px-3 py-1 bg-amber-500/10 text-amber-600 dark:text-amber-400 rounded-lg text-xs font-medium">
                                            <i data-lucide="calendar" class="w-3 h-3"></i>
                                            <?php echo e(request('angkatan')); ?>

                                            <a href="<?php echo e(route('mahasiswa.index', array_merge(request()->except('angkatan'), ['angkatan' => '']))); ?>"
                                                class="text-amber-400 hover:text-amber-500">
                                                <i data-lucide="x" class="w-3 h-3"></i>
                                            </a>
                                        </span>
                                    <?php endif; ?>

                                    <?php if(request('status_rencana')): ?>
                                        <?php
                                            $statusLabels = [
                                                'belum_ada' => 'Belum Ada Rencana',
                                                'pending' => 'Menunggu Validasi',
                                                'valid' => 'Rencana Valid',
                                            ];
                                        ?>
                                        <span
                                            class="inline-flex items-center gap-1 px-3 py-1 bg-slate-500/10 text-slate-600 dark:text-slate-400 rounded-lg text-xs font-medium">
                                            <i data-lucide="clock" class="w-3 h-3"></i>
                                            <?php echo e($statusLabels[request('status_rencana')] ?? request('status_rencana')); ?>

                                            <a href="<?php echo e(route('mahasiswa.index', array_merge(request()->except('status_rencana'), ['status_rencana' => '']))); ?>"
                                                class="text-slate-400 hover:text-slate-500">
                                                <i data-lucide="x" class="w-3 h-3"></i>
                                            </a>
                                        </span>
                                    <?php endif; ?>
                                </div>
                            </div>
                        <?php endif; ?>
                    </form>
                </div>

                <!-- Table Section -->
                <div class="overflow-x-auto">
                    <table class="w-full text-sm">
                        <thead>
                            <tr class="bg-slate-50/50 dark:bg-white/5 border-b border-slate-100 dark:border-white/5">
                                <th
                                    class="text-left py-3 px-4 text-xs font-semibold text-slate-500 dark:text-slate-400 uppercase tracking-wider w-[100px]">
                                    NIM</th>
                                <th
                                    class="text-left py-3 px-4 text-xs font-semibold text-slate-500 dark:text-slate-400 uppercase tracking-wider">
                                    Nama</th>
                                <th
                                    class="text-left py-3 px-4 text-xs font-semibold text-slate-500 dark:text-slate-400 uppercase tracking-wider">
                                    Prodi</th>
                                <th
                                    class="text-left py-3 px-4 text-xs font-semibold text-slate-500 dark:text-slate-400 uppercase tracking-wider w-[120px]">
                                    Tahun Ajaran</th>
                                <th
                                    class="text-left py-3 px-4 text-xs font-semibold text-slate-500 dark:text-slate-400 uppercase tracking-wider w-[140px]">
                                    Status Rencana</th>
                                <th
                                    class="text-left py-3 px-4 text-xs font-semibold text-slate-500 dark:text-slate-400 uppercase tracking-wider w-[180px]">
                                    Aksi</th>
                            </tr>
                        </thead>
                        <tbody class="divide-y divide-slate-100 dark:divide-white/5">
                            <?php $__empty_1 = true; $__currentLoopData = $mahasiswas; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $m): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <?php
                                    $rencana = $m->angsuran;
                                ?>
                                <tr class="hover:bg-slate-50/50 dark:hover:bg-white/5 transition-colors">
                                    <td class="py-2 px-4">
                                        <span
                                            class="inline-flex items-center justify-center px-2 py-1 bg-slate-100 dark:bg-gray-800 text-slate-600 dark:text-slate-400 rounded-md text-xs font-mono font-medium">
                                            <?php echo e($m->nim); ?>

                                        </span>
                                    </td>
                                    <td class="py-2 px-4">
                                        <div class="flex items-center gap-2">
                                            <div
                                                class="w-7 h-7 rounded-lg bg-gradient-to-br from-blue-500/10 to-cyan-600/10 text-blue-500 flex items-center justify-center flex-shrink-0">
                                                <i data-lucide="user" class="w-3.5 h-3.5"></i>
                                            </div>
                                            <div>
                                                <div class="font-medium text-gray-900 dark:text-white text-sm">
                                                    <?php echo e($m->nama); ?></div>
                                                <div class="text-xs text-slate-500 dark:text-slate-400">
                                                    <?php echo e($m->prodi->kampus->nama ?? '-'); ?></div>
                                            </div>
                                        </div>
                                    </td>
                                    <td class="py-2 px-4">
                                        <div class="flex items-center gap-1.5">
                                            <?php if($m->prodi && $m->prodi->jenjang): ?>
                                                <span
                                                    class="inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400 whitespace-nowrap flex-shrink-0">
                                                    <?php echo e($m->prodi->jenjang); ?>

                                                </span>
                                            <?php endif; ?>
                                            <span class="text-sm text-gray-900 dark:text-white truncate">
                                                <?php echo e($m->prodi->nama ?? '-'); ?>

                                            </span>
                                        </div>
                                    </td>
                                    <td class="py-2 px-4">
                                        <span
                                            class="inline-flex items-center gap-1 px-2 py-1 bg-amber-500/10 text-amber-600 dark:text-amber-400 rounded-md text-xs font-medium">
                                            <i data-lucide="calendar" class="w-3 h-3"></i>
                                            <?php echo e($m->tahun_ajaran); ?>

                                        </span>
                                    </td>
                                    <td class="py-2 px-4">
                                        <?php if(!$rencana): ?>
                                            <span
                                                class="inline-flex items-center gap-1 px-2 py-1 bg-slate-500/10 text-slate-600 dark:text-slate-400 rounded-md text-xs font-medium">
                                                <i data-lucide="clock" class="w-3 h-3"></i>
                                                Belum Ada
                                            </span>
                                        <?php elseif($rencana->status_rencana === 'pending'): ?>
                                            <span
                                                class="inline-flex items-center gap-1 px-2 py-1 bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-md text-xs font-medium">
                                                <i data-lucide="hourglass" class="w-3 h-3"></i>
                                                Menunggu Validasi
                                            </span>
                                        <?php elseif($rencana->status_rencana === 'valid'): ?>
                                            <a href="<?php echo e(route('angsuran.show', $rencana->id)); ?>" target="_blank"
                                                class="inline-flex items-center gap-1 px-2 py-1 bg-green-500/10 text-green-600 dark:text-green-400 rounded-md text-xs font-medium hover:bg-green-500/20 transition-colors">
                                                <i data-lucide="check-circle" class="w-3 h-3"></i>
                                                Lihat Rencana
                                            </a>
                                        <?php endif; ?>
                                    </td>
                                    <td class="py-2 px-4">
                                        <div class="flex items-center gap-1.5">
                                            <!-- Detail Button (semua role bisa lihat) -->
                                            <a href="<?php echo e(route('mahasiswa.show', $m->id)); ?>"
                                                class="w-7 h-7 flex items-center justify-center bg-slate-100 dark:bg-gray-800 text-slate-600 dark:text-slate-400 hover:bg-slate-200 dark:hover:bg-gray-700 rounded-md transition-colors"
                                                title="Detail">
                                                <i data-lucide="eye" class="w-3.5 h-3.5"></i>
                                            </a>

                                            <!-- Edit Button - hanya untuk validator, superadmin, admin -->
                                            <?php if($canEditMahasiswa): ?>
                                                <a href="<?php echo e(route('mahasiswa.edit', $m->id)); ?>"
                                                    class="w-7 h-7 flex items-center justify-center bg-slate-100 dark:bg-gray-800 text-slate-600 dark:text-slate-400 hover:bg-slate-200 dark:hover:bg-gray-700 rounded-md transition-colors"
                                                    title="Edit">
                                                    <i data-lucide="edit-2" class="w-3.5 h-3.5"></i>
                                                </a>
                                            <?php endif; ?>

                                            <!-- Generate Angsuran Button - hanya untuk marketing, penagihan, superadmin, admin -->
                                            <?php if(!$rencana && in_array($userRole, ['superadmin', 'admin', 'marketing', 'penagihan'])): ?>
                                                <button
                                                    onclick="openGenerateModal(<?php echo e($m->id); ?>, '<?php echo e(addslashes($m->nama)); ?>')"
                                                    class="w-7 h-7 flex items-center justify-center bg-green-500/10 text-green-600 dark:text-green-400 hover:bg-green-500/20 rounded-md transition-colors"
                                                    title="Generate Rencana Angsuran">
                                                    <i data-lucide="cog" class="w-3.5 h-3.5"></i>
                                                </button>
                                            <?php endif; ?>

                                            <!-- Delete Button - hanya untuk validator, superadmin, admin -->
                                            <?php if($canEditMahasiswa): ?>
                                                <button
                                                    onclick="deleteMahasiswa(<?php echo e($m->id); ?>, '<?php echo e(addslashes($m->nama)); ?>')"
                                                    class="w-7 h-7 flex items-center justify-center bg-red-500/10 text-red-600 dark:text-red-400 hover:bg-red-500/20 rounded-md transition-colors"
                                                    title="Hapus">
                                                    <i data-lucide="trash-2" class="w-3.5 h-3.5"></i>
                                                </button>
                                                <form id="delete-form-<?php echo e($m->id); ?>"
                                                    action="<?php echo e(route('mahasiswa.destroy', $m->id)); ?>" method="POST"
                                                    class="hidden">
                                                    <?php echo csrf_field(); ?>
                                                    <?php echo method_field('DELETE'); ?>
                                                </form>
                                            <?php endif; ?>
                                        </div>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="6" class="py-8 px-4 text-center">
                                        <div
                                            class="w-12 h-12 mx-auto mb-3 rounded-full bg-slate-100 dark:bg-gray-800 flex items-center justify-center">
                                            <i data-lucide="users"
                                                class="w-6 h-6 text-slate-400 dark:text-slate-500"></i>
                                        </div>
                                        <h4 class="text-base font-medium text-gray-900 dark:text-white mb-1">
                                            <?php if(request()->hasAny(['search', 'kampus_id', 'prodi_id', 'angkatan', 'status_rencana'])): ?>
                                                Tidak ada data mahasiswa yang sesuai dengan filter
                                            <?php else: ?>
                                                Belum ada data mahasiswa
                                            <?php endif; ?>
                                        </h4>
                                        <p class="text-sm text-slate-500 dark:text-slate-400">
                                            <?php if(request()->hasAny(['search', 'kampus_id', 'prodi_id', 'angkatan', 'status_rencana'])): ?>
                                                Coba gunakan filter lain atau <a href="<?php echo e(route('mahasiswa.index')); ?>"
                                                    class="text-violet-600 dark:text-violet-400 hover:underline">reset
                                                    filter</a>
                                            <?php else: ?>
                                                Mulai dengan menambahkan mahasiswa baru
                                            <?php endif; ?>
                                        </p>
                                        <?php if(!request()->hasAny(['search', 'kampus_id', 'prodi_id', 'angkatan', 'status_rencana'])): ?>
                                            <?php if($canCreateMahasiswa): ?>
                                                <a href="<?php echo e(route('mahasiswa.create')); ?>"
                                                    class="inline-flex items-center gap-2 px-3 py-1.5 mt-3 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">
                                                    <i data-lucide="plus" class="w-3.5 h-3.5"></i>
                                                    Tambah Mahasiswa Pertama
                                                </a>
                                            <?php endif; ?>
                                        <?php endif; ?>
                                    </td>
                                </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>

                <!-- Pagination -->
                <?php if($mahasiswas->hasPages()): ?>
                    <div class="p-6 border-t border-slate-100 dark:border-white/5">
                        <div class="flex flex-col sm:flex-row justify-between items-center gap-4">
                            <div class="text-sm text-slate-500 dark:text-slate-400">
                                Menampilkan <?php echo e($mahasiswas->firstItem()); ?> - <?php echo e($mahasiswas->lastItem()); ?> dari
                                <?php echo e($mahasiswas->total()); ?> data
                            </div>
                            <div class="flex items-center gap-2">
                                <?php echo e($mahasiswas->appends(request()->query())->links('vendor.pagination.tailwind')); ?>

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

    <!-- Modal Generate Angsuran -->
    <div id="generateModal" class="fixed inset-0 z-50 hidden overflow-y-auto" aria-labelledby="modal-title"
        role="dialog" aria-modal="true">
        <div class="flex items-center justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
            <!-- Background overlay -->
            <div class="fixed inset-0 bg-gray-500 bg-opacity-75 dark:bg-gray-900 dark:bg-opacity-75 transition-opacity"
                aria-hidden="true" onclick="closeGenerateModal()"></div>

            <!-- Modal panel -->
            <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 items-center gap-4 mb-4">
                        <div
                            class="w-12 h-12 rounded-xl bg-green-500/10 text-green-500 flex items-center justify-center">
                            <i data-lucide="calendar" class="w-6 h-6"></i>
                        </div>
                        <div>
                            <h3 class="text-lg font-bold text-gray-900 dark:text-white">Generate Rencana Angsuran</h3>
                            <p class="text-sm text-slate-500 dark:text-slate-400" id="generateModalSubtitle"></p>
                        </div>
                    </div>

                    <form id="generateForm" method="GET" class="space-y-4">
                        <div class="bg-slate-50 dark:bg-white/5 p-4 rounded-xl">
                            <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
                                Pilih Tanggal Awal Angsuran <span class="text-red-500">*</span>
                            </label>
                            <div class="relative">
                                <i data-lucide="calendar"
                                    class="absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-slate-400"></i>
                                <input type="date" name="tanggal_awal" id="tanggal_awal" required
                                    class="w-full pl-10 pr-3 py-2 bg-white dark:bg-gray-700 border border-slate-200 dark:border-gray-600 rounded-lg text-gray-700 dark:text-gray-300 focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-transparent">
                            </div>
                            <p class="text-xs text-slate-500 dark:text-slate-400 mt-2">
                                <i data-lucide="info" class="w-3 h-3 inline"></i>
                                Tanggal ini akan digunakan sebagai tanggal angsuran pertama
                            </p>
                        </div>

                        <!-- Info Box -->
                        <div class="bg-blue-50 dark:bg-blue-900/20 p-3 rounded-lg">
                            <div class="flex items-start gap-2">
                                <i data-lucide="info"
                                    class="w-4 h-4 text-blue-500 dark:text-blue-400 flex-shrink-0 mt-0.5"></i>
                                <p class="text-xs text-blue-700 dark:text-blue-300">
                                    Tanggal-tanggal berikutnya akan dihitung otomatis per bulan setelah angsuran
                                    pertama.
                                </p>
                            </div>
                        </div>

                        <div class="flex justify-end gap-3 pt-4 border-t border-slate-100 dark:border-white/5">
                            <button type="button" onclick="closeGenerateModal()"
                                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">
                                Batal
                            </button>
                            <button type="submit"
                                class="px-4 py-2 bg-gradient-to-r from-green-600 to-emerald-700 text-white rounded-lg text-sm font-medium hover:shadow-lg hover:shadow-green-500/25 transition-all flex items-center gap-2">
                                <i data-lucide="play" class="w-4 h-4"></i>
                                Generate Rencana
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>

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

            // Search dengan debounce
            let searchTimeout;
            const searchInput = document.querySelector('input[name="search"]');

            if (searchInput) {
                searchInput.addEventListener('input', function() {
                    clearTimeout(searchTimeout);
                    searchTimeout = setTimeout(() => {
                        this.form.submit();
                    }, 500);
                });
            }

            // Dynamic Prodi Filter berdasarkan Kampus yang dipilih
            const kampusSelect = document.getElementById('filterKampus');
            const prodiSelect = document.getElementById('filterProdi');

            if (kampusSelect && prodiSelect) {
                function loadProdiForFilter(kampusId) {
                    if (!kampusId) {
                        prodiSelect.innerHTML = '<option value="">Semua Program Studi</option>';
                        return;
                    }

                    const currentValue = prodiSelect.value;

                    fetch(`/get-prodi-by-kampus/${kampusId}`)
                        .then(response => response.json())
                        .then(data => {
                            prodiSelect.innerHTML = '<option value="">Semua Program Studi</option>';

                            data.forEach(prodi => {
                                const option = document.createElement('option');
                                option.value = prodi.id;
                                option.textContent = prodi.nama;

                                if (currentValue == prodi.id) {
                                    option.selected = true;
                                }

                                prodiSelect.appendChild(option);
                            });
                        })
                        .catch(error => {
                            console.error('Error loading prodi:', error);
                            prodiSelect.innerHTML = '<option value="">Error loading data</option>';
                        });
                }

                kampusSelect.addEventListener('change', function() {
                    loadProdiForFilter(this.value);
                });

                const initialKampusId = kampusSelect.value;
                if (initialKampusId) {
                    loadProdiForFilter(initialKampusId);
                }
            }
        });

        // Modal Generate Functions
        const generateModal = document.getElementById('generateModal');
        const generateForm = document.getElementById('generateForm');
        const generateModalSubtitle = document.getElementById('generateModalSubtitle');
        const tanggalAwalInput = document.getElementById('tanggal_awal');

        function openGenerateModal(mahasiswaId, mahasiswaNama) {
            // Set form action
            generateForm.action = `/angsuran/generate/${mahasiswaId}`;

            // Set subtitle
            generateModalSubtitle.textContent = `Generate rencana angsuran untuk ${mahasiswaNama}`;

            // Set default tanggal ke hari ini
            const today = new Date().toISOString().split('T')[0];
            tanggalAwalInput.value = today;

            // Show modal
            generateModal.classList.remove('hidden');
            document.body.style.overflow = 'hidden'; // Prevent scrolling

            // Recreate icons in modal
            lucide.createIcons();
        }

        function closeGenerateModal() {
            generateModal.classList.add('hidden');
            document.body.style.overflow = ''; // Restore scrolling
        }

        // Close modal when clicking outside
        window.onclick = function(event) {
            if (event.target.classList.contains('bg-opacity-75')) {
                closeGenerateModal();
            }
        }

        // Prevent modal close when clicking inside
        document.querySelectorAll('.bg-white, .dark\\:bg-\\[#1a1a2e\\]').forEach(modal => {
            if (modal) {
                modal.addEventListener('click', function(e) {
                    e.stopPropagation();
                });
            }
        });

        // Keyboard event untuk close modal dengan ESC
        document.addEventListener('keydown', function(e) {
            if (e.key === 'Escape' && !generateModal.classList.contains('hidden')) {
                closeGenerateModal();
            }
        });

        function deleteMahasiswa(id, nama) {
            Swal.fire({
                title: 'Hapus Mahasiswa?',
                html: `<div class="text-left">
                    <div class="mb-4 p-4 bg-red-500/10 border border-red-500/20 rounded-xl">
                        <div class="flex items-start gap-3">
                            <div class="w-10 h-10 rounded-xl bg-red-500/10 text-red-500 flex items-center justify-center flex-shrink-0">
                                <i data-lucide="alert-triangle" class="w-5 h-5"></i>
                            </div>
                            <div>
                                <h4 class="font-bold text-red-700 dark:text-red-400">Perhatian!</h4>
                                <p class="text-sm text-red-600 dark:text-red-300 mt-1">
                                    Data mahasiswa <strong>"${nama}"</strong> dan semua data terkait akan dihapus secara permanen.
                                </p>
                            </div>
                        </div>
                    </div>
                    <p class="text-sm text-slate-500 dark:text-slate-400">
                        Tindakan ini tidak dapat dibatalkan. Pastikan Anda telah mem-backup data penting.
                    </p>
                </div>`,
                icon: 'warning',
                showCancelButton: true,
                confirmButtonColor: '#d33',
                cancelButtonColor: '#6b7280',
                confirmButtonText: 'Ya, Hapus!',
                cancelButtonText: 'Batal',
                didOpen: () => {
                    lucide.createIcons();
                }
            }).then((result) => {
                if (result.isConfirmed) {
                    document.getElementById(`delete-form-${id}`).submit();
                }
            });
        }
    </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/mahasiswa/index.blade.php ENDPATH**/ ?>