<?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>
                <h1 class="text-4xl font-black tracking-tight dark:text-white">
                    <span class="bg-gradient-to-r from-violet-600 to-indigo-600 bg-clip-text text-transparent">
                        Metode Pembayaran
                    </span>
                </h1>
                <p class="text-slate-500 dark:text-slate-400 text-sm mt-1">
                    <i data-lucide="credit-card" class="w-4 h-4 inline mr-2"></i>
                    Kelola metode pembayaran yang tersedia
                </p>
            </div>
            <a href="<?php echo e(route('metode-pembayaran.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 transition-all flex items-center gap-2">
                <i data-lucide="plus" class="w-4 h-4"></i>
                Tambah Metode
            </a>
        </div>

        <div class="bg-white dark:bg-[#1a1a2e] rounded-3xl border border-slate-200 dark:border-white/5 shadow-xl overflow-hidden">
            <div class="overflow-x-auto">
                <table class="w-full">
                    <thead class="bg-slate-50/50 dark:bg-white/5 border-b">
                        <tr>
                            <th class="text-left py-4 px-6 text-xs font-semibold uppercase">No</th>
                            <th class="text-left py-4 px-6 text-xs font-semibold uppercase">Nama Metode</th>
                            <th class="text-left py-4 px-6 text-xs font-semibold uppercase">Kode</th>
                            <th class="text-center py-4 px-6 text-xs font-semibold uppercase">Status</th>
                            <th class="text-center py-4 px-6 text-xs font-semibold uppercase">Urutan</th>
                            <th class="text-center py-4 px-6 text-xs font-semibold uppercase">Aksi</th>
                        </tr>
                    </thead>
                    <tbody class="divide-y divide-slate-100 dark:divide-gray-800">
                        <?php $__empty_1 = true; $__currentLoopData = $metode; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr class="hover:bg-slate-50/50 dark:hover:bg-gray-800/30">
                                <td class="py-4 px-6"><?php echo e($metode->firstItem() + $index); ?></td>
                                <td class="py-4 px-6 font-medium"><?php echo e($item->nama); ?></td>
                                <td class="py-4 px-6">
                                    <span class="px-2 py-1 bg-slate-100 dark:bg-gray-800 rounded-lg text-xs font-mono"><?php echo e($item->kode); ?></span>
                                </td>
                                <td class="py-4 px-6 text-center">
                                    <?php if($item->is_active): ?>
                                        <span class="px-2 py-1 text-xs rounded-full bg-green-500/10 text-green-600">Aktif</span>
                                    <?php else: ?>
                                        <span class="px-2 py-1 text-xs rounded-full bg-red-500/10 text-red-600">Nonaktif</span>
                                    <?php endif; ?>
                                </td>
                                <td class="py-4 px-6 text-center"><?php echo e($item->urutan); ?></td>
                                <td class="py-4 px-6">
                                    <div class="flex items-center gap-2 justify-center">
                                        <a href="<?php echo e(route('metode-pembayaran.edit', $item->id)); ?>" class="p-2 bg-amber-100 text-amber-600 rounded-lg hover:bg-amber-200 transition-all" title="Edit">
                                            <i data-lucide="edit-2" class="w-4 h-4"></i>
                                        </a>
                                        <button type="button" onclick="toggleStatus(<?php echo e($item->id); ?>, '<?php echo e($item->nama); ?>', <?php echo e($item->is_active ? 'true' : 'false'); ?>)"
                                            class="p-2 <?php echo e($item->is_active ? 'bg-red-100 text-red-600 hover:bg-red-200' : 'bg-green-100 text-green-600 hover:bg-green-200'); ?> rounded-lg transition-all"
                                            title="<?php echo e($item->is_active ? 'Nonaktifkan' : 'Aktifkan'); ?>">
                                            <i data-lucide="<?php echo e($item->is_active ? 'toggle-right' : 'toggle-left'); ?>" class="w-4 h-4"></i>
                                        </button>
                                        <button type="button" onclick="confirmDelete(<?php echo e($item->id); ?>, '<?php echo e($item->nama); ?>')"
                                            class="p-2 bg-red-100 text-red-600 rounded-lg hover:bg-red-200 transition-all"
                                            title="Hapus">
                                            <i data-lucide="trash-2" class="w-4 h-4"></i>
                                        </button>
                                        <form id="delete-form-<?php echo e($item->id); ?>" action="<?php echo e(route('metode-pembayaran.destroy', $item->id)); ?>" method="POST" class="hidden">
                                            <?php echo csrf_field(); ?>
                                            <?php echo method_field('DELETE'); ?>
                                        </form>
                                        <form id="toggle-form-<?php echo e($item->id); ?>" action="<?php echo e(route('metode-pembayaran.toggle', $item->id)); ?>" method="POST" class="hidden">
                                            <?php echo csrf_field(); ?>
                                        </form>
                                    </div>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr>
                                <td colspan="6" class="py-12 text-center text-slate-500">
                                    <i data-lucide="inbox" class="w-12 h-12 mx-auto mb-3 opacity-50"></i>
                                    <p>Belum ada metode pembayaran</p>
                                </td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
            <div class="p-4 border-t">
                <?php echo e($metode->links()); ?>

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

    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            lucide.createIcons();

            <?php if(session('success')): ?>
                Swal.fire({
                    title: 'Berhasil!',
                    text: <?php echo json_encode(session('success')); ?>,
                    icon: 'success',
                    timer: 3000,
                    showConfirmButton: true,
                    confirmButtonColor: '#4f46e5'
                });
            <?php endif; ?>

            <?php if(session('error')): ?>
                Swal.fire({
                    title: 'Gagal!',
                    text: <?php echo json_encode(session('error')); ?>,
                    icon: 'error',
                    confirmButtonColor: '#ef4444'
                });
            <?php endif; ?>
        });

        function confirmDelete(id, nama) {
            Swal.fire({
                title: 'Hapus Metode Pembayaran?',
                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">
                                    Metode pembayaran <strong>"${nama}"</strong> 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 metode ini tidak sedang digunakan.
                    </p>
                </div>`,
                icon: 'warning',
                showCancelButton: true,
                confirmButtonColor: '#d33',
                cancelButtonColor: '#6b7280',
                confirmButtonText: 'Ya, Hapus!',
                cancelButtonText: 'Batal',
                didOpen: () => {
                    if (typeof lucide !== 'undefined') lucide.createIcons();
                }
            }).then((result) => {
                if (result.isConfirmed) {
                    document.getElementById(`delete-form-${id}`).submit();
                }
            });
        }

        function toggleStatus(id, nama, isActive) {
            const action = isActive ? 'nonaktifkan' : 'aktifkan';
            Swal.fire({
                title: `${isActive ? 'Nonaktifkan' : 'Aktifkan'} Metode?`,
                text: `Apakah Anda yakin ingin ${action} metode pembayaran "${nama}"?`,
                icon: 'question',
                showCancelButton: true,
                confirmButtonColor: '#4f46e5',
                cancelButtonColor: '#6b7280',
                confirmButtonText: `Ya, ${action}!`,
                cancelButtonText: 'Batal'
            }).then((result) => {
                if (result.isConfirmed) {
                    document.getElementById(`toggle-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/metode-pembayaran/index.blade.php ENDPATH**/ ?>