<?php
require __DIR__.'/config.php';
$key = $_GET['key'] ?? '';
if ($key !== $ADMIN_SECRET) die("Accès refusé");
$page = $_GET['page'] ?? 'produits';
?>
<!DOCTYPE html>
<html lang="fr">
<head>
  <meta charset="UTF-8">
  <title>Panel Admin - <?= htmlspecialchars($APP_NAME) ?></title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="<?= asset('assets/app.min.css') ?>">
  <script defer src="<?= asset('assets/app.min.js') ?>"></script>
</head>
<body>
<header class="appbar"><div class="title">Panel Admin - <?= htmlspecialchars($APP_NAME) ?></div></header>
<nav class="admin-nav">
  <a href="?key=<?= urlencode($ADMIN_SECRET) ?>&page=produits"  class="<?= $page==='produits'?'active':'' ?>">Produits</a>
  <a href="?key=<?= urlencode($ADMIN_SECRET) ?>&page=categories" class="<?= $page==='categories'?'active':'' ?>">Catégories</a>
  <a href="?key=<?= urlencode($ADMIN_SECRET) ?>&page=uploads"    class="<?= $page==='uploads'?'active':'' ?>">Uploads</a>
  <a href="?key=<?= urlencode($ADMIN_SECRET) ?>&page=aide"       class="<?= $page==='aide'?'active':'' ?>">Aide</a>
</nav>

<div class="admin-wrap">
<?php
if ($page === 'produits')      include __DIR__.'/admin_produits.php';
elseif ($page === 'categories') include __DIR__.'/admin_categories.php';
elseif ($page === 'uploads')    include __DIR__.'/admin_uploads.php';
else                            include __DIR__.'/admin_aide.php';
?>
</div>

</body>
</html>
