<?php 
session_start();
error_reporting(0);
include('includes/config.php');
if(strlen($_SESSION['login'])==0) { 
    header('location:index.php');
} else { 
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gips | Dashboard</title>

<!-- Bootstrap 5 -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">

<!-- Font Awesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">

<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap" rel="stylesheet">

<style>
body {
    font-family: 'Poppins', sans-serif;
    background-color: #f4f6f9;
    margin: 0;
}

/* Sidebar */
#sidebar {
    width: 260px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: linear-gradient(180deg,#ff8000,#ff4500);
    color: #fff;
    padding-top: 80px;
    border-radius: 0 20px 20px 0;
    overflow-y: auto;
    box-shadow: 2px 0 12px rgba(0,0,0,0.1);
}

/* Main Content */
.main-content {
    margin-left: 260px;
    padding-top: 100px;
    padding-left: 30px;
    padding-right: 30px;
}

/* Dashboard Cards */
.dashboard-card {
    background: linear-gradient(135deg,#ff9966,#ff5e62);
    border-radius: 15px;
    color: #fff;
    padding: 30px 20px;
    text-align: center;
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
    overflow: hidden;
}
.dashboard-card:hover {
    transform: translateY(-7px) scale(1.03);
    box-shadow: 0 12px 30px rgba(0,0,0,0.2);
}
.dashboard-card h3 {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 10px;
}
.dashboard-card p {
    font-size: 15px;
    margin-bottom: 0;
}
.dashboard-card i {
    font-size: 50px;
    position: absolute;
    top: 20px;
    right: 20px;
    opacity: 0.2;
}

/* Responsive */
@media (max-width:991px){
    .main-content {margin-left:0; padding-left:15px; padding-right:15px;}
    #sidebar {width:100%; height:auto; position:relative; border-radius:0; padding-top:20px;}
}
</style>
</head>

<body>
<?php include("includes/header.php"); ?>
<?php include("includes/sidebar.php"); ?>

<section class="main-content">
    <div class="container-fluid">
        <h3 class="mb-4"><i class="fa fa-dashboard"></i> Dashboard</h3>
        <div class="row g-4">

            <!-- Not Processed Complaints -->
            <?php 
            $rt = mysqli_query($bd, "SELECT * FROM tblcomplaints WHERE userId='".$_SESSION['id']."' AND (status IS NULL OR status='')");
            $notProcessed = mysqli_num_rows($rt);
            ?>
            <div class="col-md-4">
                <div class="dashboard-card">
                    <i class="fas fa-clock"></i>
                    <h3><?php echo htmlentities($notProcessed); ?></h3>
                    <p><?php echo htmlentities($notProcessed); ?> Complaints not processed yet</p>
                </div>
            </div>

            <!-- In Process Complaints -->
            <?php 
            $rt = mysqli_query($bd, "SELECT * FROM tblcomplaints WHERE userId='".$_SESSION['id']."' AND status='in process'");
            $inProcess = mysqli_num_rows($rt);
            ?>
            <div class="col-md-4">
                <div class="dashboard-card">
                    <i class="fas fa-spinner"></i>
                    <h3><?php echo htmlentities($inProcess); ?></h3>
                    <p><?php echo htmlentities($inProcess); ?> Complaints in process</p>
                </div>
            </div>

            <!-- Closed Complaints -->
            <?php 
            $rt = mysqli_query($bd, "SELECT * FROM tblcomplaints WHERE userId='".$_SESSION['id']."' AND status='closed'");
            $closed = mysqli_num_rows($rt);
            ?>
            <div class="col-md-4">
                <div class="dashboard-card">
                    <i class="fas fa-check-circle"></i>
                    <h3><?php echo htmlentities($closed); ?></h3>
                    <p><?php echo htmlentities($closed); ?> Complaints closed</p>
                </div>
            </div>

        </div>
    </div>
</section>

<?php include("includes/footer.php"); ?>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
<?php } ?>
