<?php $__env->startSection('backend_content'); ?>
    <div class="container-fluid">
        <div class="row">
            <div class="col-12">
                <div class="d-flex justify-content-between align-items-center mb-4">
                    <div>
                        <h1 class="h3 mb-1">Orders Management</h1>
                        <p class="text-muted mb-0">Manage, search, and update customer orders</p>
                    </div>
                </div>

                <div class="row g-3 mb-4">
                    <div class="col-12 col-md-6 col-xl-3">
                        <div class="card border-0 shadow-sm h-100">
                            <div class="card-body d-flex justify-content-between align-items-center">
                                <div>
                                    <small class="text-muted text-uppercase">Total Orders</small>
                                    <h4 class="mb-0 fw-700"><?php echo e($stats['total']); ?></h4>
                                </div>
                                <i class="bi bi-receipt-cutoff fs-3 text-primary"></i>
                            </div>
                        </div>
                    </div>
                    <div class="col-12 col-md-6 col-xl-3">
                        <div class="card border-0 shadow-sm h-100">
                            <div class="card-body d-flex justify-content-between align-items-center">
                                <div>
                                    <small class="text-muted text-uppercase">Pending</small>
                                    <h4 class="mb-0 fw-700 text-warning"><?php echo e($stats['pending']); ?></h4>
                                </div>
                                <i class="bi bi-clock-history fs-3 text-warning"></i>
                            </div>
                        </div>
                    </div>
                    <div class="col-12 col-md-6 col-xl-3">
                        <div class="card border-0 shadow-sm h-100">
                            <div class="card-body d-flex justify-content-between align-items-center">
                                <div>
                                    <small class="text-muted text-uppercase">Completed</small>
                                    <h4 class="mb-0 fw-700 text-success"><?php echo e($stats['completed']); ?></h4>
                                </div>
                                <i class="bi bi-check2-circle fs-3 text-success"></i>
                            </div>
                        </div>
                    </div>
                    <div class="col-12 col-md-6 col-xl-3">
                        <div class="card border-0 shadow-sm h-100">
                            <div class="card-body d-flex justify-content-between align-items-center">
                                <div>
                                    <small class="text-muted text-uppercase">Cancelled</small>
                                    <h4 class="mb-0 fw-700 text-danger"><?php echo e($stats['cancelled']); ?></h4>
                                </div>
                                <i class="bi bi-x-octagon fs-3 text-danger"></i>
                            </div>
                        </div>
                    </div>
                </div>

                
                <div class="card border-0 shadow-sm mb-4">
                    <div class="card-body">
                        <form method="GET" action="<?php echo e(route('admin.orders.index')); ?>" class="row g-3">
                            <div class="col-lg-8">
                                <label class="form-label fw-600">Search by Name, Phone, or Order #</label>
                                <div class="input-group">
                                    <span class="input-group-text bg-white"><i class="bi bi-search"></i></span>
                                    <input type="text" name="search" class="form-control"
                                        placeholder="Type customer name, phone, or order number..."
                                        value="<?php echo e(request('search')); ?>">
                                </div>
                            </div>
                            <div class="col-lg-4">
                                <label class="form-label fw-600">&nbsp;</label>
                                <div class="d-flex gap-2">
                                    <button type="submit" class="btn btn-primary w-100">
                                        <i class="bi bi-search"></i> Search
                                    </button>
                                    <a href="<?php echo e(route('admin.orders.index')); ?>" class="btn btn-light border w-100">Clear</a>
                                </div>
                            </div>

                            <div class="col-12">
                                <div class="d-flex flex-wrap gap-2">
                                    <a href="<?php echo e(route('admin.orders.index', array_merge(request()->except('status'), ['status' => 'pending']))); ?>"
                                        class="btn btn-sm <?php echo e(request('status') === 'pending' ? 'btn-warning' : 'btn-outline-warning'); ?>">
                                        Pending
                                    </a>
                                    <a href="<?php echo e(route('admin.orders.index', array_merge(request()->except('status'), ['status' => 'completed']))); ?>"
                                        class="btn btn-sm <?php echo e(request('status') === 'completed' ? 'btn-success' : 'btn-outline-success'); ?>">
                                        Completed
                                    </a>
                                    <a href="<?php echo e(route('admin.orders.index', array_merge(request()->except('status'), ['status' => 'cancelled']))); ?>"
                                        class="btn btn-sm <?php echo e(request('status') === 'cancelled' ? 'btn-danger' : 'btn-outline-danger'); ?>">
                                        Cancelled
                                    </a>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>

                
                <div class="card border-0 shadow-sm">
                    <div class="card-header bg-white border-bottom d-flex justify-content-between align-items-center">
                        <h6 class="mb-0 fw-600">Order List</h6>
                        <small class="text-muted"><?php echo e($orders->total()); ?> result(s)</small>
                    </div>
                    <div class="table-responsive">
                        <table class="table table-hover align-middle mb-0">
                            <thead class="table-light">
                                <tr>
                                    <th>Order #</th>
                                    <th>Customer</th>
                                    <th>Items</th>
                                    <th>Total</th>
                                    <th>Status</th>
                                    <th>Date</th>
                                    <th>Actions</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__empty_1 = true; $__currentLoopData = $orders; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $order): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <tr>
                                        <td>
                                            <a href="<?php echo e(route('admin.orders.show', $order)); ?>" class="fw-600 text-decoration-none">
                                                <?php echo e($order->order_number); ?>

                                            </a>
                                        </td>
                                        <td>
                                            <div>
                                                <div class="fw-600"><?php echo e($order->customer_name); ?></div>
                                                <small class="text-muted"><?php echo e($order->phone); ?></small>
                                            </div>
                                        </td>
                                        <td>
                                            <span class="badge bg-light text-dark"><?php echo e($order->items_count); ?> item(s)</span>
                                        </td>
                                        <td class="fw-600">৳<?php echo e(number_format($order->total_amount, 0)); ?></td>
                                        <td>
                                            <?php if($order->status === 'pending'): ?>
                                                <span class="badge bg-warning text-dark">Pending</span>
                                            <?php elseif($order->status === 'completed'): ?>
                                                <span class="badge bg-success">Completed</span>
                                            <?php elseif($order->status === 'cancelled'): ?>
                                                <span class="badge bg-danger">Cancelled</span>
                                            <?php endif; ?>
                                        </td>
                                        <td>
                                            <small class="text-muted"><?php echo e($order->created_at->format('M d, Y h:i A')); ?></small>
                                        </td>
                                        <td>
                                            <a href="<?php echo e(route('admin.orders.show', $order)); ?>" class="btn btn-sm btn-primary" title="View Details">
                                                <i class="bi bi-eye"></i> View
                                            </a>
                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <tr>
                                        <td colspan="7" class="text-center py-5 text-muted">
                                            <i class="bi bi-inbox" style="font-size: 2rem; opacity: 0.5;"></i>
                                            <p class="mt-3">No orders found</p>
                                        </td>
                                    </tr>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                </div>

                
                <div class="d-flex justify-content-center mt-4">
                    <?php echo e($orders->appends(request()->query())->links()); ?>

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

    <style>
        .table-hover tbody tr:hover {
            background-color: rgba(0, 0, 0, .02);
        }

        .fw-600 {
            font-weight: 600;
        }

        .fw-700 {
            font-weight: 700;
        }
    </style>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('backend.layout', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\Abdur Rahman\Desktop\faa\resources\views/backend/orders/index.blade.php ENDPATH**/ ?>