<?php
/** Admin ana şablonu. $content, $title, $activeMenu dışarıdan gelir. */
$menu = [
    'dashboard'  => ['Panel', 'admin/dashboard', '▤'],
    'categories' => ['Kategoriler', 'admin/kategoriler', '☰'],
    'products'   => ['Ürünler', 'admin/urunler', '🍽'],
    'events'     => ['Etkinlikler', 'admin/etkinlikler', '★'],
    'settings'   => ['Ayarlar', 'admin/ayarlar', '⚙'],
];
$flashes = get_flashes();
?>
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= e($title ?? 'Yönetim') ?> — Yönetim</title>
<link rel="stylesheet" href="<?= e(asset('assets/css/admin.css')) ?>">
</head>
<body>
<div class="admin-wrap">
    <input type="checkbox" id="navToggle" class="nav-toggle-cb" hidden>
    <aside class="sidebar">
        <div class="brand"><?= e(setting('business_name','QR Menü')) ?><span>yönetim</span></div>
        <nav class="side-nav">
            <?php foreach ($menu as $key => [$label,$path,$ic]): ?>
                <a href="<?= e(url($path)) ?>" class="<?= ($activeMenu??'')===$key?'active':'' ?>">
                    <span class="ic"><?= $ic ?></span> <?= e($label) ?>
                </a>
            <?php endforeach; ?>
            <a href="<?= e(url('/')) ?>" target="_blank" class="ext"><span class="ic">↗</span> Siteyi Gör</a>
            <a href="<?= e(url('admin/logout')) ?>" class="logout"><span class="ic">⏻</span> Çıkış</a>
        </nav>
    </aside>

    <main class="content">
        <header class="topbar">
            <label for="navToggle" class="hamburger" aria-label="Menü">☰</label>
            <h1><?= e($title ?? '') ?></h1>
            <div class="topbar-user">👤 <?= e($adminUser ?? 'Yönetici') ?></div>
        </header>

        <?php foreach ($flashes as $f): ?>
            <div class="flash <?= e($f['type']) ?>"><?= e($f['msg']) ?></div>
        <?php endforeach; ?>

        <div class="content-inner">
            <?= $content ?? '' ?>
        </div>
    </main>
</div>
<script src="<?= e(asset('assets/js/admin.js')) ?>" defer></script>
</body>
</html>
