

<?php $__env->startSection('title', 'Dashboard'); ?>

<?php $__env->startSection('content'); ?>
<div class="content-wrapper">
    <div class="row">
        <div class="col-sm-12">
            <h4 class="mb-4">Welcome, <?php echo e($reseller->name); ?>!</h4>
        </div>
    </div>

    <!-- Stats Cards -->
    <div class="row">
        <div class="col-md-4 grid-margin stretch-card">
            <div class="card">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-center">
                        <div>
                            <p class="text-muted mb-2">Total Users</p>
                            <h3 class="mb-0"><?php echo e($totalUsers); ?></h3>
                        </div>
                        <div class="text-primary">
                            <i class="mdi mdi-account-group mdi-36px"></i>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-4 grid-margin stretch-card">
            <div class="card">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-center">
                        <div>
                            <p class="text-muted mb-2">Active Users</p>
                            <h3 class="mb-0"><?php echo e($activeUsers); ?></h3>
                        </div>
                        <div class="text-success">
                            <i class="mdi mdi-account-check mdi-36px"></i>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-4 grid-margin stretch-card">
            <div class="card">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-center">
                        <div>
                            <p class="text-muted mb-2">Total Revenue</p>
                            <h3 class="mb-0"><?php echo e(App\CPU\Helpers::formatCurrency($totalRevenue)); ?></h3>
                        </div>
                        <div class="text-warning">
                            <i class="mdi mdi-currency-usd mdi-36px"></i> <!-- Consider dynamic icon if needed -->
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Balance & Commission -->
    <div class="row">
        <div class="col-md-6 grid-margin stretch-card">
            <div class="card">
                <div class="card-body">
                    <h4 class="card-title">Wallet Balance</h4>
                    <div class="d-flex justify-content-between align-items-center mb-3">
                        <div>
                            <h2 class="mb-0"><?php echo e(App\CPU\Helpers::formatCurrency($reseller->balance)); ?></h2>
                        </div>
                        <div>
                            <span class="badge badge-success">Commission: <?php echo e($reseller->commission_rate); ?>%</span>
                        </div>
                    </div>
                    <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addBalanceModal">
                        Add Balance
                    </button>
                </div>
            </div>
        </div>
        <div class="col-md-6 grid-margin stretch-card">
            <div class="card">
                <div class="card-body">
                    <h4 class="card-title">Quick Stats</h4>
                    <div class="row">
                        <div class="col-6">
                            <p class="text-muted">Company</p>
                            <h5><?php echo e($reseller->company_name ?? 'N/A'); ?></h5>
                        </div>
                        <div class="col-6">
                            <p class="text-muted">Phone</p>
                            <h5><?php echo e($reseller->phone ?? 'N/A'); ?></h5>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Recent Orders -->
    <div class="row">
        <div class="col-12 grid-margin stretch-card">
            <div class="card">
                <div class="card-body">
                    <h4 class="card-title">Recent Orders</h4>
                    <div class="table-responsive">
                        <table class="table table-striped">
                            <thead>
                                <tr>
                                    <th>Order ID</th>
                                    <th>User</th>
                                    <th>Amount</th>
                                    <th>Status</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->id); ?></td>
                                    <td><?php echo e($order->user->name ?? 'N/A'); ?></td>
                                    <td><?php echo e(App\CPU\Helpers::formatCurrency($order->price)); ?></td>
                                    <td>
                                        <?php if($order->status == 'active'): ?>
                                        <span class="badge badge-success">Active</span>
                                        <?php elseif($order->status == 'expired'): ?>
                                        <span class="badge badge-danger">Expired</span>
                                        <?php else: ?>
                                        <span class="badge badge-warning"><?php echo e($order->status); ?></span>
                                        <?php endif; ?>
                                    </td>
                                    <td><?php echo e($order->created_at->format('Y-m-d')); ?></td>
                                </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="5" class="text-center">No orders found</td>
                                </tr>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- Add Balance Modal -->
<div class="modal fade" id="addBalanceModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Add Balance</h5>
                <button type="button" class="close" data-dismiss="modal">
                    <span>&times;</span>
                </button>
            </div>
            <form action="<?php echo e(route('reseller.addBalance')); ?>" method="POST">
                <?php echo csrf_field(); ?>
                <div class="modal-body">
                    <div class="form-group">
                        <label>Amount (<?php echo e(App\CPU\Helpers::getCurrencySymbol()); ?>)</label>
                        <input type="number" name="amount" class="form-control" min="1" step="0.01" required>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">Add Balance</button>
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                </div>
            </form>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.reseller', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\pixy\resources\views/reseller/dashboard.blade.php ENDPATH**/ ?>