<?php
    session_start(); 
    $u_uname = '';
    if (isset($_COOKIE['auth_token'])) {
        $u_uname = $_COOKIE['auth_token'];
    } else {
        header("location:login.php");
    }
?>

<?php include 'include/header.php'; ?>
<?php include 'include/aside.php'; ?>
<?php include 'include/connection.php'; ?>
<style>
 @property --direction {
            syntax: "<angle>";
            initial-value: 0deg;
            inherits: false;
        }

.card-body {
    position: relative; /* Ensure the ::after and ::before can be positioned relative to the card */
}

.card-body::after {
    content: ''; /* Ensure content property is correctly used */
    position: absolute;
    width: 100%;
    height: 104%;
    transform: translate(-50%, -50%); /* Correct the use of 'translate' */
    left: 50%;
    top: 50%;
    z-index: -1;
    padding: 3px;
    background: conic-gradient(
        from var(--direction),
        transparent 70%,
        #ff5f6d,
        #ffc371,
        #ffd700,
        #32cd32,
        #00fa9a,
        #1e90ff,
        #9370db,
        #ff5f6d
    );
    border-radius: 10px;
    animation: rotate 3s linear infinite; /* Ensure the animation property is correctly placed */
}

.card-body::before {
    content: ''; /* Ensure content property is correctly used */
    position: absolute;
    height: 100%;
    transform: translate(-50%, -50%); /* Correct the use of 'translate' */
    left: 50%;
    top: 50%;
    filter: blur(1.5rem);
    opacity: 0.8;
    background: inherit;
    border-radius: 10px;
}

@keyframes rotate {
    from {
        --direction: 0deg;
    }
    to {
        --direction: 360deg;
    }
}
</style>
<div class="page-wrapper">
    <div class="page-content">
        <div class="row row-cols-1 row-cols-md-2 row-cols-xl-4">
            <div class="col">
                <div class="card radius-10">
                    <div class="card-body">
                        <div class="d-flex align-items-center">
                            <div>
                                <p class="mb-0 text-secondary">Total Users</p>
                                <h4 class="my-1">
                                    <?php
                                    $query = "SELECT COUNT(id) AS total_users FROM `users`";
                                    $result = $link->query($query);
                                    
                                    if ($result && $result->num_rows > 0) {
                                        $row = $result->fetch_assoc();
                                        echo  $row['total_users'];
                                    } 
                                    ?>
                                    
                                </h4>
                                <!--<p class="mb-0 font-13 text-success"><i class="bx bxs-up-arrow align-middle"></i>$34 from last week</p>-->
                            </div>
                            <div class="widgets-icons bg-light-success text-success ms-auto"><i class="bx bxs-wallet"></i></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col">
                <div class="card radius-10">
                    <div class="card-body">
                        <div class="d-flex align-items-center">
                            <div>
                                <p class="mb-0 text-secondary">Wallet Amount</p>
                                <h4 class="my-1">
                                    <?php
                                    $query5 = "SELECT SUM(wallet_balance) AS total_wallet_balance FROM `users`";
                                    $result5 = $link->query($query5);
                                    
                                    if ($result5 && $result5->num_rows > 0) {
                                        $row5 = $result5->fetch_assoc();
                                        echo  $row5['total_wallet_balance'];
                                    } else {
                                        echo "0";
                                    }
                                    ?>
                                </h4>
                                <!--<p class="mb-0 font-13 text-success"><i class="bx bxs-up-arrow align-middle"></i>$24 from last week</p>-->
                            </div>
                            <div class="widgets-icons bg-light-info text-info ms-auto"><i class="bx bxs-group"></i></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col">
                <div class="card radius-10">
                    <div class="card-body">
                        <div class="d-flex align-items-center">
                            <div>
                                <p class="mb-0 text-secondary">Block User</p>
                                <h4 class="my-1">
                                     <?php
                                    $query1 = "SELECT COUNT(id) AS block_users FROM `users` where blocking_status='1'";
                                    $result1 = $link->query($query1);
                                    
                                    if ($result1 && $result1->num_rows > 0) {
                                        $row1 = $result1->fetch_assoc();
                                        echo  $row1['block_users'];
                                    }else{
                                        echo "1";
                                    } 
                                    ?>
                                   
                                    
                                    
                                </h4>
                                <!--<p class="mb-0 font-13 text-danger"><i class="bx bxs-down-arrow align-middle"></i>$34 from last week</p>-->
                            </div>
                            <div class="widgets-icons bg-light-danger text-danger ms-auto"><i class="bx bxs-binoculars"></i></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col">
                <div class="card radius-10">
                    <div class="card-body">
                        <div class="d-flex align-items-center">
                            <div>
                                <p class="mb-0 text-secondary">Unblock User</p>
                                <h4 class="my-1">
                                    <?php
                                    $query2 = "SELECT COUNT(id) AS unblock_users FROM `users` where blocking_status='0'";
                                    $result2 = $link->query($query2);
                                    
                                    if ($result2 && $result2->num_rows > 0) {
                                        $row2 = $result2->fetch_assoc();
                                        echo  $row2['unblock_users'];
                                    }else{
                                        echo "1";
                                    } 
                                    ?>
                                </h4>
                                <!--<p class="mb-0 font-13 text-danger"><i class="bx bxs-down-arrow align-middle"></i>12.2% from last week</p>-->
                            </div>
                            <div class="widgets-icons bg-light-warning text-warning ms-auto"><i class="bx bx-line-chart-down"></i></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col">
                <div class="card radius-10">
                    <div class="card-body">
                        <div class="d-flex align-items-center">
                            <div>
                                <p class="mb-0 text-secondary">Active Server</p>
                                <h4 class="my-1">
                                    <?php
                                    $query12 = "SELECT COUNT(server_status) AS status FROM `server` where server_status='1'";
                                    $result12 = $link->query($query12);
                                    
                                    if ($result12 && $result12->num_rows > 0) {
                                        $row12 = $result12->fetch_assoc();
                                        echo  $row12['status'];
                                    }else{
                                        echo "1";
                                    } 
                                    ?>
                                </h4>
                                <!--<p class="mb-0 font-13 text-danger"><i class="bx bxs-down-arrow align-middle"></i>12.2% from last week</p>-->
                            </div>
                            <div class="widgets-icons bg-light-warning text-warning ms-auto"><i class="bx bx-line-chart-down"></i></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

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