<?php $__env->startSection('content'); ?>
<div class="container-fluid px-4">
    <h1 class="h3 mb-4 text-gray-800">Super Admin Dashboard</h1>

    <!-- Statistics Cards -->
    <div class="row mb-4">
        <div class="col-xl-3 col-md-6 mb-4">
            <div class="card border-left-primary shadow h-100 py-2">
                <div class="card-body">
                    <div class="text-primary font-weight-bold text-uppercase mb-1">Total Admins</div>
                    <div class="h3 mb-0"><?php echo e($totalAdmins); ?></div>
                </div>
            </div>
        </div>

        <div class="col-xl-3 col-md-6 mb-4">
            <div class="card border-left-success shadow h-100 py-2">
                <div class="card-body">
                    <div class="text-success font-weight-bold text-uppercase mb-1">Total Users</div>
                    <div class="h3 mb-0"><?php echo e($totalUsers); ?></div>
                </div>
            </div>
        </div>

        <div class="col-xl-3 col-md-6 mb-4">
            <div class="card border-left-info shadow h-100 py-2">
                <div class="card-body">
                    <div class="text-info font-weight-bold text-uppercase mb-1">Total Transactions</div>
                    <div class="h3 mb-0"><?php echo e($totalTransactions); ?></div>
                </div>
            </div>
        </div>

        <div class="col-xl-3 col-md-6 mb-4">
            <div class="card border-left-warning shadow h-100 py-2">
                <div class="card-body">
                    <div class="text-warning font-weight-bold text-uppercase mb-1">Permissions Available</div>
                    <div class="h3 mb-0"><?php echo e($totalPermissions); ?></div>
                </div>
            </div>
        </div>
    </div>

    <!-- Admin Management Section -->
    <div class="card shadow mb-4">
        <div class="card-header py-3 d-flex justify-content-between align-items-center">
            <h6 class="m-0 font-weight-bold text-primary">Manage Admins</h6>
            <a href="<?php echo e(route('super-admin.create-admin')); ?>" class="btn btn-primary btn-sm">
                <i class="fas fa-plus"></i> Create Admin
            </a>
        </div>
        <div class="card-body">
            <?php if($admins->count() > 0): ?>
                <div class="table-responsive">
                    <table class="table table-hover">
                        <thead class="table-light">
                            <tr>
                                <th>Name</th>
                                <th>Email</th>
                                <th>Permissions</th>
                                <th>Created</th>
                                <th>Actions</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__currentLoopData = $admins; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $admin): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td><?php echo e($admin->name); ?></td>
                                    <td><?php echo e($admin->email); ?></td>
                                    <td>
                                        <span class="badge bg-info"><?php echo e($admin->permissions_count); ?> permissions</span>
                                    </td>
                                    <td><?php echo e($admin->created_at->format('M d, Y')); ?></td>
                                    <td>
                                        <a href="<?php echo e(route('super-admin.edit-permissions', $admin->id)); ?>" class="btn btn-sm btn-warning">
                                            <i class="fas fa-edit"></i> Permissions
                                        </a>
                                        <form action="<?php echo e(route('super-admin.delete-admin', $admin->id)); ?>" method="POST" class="d-inline">
                                            <?php echo csrf_field(); ?>
                                            <?php echo method_field('DELETE'); ?>
                                            <button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('Are you sure?')">
                                                <i class="fas fa-trash"></i> Delete
                                            </button>
                                        </form>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                </div>

                <!-- Pagination -->
                <div class="d-flex justify-content-center">
                    <?php echo e($admins->links()); ?>

                </div>
            <?php else: ?>
                <div class="alert alert-info">
                    No admins created yet. <a href="<?php echo e(route('super-admin.create-admin')); ?>">Create one now</a>
                </div>
            <?php endif; ?>
        </div>
    </div>

    <!-- Quick Links -->
    <div class="row">
        <div class="col-md-6">
            <div class="card shadow mb-4">
                <div class="card-header py-3">
                    <h6 class="m-0 font-weight-bold text-primary">Quick Links</h6>
                </div>
                <div class="card-body">
                    <a href="<?php echo e(route('super-admin.admins')); ?>" class="btn btn-block btn-outline-primary mb-2">
                        <i class="fas fa-users"></i> Manage All Admins
                    </a>
                    <a href="<?php echo e(route('super-admin.permissions')); ?>" class="btn btn-block btn-outline-primary mb-2">
                        <i class="fas fa-lock"></i> View All Permissions
                    </a>
                    <a href="<?php echo e(route('super-admin.activity-logs.index')); ?>" class="btn btn-block btn-outline-success mb-2">
                        <i class="fas fa-history"></i> Activity Logs
                    </a>
                    <a href="<?php echo e(route('super-admin.activity-logs.transactions')); ?>" class="btn btn-block btn-outline-info mb-2">
                        <i class="fas fa-exchange-alt"></i> Transaction History
                    </a>
                    <a href="<?php echo e(route('super-admin.statistics')); ?>" class="btn btn-block btn-outline-primary">
                        <i class="fas fa-chart-bar"></i> Statistics & Reports
                    </a>
                </div>
            </div>
        </div>

        <div class="col-md-6">
            <div class="card shadow mb-4">
                <div class="card-header py-3">
                    <h6 class="m-0 font-weight-bold text-primary">System Overview</h6>
                </div>
                <div class="card-body">
                    <p><strong>Total Revenue:</strong> <?php echo e(number_format($totalRevenue, 2)); ?></p>
                    <p><strong>Total Expenses:</strong> <?php echo e(number_format($totalExpenses, 2)); ?></p>
                    <p><strong>Net Profit:</strong> <?php echo e(number_format($totalRevenue - $totalExpenses, 2)); ?></p>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-6">
            <div class="card">
                <div class="card-header">Recent Users</div>
                <div class="card-body p-0">
                    <ul class="list-group list-group-flush">
                        <?php $__currentLoopData = $recentUsers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $u): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <li class="list-group-item"><?php echo e($u->name); ?> &middot; <?php echo e($u->email); ?></li>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </ul>
                </div>
            </div>
        </div>

        <div class="col-md-6">
            <div class="card">
                <div class="card-header">Top Users (by income)</div>
                <div class="card-body p-0">
                    <ul class="list-group list-group-flush">
                        <?php $__currentLoopData = $topUsers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $u): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <li class="list-group-item"><?php echo e($u->name); ?> — <?php echo e(number_format($u->total_income, 2)); ?></li>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </ul>
                </div>
            </div>
        </div>
     </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\startup sabbir\Desktop\jannat\accounting-system\resources\views/super-admin/dashboard.blade.php ENDPATH**/ ?>