<?php
session_start();
include("../db.php");

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

/* Counts */

$slider_count=mysqli_num_rows(mysqli_query($conn,"SELECT * FROM sliders"));
$service_count=mysqli_num_rows(mysqli_query($conn,"SELECT * FROM services"));
?>

<!DOCTYPE html>
<html>

<head>

<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Radios OnAIR Admin</title>

<style>

body{
margin:0;
font-family:Arial;
background:#eef1f5;
display:flex;
}

/* Sidebar */

.sidebar{
width:230px;
background:#0f6c74;
color:white;
height:100vh;
position:fixed;
padding-top:20px;
}

.sidebar h2{
text-align:center;
margin-bottom:30px;
}

.sidebar a{
display:block;
padding:12px 20px;
color:white;
text-decoration:none;
}

.sidebar a:hover{
background:#0a5258;
}

/* Main */

.main{
margin-left:230px;
width:100%;
}

/* Topbar */

.topbar{
background:white;
padding:15px;
display:flex;
justify-content:space-between;
align-items:center;
box-shadow:0 2px 6px rgba(0,0,0,0.1);
}

/* Container */

.container{
padding:20px;
}

/* Dashboard Cards */

.dashboard-grid{
display:grid;
grid-template-columns:repeat(auto-fit,minmax(200px,1fr));
gap:20px;
}

.card{
background:white;
padding:20px;
border-radius:10px;
box-shadow:0 3px 8px rgba(0,0,0,0.1);
text-align:center;
}

.card h3{
margin:0;
font-size:16px;
color:#555;
}

.card p{
font-size:32px;
color:#0f6c74;
margin-top:10px;
font-weight:bold;
}

.quick-links{
margin-top:20px;
}

.quick-links a{
display:inline-block;
background:#0f6c74;
color:white;
padding:10px 15px;
margin-right:10px;
border-radius:6px;
text-decoration:none;
}

</style>

</head>

<body>

<!-- Sidebar Include -->

<?php include("layout/sidebar.php"); ?>

<!-- Main -->

<div class="main">

<div class="topbar">

<h3>Admin Dashboard</h3>

<div>Super Admin</div>

</div>

<div class="container">

<div class="dashboard-grid">

<div class="card">

<h3>Total Sliders</h3>

<p><?php echo $slider_count; ?></p>

</div>

<div class="card">

<h3>Total Services</h3>

<p><?php echo $service_count; ?></p>

</div>

<div class="card">

<h3>Platform</h3>

<p>Radios OnAIR</p>

</div>

</div>

<div class="card quick-links">

<h3>Quick Actions</h3>

<br>

<a href="sliders.php">Add Slider</a>
<a href="services.php">Add Service</a>
<a href="ticker.php">Edit Ticker</a>

</div>

</div>

</div>

</body>

</html>