<?php
session_start();
include('con.php');

if (!isset($_SESSION['username'])) {
    header("Location: login.php");
    exit;
}

$mobile = $_SESSION['username'];
$customerName = "";
$balance = 0.00;

// Fetch user info
$query = mysqli_query($ahk_conn, "SELECT name, balance FROM members WHERE username = '$mobile'");
if ($query && mysqli_num_rows($query) > 0) {
    $user = mysqli_fetch_assoc($query);
    $customerName = $user['name'];
    $balance = number_format($user['balance'], 2);
} else {
    $customerName = "Unknown User";
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Dashboard</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .card-hover {
            cursor: pointer;
            transition: transform 0.2s ease-in-out;
        }
        .card-hover:hover {
            transform: scale(1.03);
        }
        .card-img-top {
            height: 100px;
            object-fit: contain;
            padding: 10px;
        }
    </style>
</head>
<body>

<!-- Top Navbar -->
<nav class="navbar navbar-expand-lg navbar-light bg-light shadow-sm mb-4">
    <div class="container">
        <a class="navbar-brand" href="#">HarGharRojgar</a>
        <div class="d-flex ms-auto">
            <span class="navbar-text me-3">Welcome, <strong><?php echo htmlspecialchars($customerName); ?></strong></span>
            <span class="navbar-text me-3 text-success">Balance: ₹<?php echo $balance; ?></span>
            <a href="logout.php" class="btn btn-outline-danger btn-sm">Logout</a>
        </div>
    </div>
</nav>

<!-- Main Dashboard -->
<div class="container">
    <div class="row g-4 justify-content-center">

        <!-- Card 1
        <div class="col-lg-3 col-md-4 col-sm-6 col-12">
            <div class="card card-hover" onclick="location.href='rc_pdf.php'">
                <img src="img/Yamaha-Bike-PNG.png" class="card-img-top" alt="RC Download">
                <div class="card-body text-center">
                    <h6 class="card-title mb-0">RC Download</h6>
                </div>
            </div>
        </div>

        <!-- Card 2
        <div class="col-lg-3 col-md-4 col-sm-6 col-12">
            <div class="card card-hover" onclick="location.href='dl_pdf.php'">
                <img src="img/drivinglicencechip.png" class="card-img-top" alt="Driving Licence">
                <div class="card-body text-center">
                    <h6 class="card-title mb-0">Driving Licence</h6>
                </div>
            </div>
        </div>

        <!-- Card 3 
        <div class="col-lg-3 col-md-4 col-sm-6 col-12">
            <div class="card card-hover" onclick="location.href='Pan_details.php'">
                <img src="img/subservice57.png" class="card-img-top" alt="Pan Card">
                <div class="card-body text-center">
                    <h6 class="card-title mb-0">Pan Card</h6>
                </div>
            </div>
        </div>

        <!-- Card 4 
        <div class="col-lg-3 col-md-4 col-sm-6 col-12">
            <div class="card card-hover" onclick="location.href='ration_print.php'">
                <img src="img/ration1.png" class="card-img-top" alt="Ration Card">
                <div class="card-body text-center">
                    <h6 class="card-title mb-0">Ration Card</h6>
                </div>
            </div>
        </div>
 <!-- Card 4-->
        <div class="col-lg-3 col-md-4 col-sm-6 col-12">
            <div class="card card-hover" onclick="location.href='mvcc.php'">
                <img src="img/sssss.jpg" class="card-img-top" alt="Ration Card">
                <div class="card-body text-center">
                    <h6 class="card-title mb-0">Voter Mobile No. Link</h6>
                </div>
            </div>
        </div>

        <!-- Card 5 -->
        <div class="col-lg-3 col-md-4 col-sm-6 col-12">
            <div class="card card-hover" onclick="location.href='mvcchis.php'">
                <img src="img/dlpng1.png" class="card-img-top" alt="History">
                <div class="card-body text-center">
                    <h6 class="card-title mb-0">History</h6>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- Footer -->
<?php include('footer.php'); ?>

<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
