<?php 
include 'auth.php';
include 'includes/header.php'; 
include 'includes/sidebar.php';
include '../includes/db.php';

// Quick stats
$users = mysqli_fetch_assoc(mysqli_query($conn,"SELECT COUNT(*) as total FROM users"))['total'];
$paid = mysqli_fetch_assoc(mysqli_query($conn,"SELECT COUNT(*) as total FROM users WHERE payment_status=1"))['total'];
$pendingBills = mysqli_fetch_assoc(mysqli_query($conn,"SELECT COUNT(*) as total FROM billings WHERE status='pending'"))['total'];
?>

<div class="container-fluid">

    <!-- Title -->
    <h4 class="mb-4 text-primary fw-bold">📊 Admin Dashboard</h4>

    <!-- Stats -->
    <div class="row g-4">

        <div class="col-md-4">
            <div class="card text-center p-4">
                <i class="bi bi-people fs-1 text-info"></i>
                <h6 class="mt-2">Total Users</h6>
                <h2><?php echo $users; ?></h2>
            </div>
        </div>

        <div class="col-md-4">
            <div class="card text-center p-4">
                <i class="bi bi-check-circle fs-1 text-success"></i>
                <h6 class="mt-2">Paid Users</h6>
                <h2><?php echo $paid; ?></h2>
            </div>
        </div>

        <div class="col-md-4">
            <div class="card text-center p-4">
                <i class="bi bi-receipt fs-1 text-warning"></i>
                <h6 class="mt-2">Pending Bills</h6>
                <h2><?php echo $pendingBills; ?></h2>
            </div>
        </div>

    </div>

</div>

<?php include 'includes/footer.php'; ?>