<?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([]); ?>
     <?php $__env->slot('header', null, []); ?> 
        <h2 class="font-semibold text-xl text-gray-800 leading-tight">Manajemen Pengguna</h2>
     <?php $__env->endSlot(); ?>

    <div class="py-10">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">

            
            <div class="grid grid-cols-2 md:grid-cols-5 gap-4 mb-6">
                <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-5">
                    <div class="text-xs text-gray-400 font-semibold uppercase">Total Customer</div>
                    <div class="text-2xl font-extrabold text-gray-900 mt-1"><?php echo e($stats['total_customers']); ?></div>
                </div>
                <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-5">
                    <div class="text-xs text-gray-400 font-semibold uppercase">Total Admin</div>
                    <div class="text-2xl font-extrabold text-blue-600 mt-1"><?php echo e($stats['total_admins']); ?></div>
                </div>
                <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-5">
                    <div class="text-xs text-gray-400 font-semibold uppercase">Total Kurir</div>
                    <div class="text-2xl font-extrabold text-indigo-600 mt-1"><?php echo e($stats['total_couriers']); ?></div>
                </div>
                <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-5">
                    <div class="text-xs text-gray-400 font-semibold uppercase">Customer Aktif</div>
                    <div class="text-2xl font-extrabold text-green-600 mt-1"><?php echo e($stats['active_customers']); ?></div>
                </div>
            </div>

            
            <div class="bg-white rounded-xl shadow-sm border border-gray-100 mb-6 p-5">
                <form method="GET" action="<?php echo e(route('admin.users.index')); ?>" class="grid grid-cols-1 md:grid-cols-4 gap-4">
                    <div>
                        <label class="block text-xs font-semibold text-gray-600 mb-1">Cari Pengguna</label>
                        <input type="text" name="search" value="<?php echo e(request('search')); ?>" placeholder="Nama, Email, atau HP"
                               class="w-full rounded-xl border-gray-300 shadow-sm text-sm focus:border-indigo-400 focus:ring-indigo-400">
                    </div>
                    <div>
                        <label class="block text-xs font-semibold text-gray-600 mb-1">Role</label>
                        <select name="role" class="w-full rounded-xl border-gray-300 shadow-sm text-sm focus:border-indigo-400 focus:ring-indigo-400">
                            <option value="customer" <?php echo e(request('role','customer') == 'customer' ? 'selected' : ''); ?>>Customer</option>
                            <option value="kurir"    <?php echo e(request('role') == 'kurir'    ? 'selected' : ''); ?>>Kurir</option>
                            <option value="admin"    <?php echo e(request('role') == 'admin'    ? 'selected' : ''); ?>>Admin</option>
                            <option value="all"      <?php echo e(request('role') == 'all'      ? 'selected' : ''); ?>>Semua</option>
                        </select>
                    </div>
                    <div>
                        <label class="block text-xs font-semibold text-gray-600 mb-1">Status</label>
                        <select name="status" class="w-full rounded-xl border-gray-300 shadow-sm text-sm focus:border-indigo-400 focus:ring-indigo-400">
                            <option value="">Semua Status</option>
                            <option value="1" <?php echo e(request('status') == '1' ? 'selected' : ''); ?>>Aktif</option>
                            <option value="0" <?php echo e(request('status') == '0' ? 'selected' : ''); ?>>Nonaktif</option>
                        </select>
                    </div>
                    <div class="flex items-end">
                        <button type="submit" class="w-full bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2.5 px-4 rounded-xl text-sm transition">
                            <i class="fas fa-search mr-2"></i>Filter
                        </button>
                    </div>
                </form>
            </div>

            
            <?php if(session('success')): ?>
            <div class="bg-green-50 border border-green-200 text-green-700 px-4 py-3 rounded-xl mb-4 text-sm"><?php echo e(session('success')); ?></div>
            <?php endif; ?>
            <?php if(session('error')): ?>
            <div class="bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-xl mb-4 text-sm"><?php echo e(session('error')); ?></div>
            <?php endif; ?>

            
            <div class="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden">
                <div class="overflow-x-auto">
                    <table class="min-w-full divide-y divide-gray-100">
                        <thead class="bg-gray-50">
                            <tr>
                                <th class="px-6 py-3 text-left text-xs font-bold text-gray-500 uppercase">Pengguna</th>
                                <th class="px-6 py-3 text-left text-xs font-bold text-gray-500 uppercase">Email & HP</th>
                                <th class="px-6 py-3 text-left text-xs font-bold text-gray-500 uppercase">Role</th>
                                <th class="px-6 py-3 text-left text-xs font-bold text-gray-500 uppercase">Status</th>
                                <th class="px-6 py-3 text-left text-xs font-bold text-gray-500 uppercase">Orders</th>
                                <th class="px-6 py-3 text-left text-xs font-bold text-gray-500 uppercase">Bergabung</th>
                                <th class="px-6 py-3 text-left text-xs font-bold text-gray-500 uppercase">Aksi</th>
                            </tr>
                        </thead>
                        <tbody class="bg-white divide-y divide-gray-100">
                            <?php $__empty_1 = true; $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr class="hover:bg-gray-50 transition">
                                <td class="px-6 py-4 whitespace-nowrap">
                                    <div class="flex items-center gap-3">
                                        <?php if($user->avatar): ?>
                                            <img class="w-10 h-10 rounded-full object-cover flex-shrink-0" src="<?php echo e(\Storage::url($user->avatar)); ?>" alt="<?php echo e($user->name); ?>">
                                        <?php else: ?>
                                            <div class="w-10 h-10 rounded-full bg-indigo-100 flex items-center justify-center flex-shrink-0">
                                                <span class="text-indigo-700 font-extrabold text-sm"><?php echo e(strtoupper(substr($user->name, 0, 1))); ?></span>
                                            </div>
                                        <?php endif; ?>
                                        <div class="text-sm font-semibold text-gray-900"><?php echo e($user->name); ?></div>
                                    </div>
                                </td>
                                <td class="px-6 py-4">
                                    <div class="text-sm text-gray-800"><?php echo e($user->email); ?></div>
                                    <div class="text-xs text-gray-400"><?php echo e($user->phone ?? '-'); ?></div>
                                </td>
                                <td class="px-6 py-4 whitespace-nowrap">
                                    <?php if($user->role === 'admin'): ?>
                                        <span class="px-2 py-1 bg-blue-100 text-blue-800 text-xs font-bold rounded-full">Admin</span>
                                    <?php elseif($user->role === 'kurir'): ?>
                                        <span class="px-2 py-1 bg-indigo-100 text-indigo-800 text-xs font-bold rounded-full">🚚 Kurir</span>
                                    <?php else: ?>
                                        <span class="px-2 py-1 bg-green-100 text-green-800 text-xs font-bold rounded-full">Customer</span>
                                    <?php endif; ?>
                                </td>
                                <td class="px-6 py-4 whitespace-nowrap">
                                    <?php if($user->is_active): ?>
                                        <span class="px-2 py-1 bg-green-100 text-green-800 text-xs font-bold rounded-full">Aktif</span>
                                    <?php else: ?>
                                        <span class="px-2 py-1 bg-red-100 text-red-800 text-xs font-bold rounded-full">Nonaktif</span>
                                    <?php endif; ?>
                                </td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
                                    <?php if($user->role === 'kurir'): ?>
                                        <?php echo e($user->courier_orders_count ?? 0); ?> diantar
                                    <?php else: ?>
                                        <?php echo e($user->orders_count); ?> pesanan
                                    <?php endif; ?>
                                </td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
                                    <div><?php echo e($user->created_at->format('d M Y')); ?></div>
                                    <div class="text-xs text-gray-400"><?php echo e($user->created_at->format('H:i')); ?> WIB</div>
                                </td>
                                <td class="px-6 py-4 whitespace-nowrap">
                                    <div class="flex items-center gap-2">
                                        <a href="<?php echo e(route('admin.users.show', $user)); ?>"
                                           class="inline-flex items-center gap-1 px-3 py-1.5 bg-indigo-50 text-indigo-600 hover:bg-indigo-600 hover:text-white rounded-lg text-xs font-bold transition">
                                            <i class="fas fa-eye"></i> Detail
                                        </a>
                                        <form action="<?php echo e(route('admin.users.toggle-status', $user)); ?>" method="POST" class="inline">
                                            <?php echo csrf_field(); ?>
                                            <?php echo method_field('PATCH'); ?>
                                            <button type="submit"
                                                class="inline-flex items-center gap-1 px-3 py-1.5 rounded-lg text-xs font-bold transition <?php echo e($user->is_active ? 'bg-red-50 text-red-600 hover:bg-red-600 hover:text-white' : 'bg-green-50 text-green-600 hover:bg-green-600 hover:text-white'); ?>"
                                                onclick="return confirm('<?php echo e($user->is_active ? 'Nonaktifkan' : 'Aktifkan'); ?> user <?php echo e(addslashes($user->name)); ?>?')">
                                                <i class="fas fa-<?php echo e($user->is_active ? 'ban' : 'check'); ?>"></i>
                                                <?php echo e($user->is_active ? 'Nonaktifkan' : 'Aktifkan'); ?>

                                            </button>
                                        </form>
                                    </div>
                                </td>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr>
                                <td colspan="7" class="px-6 py-10 text-center text-gray-400 text-sm">Tidak ada data pengguna</td>
                            </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
                <div class="px-6 py-4 border-t border-gray-100">
                    <?php echo e($users->links()); ?>

                </div>
            </div>

        </div>
    </div>
 <?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:\laragon\www\e_commerce_pakaian\resources\views/admin/users/index.blade.php ENDPATH**/ ?>