<?php

declare(strict_types=1);

require_once '../../private/db.php';
require_once '../../private/auth.php';

require_login();

$stmt=$pdo->query("
SELECT COUNT(*) AS total_orders,
SUM(total) AS total_sales
FROM orders
");

$report=$stmt->fetch();

?>
<!DOCTYPE html>
<html>
<head>
<title>Reports</title>
<style>
body{font-family:Arial;background:#111827;color:#fff;padding:20px;}
.card{background:#1f2937;padding:20px;border-radius:12px;margin-bottom:20px;}
</style>
</head>
<body>

<h1>Reports</h1>

<p><a href="dashboard.php" style="color:white;">Dashboard</a></p>

<div class="card">
<h2>Total Orders</h2>
<p><?= (int)$report['total_orders'] ?></p>
</div>

<div class="card">
<h2>Total Sales</h2>
<p>$<?= number_format((float)$report['total_sales'],2) ?></p>
</div>

</body>
</html>
