<?php
/** @var string $pageTitle */
require_once __DIR__ . '/bootstrap.php';
$flash = pull_flash();
$cssVersion = (string) (@filemtime(__DIR__ . '/../assets/css/style.css') ?: time());
?>
<!doctype html>
<html lang="ar" dir="rtl">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="theme-color" content="#1558d6">
    <title><?= e($pageTitle ?? APP_NAME) ?> | <?= e(APP_NAME) ?></title>
    <link rel="stylesheet" href="<?= e(url('assets/css/style.css?v=' . $cssVersion)) ?>">
</head>
<body class="<?= e($bodyClass ?? '') ?>">
<header class="topbar">
    <div class="topbar-inner">
        <a class="brand" href="<?= e(url('index.php')) ?>">
            <span class="brand-logo-wrap">
                <img src="<?= e(url('assets/images/kodo-logo.png')) ?>" alt="شخصية كودو">
            </span>
            <span class="brand-copy">
                <strong>كودو</strong>
                <small>البرمجة والذكاء الاصطناعي</small>
            </span>
        </a>
        <nav class="topbar-nav">
            <?php if (admin_logged_in()): ?>
                <a class="topbar-link" href="<?= e(url('admin/dashboard.php')) ?>">الطلاب</a>
                <a class="topbar-link" href="<?= e(url('admin/videos.php')) ?>">الفيديوهات</a>
                <a class="topbar-link" href="<?= e(url('admin/quizzes.php')) ?>">الاختبارات</a>
                <a class="topbar-link" href="<?= e(url('admin/logout.php')) ?>">خروج</a>
            <?php elseif (student_logged_in()): ?>
                <a class="topbar-link" href="<?= e(url('student/dashboard.php')) ?>">محتواي</a>
                <a class="topbar-link" href="<?= e(url('logout.php')) ?>">خروج</a>
            <?php else: ?>
                <a class="topbar-link" href="<?= e(url('index.php')) ?>">الرئيسية</a>
            <?php endif; ?>
        </nav>
    </div>
</header>
<main class="page-shell">
<?php if ($flash): ?>
    <div class="alert alert-<?= e($flash['type']) ?>"><?= e($flash['message']) ?></div>
<?php endif; ?>
