<?php $__env->startSection('title', 'Customers'); ?>
<?php $__env->startSection('content'); ?>
<div class="page-header d-print-none">
    <div class="container-xl">
        <div class="row g-2 align-items-center">
            <div class="col"><h2 class="page-title">Customers</h2></div>
            <div class="col-auto ms-auto d-print-none">
                <a href="<?php echo e(route('admin.customers.create')); ?>" class="btn btn-primary">
                    <svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 5l0 14" /><path d="M5 12l14 0" /></svg>
                    Add Customer
                </a>
            </div>
        </div>
    </div>
</div>
<div class="page-body">
    <div class="card mb-3">
        <div class="card-body">
            <form method="GET" class="row g-3">
                <div class="col-md-5">
                    <input type="text" name="search" class="form-control" placeholder="Search name, email, phone..." value="<?php echo e(request('search')); ?>">
                </div>
                <div class="col-md-3">
                    <select name="status" class="form-select">
                        <option value="">All Statuses</option>
                        <?php $__currentLoopData = ['active','blocked','pending']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $s): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($s); ?>" <?php echo e(request('status')==$s?'selected':''); ?>><?php echo e(ucfirst($s)); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
                <div class="col-md-4 d-flex gap-2">
                    <button type="submit" class="btn btn-primary">Filter</button>
                    <a href="<?php echo e(route('admin.customers.index')); ?>" class="btn btn-outline-secondary">Clear</a>
                </div>
            </form>
        </div>
    </div>

    <div class="card">
        <div class="card-header">
            <h3 class="card-title">All Customers (<?php echo e($customers->total()); ?>)</h3>
        </div>
        <div class="table-responsive">
            <table class="table table-vcenter card-table">
                <thead>
                    <tr>
                        <th>Customer</th>
                        <th>Phone</th>
                        <th>Status</th>
                        <th>Orders</th>
                        <th>Wallet</th>
                        <th>Joined</th>
                        <th>Actions</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $customers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $customer): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr>
                        <td>
                            <div class="d-flex align-items-center gap-2">
                                <span class="avatar avatar-sm"><?php echo e(strtoupper(substr($customer->name,0,2))); ?></span>
                                <div>
                                    <div class="fw-medium"><?php echo e($customer->name); ?></div>
                                    <div class="text-muted small"><?php echo e($customer->email); ?></div>
                                </div>
                            </div>
                        </td>
                        <td><?php echo e($customer->phone ?? '—'); ?></td>
                        <td>
                            <?php $sc=['active'=>'success','blocked'=>'danger','pending'=>'warning']; ?>
                            <span class="badge bg-<?php echo e($sc[$customer->status]??'secondary'); ?>-lt text-capitalize"><?php echo e($customer->status); ?></span>
                        </td>
                        <td><?php echo e($customer->orders_count); ?></td>
                        <td>₹<?php echo e(number_format($customer->wallet?->balance ?? 0, 2)); ?></td>
                        <td><?php echo e($customer->created_at->format('d M Y')); ?></td>
                        <td>
                            <div class="d-flex gap-1">
                                <a href="<?php echo e(route('admin.customers.show', $customer)); ?>" class="btn btn-sm btn-outline-secondary">View</a>
                                <?php if($customer->status === 'active'): ?>
                                    <form action="<?php echo e(route('admin.customers.block', $customer)); ?>" method="POST" class="d-inline">
                                        <?php echo csrf_field(); ?>
                                        <button class="btn btn-sm btn-danger" onclick="return confirm('Block this customer?')">Block</button>
                                    </form>
                                <?php else: ?>
                                    <form action="<?php echo e(route('admin.customers.unblock', $customer)); ?>" method="POST" class="d-inline">
                                        <?php echo csrf_field(); ?>
                                        <button class="btn btn-sm btn-success">Unblock</button>
                                    </form>
                                <?php endif; ?>
                            </div>
                        </td>
                    </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr><td colspan="7" class="text-center text-muted py-4">No customers found</td></tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>
        <div class="card-footer d-flex align-items-center">
            <?php echo e($customers->links()); ?>

        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/dev13codebuzzers/public_html/yamee/resources/views/admin/customers/index.blade.php ENDPATH**/ ?>