<?php
// ======================================
// Admin Layout (Master Template)
// ======================================

// Protect admin pages
require_once __DIR__ . '/../includes/admin_check.php';

// Page title (optional)
$pageTitle = $pageTitle ?? 'Admin Panel';

// Content must be passed from page
if (!isset($content)) {
    $content = "<p>No content loaded.</p>";
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title><?= htmlspecialchars($pageTitle); ?></title>
    <link rel="stylesheet" href="/assets/css/dashboard.css">
</head>
<body>

<div class="admin-wrapper">

    <!-- SIDEBAR -->
    <aside class="admin-sidebar" id="sidebar">
        <?php include __DIR__ . '/admin_sidebar.php'; ?>
    </aside>

    <!-- MAIN -->
    <div class="admin-main">

        <!-- TOP NAV -->
        <div class="admin-navbar">

            <button class="menu-toggle" onclick="toggleSidebar()">☰</button>

            <div class="nav-title"><?= htmlspecialchars($pageTitle); ?></div>

            <div class="nav-right">
                <input type="text" placeholder="Search..." class="nav-search">

                <div class="admin-user">
                    Admin
                </div>
            </div>

        </div>

        <!-- CONTENT -->
        <div class="admin-content">
            <?= $content; ?>
        </div>

    </div>

</div>

<script>
function toggleSidebar() {
    document.getElementById("sidebar").classList.toggle("collapsed");
}
</script>

</body>
</html>