<?php $__env->startSection('backend_content'); ?>
    <div class="container-fluid">
        <div class="d-flex justify-content-between align-items-center mb-4">
            <div>
                <h4 class="fw-bold mb-1"><?php echo e($shop->name); ?> Report</h4>
                <small class="text-muted">Sales, orders, and product performance summary</small>
            </div>
            <div class="d-flex gap-2">
                <a href="<?php echo e(route('admin.shops.show', $shop)); ?>" class="btn btn-light border">
                    <i class="bx bx-show"></i> Shop Details
                </a>
                <a href="<?php echo e(route('admin.shops.index')); ?>" class="btn btn-light">
                    <i class="bx bx-arrow-back"></i> Back
                </a>
            </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">
                        <small class="text-muted text-uppercase">Total Products</small>
                        <h3 class="mb-0 fw-700"><?php echo e($summary['total_products']); ?></h3>
                    </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">
                        <small class="text-muted text-uppercase">In Stock</small>
                        <h3 class="mb-0 fw-700 text-success"><?php echo e($summary['in_stock_products']); ?></h3>
                    </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">
                        <small class="text-muted text-uppercase">Total Orders</small>
                        <h3 class="mb-0 fw-700 text-primary"><?php echo e($summary['orders_count']); ?></h3>
                    </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">
                        <small class="text-muted text-uppercase">Gross Sales</small>
                        <h3 class="mb-0 fw-700 text-dark"><?php echo e(number_format($summary['gross_sales'], 0)); ?> BDT</h3>
                    </div>
                </div>
            </div>
        </div>

        <div class="row g-4">
            <div class="col-lg-5">
                <div class="card border-0 shadow-sm mb-4">
                    <div class="card-header bg-white border-bottom">
                        <h6 class="mb-0 fw-600">Order Status Breakdown</h6>
                    </div>
                    <div class="card-body">
                        <div class="d-flex flex-wrap gap-2">
                            <span class="badge bg-warning text-dark p-2">Pending: <?php echo e((int) ($statusCounts['pending'] ?? 0)); ?></span>
                            <span class="badge bg-success p-2">Completed: <?php echo e((int) ($statusCounts['completed'] ?? 0)); ?></span>
                            <span class="badge bg-danger p-2">Cancelled: <?php echo e((int) ($statusCounts['cancelled'] ?? 0)); ?></span>
                        </div>
                        <hr>
                        <div class="d-flex justify-content-between mb-2">
                            <span class="text-muted">Items Sold</span>
                            <strong><?php echo e($summary['items_sold']); ?></strong>
                        </div>
                        <div class="d-flex justify-content-between">
                            <span class="text-muted">Avg. Order Value</span>
                            <strong>
                                <?php echo e($summary['orders_count'] > 0 ? number_format($summary['gross_sales'] / $summary['orders_count'], 0) : 0); ?> BDT
                            </strong>
                        </div>
                    </div>
                </div>

                <div class="card border-0 shadow-sm">
                    <div class="card-header bg-white border-bottom">
                        <h6 class="mb-0 fw-600">Top Products</h6>
                    </div>
                    <div class="table-responsive">
                        <table class="table table-sm align-middle mb-0">
                            <thead class="table-light">
                                <tr>
                                    <th>Product</th>
                                    <th class="text-end">Qty</th>
                                    <th class="text-end">Revenue</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__empty_1 = true; $__currentLoopData = $topProducts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <tr>
                                        <td><?php echo e($row->product_name); ?></td>
                                        <td class="text-end"><?php echo e((int) $row->qty_sold); ?></td>
                                        <td class="text-end"><?php echo e(number_format((float) $row->revenue, 0)); ?> BDT</td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <tr>
                                        <td colspan="3" class="text-center text-muted py-3">No product sales data yet.</td>
                                    </tr>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

            <div class="col-lg-7">
                <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">Recent Orders</h6>
                        <small class="text-muted">Latest 10 orders for this shop</small>
                    </div>
                    <div class="table-responsive">
                        <table class="table align-middle mb-0">
                            <thead class="table-light">
                                <tr>
                                    <th>Order #</th>
                                    <th>Customer</th>
                                    <th>Status</th>
                                    <th class="text-end">Amount</th>
                                    <th>Date</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__empty_1 = true; $__currentLoopData = $recentOrders; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $order): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <tr>
                                        <td><?php echo e($order->order_number); ?></td>
                                        <td>
                                            <div class="fw-600"><?php echo e($order->customer_name); ?></div>
                                            <small class="text-muted"><?php echo e($order->phone); ?></small>
                                        </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 else: ?>
                                                <span class="badge bg-secondary"><?php echo e(ucfirst($order->status)); ?></span>
                                            <?php endif; ?>
                                        </td>
                                        <td class="text-end"><?php echo e(number_format((float) $order->total_amount, 0)); ?> BDT</td>
                                        <td><?php echo e(\Carbon\Carbon::parse($order->created_at)->format('M d, Y')); ?></td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <tr>
                                        <td colspan="5" class="text-center text-muted py-5">No orders found for this shop yet.</td>
                                    </tr>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <style>
        .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\shops\report.blade.php ENDPATH**/ ?>