<?php
require_once __DIR__ . '/../../bootstrap.php';
require_once __DIR__ . '/../../src/AdminAuth.php';
AdminAuth::requireLogin();

if (empty($_SESSION['csrf_token'])) {
    $_SESSION['csrf_token'] = bin2hex(random_bytes(32));
}

require_once __DIR__ . '/../../src/Database.php';

$pageTitle = "Gestion des mots-clés";

try {
    $db   = new Database();
    $tags = $db->getAllTagsWithCount();
} catch (Exception $e) {
    die("Erreur : " . htmlspecialchars($e->getMessage()));
}

$isAdmin = true; $bodyClass = 'admin-body';
require_once APP_ROOT . '/templates/head.php';
include APP_ROOT . '/templates/header.php';
include APP_ROOT . '/templates/admin/tags.php';
require_once APP_ROOT . '/templates/admin/footer.php';
