<?php
$title = $title ?? app_name();
$description = $description ?? 'Aplikasi pembelian akses Wi-Fi tanpa kartu.';
$currentUser = auth_user();
?>
<!doctype html>
<html lang="id">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="<?= e($description) ?>">
    <title><?= e($title) ?> - <?= e(app_name()) ?></title>
    <link rel="stylesheet" href="<?= e(asset('/assets/app.css')) ?>">
</head>
<body>
<div class="page-shell">
    <header class="topbar">
        <div class="container">
            <nav class="nav" aria-label="Navigasi utama">
                <a class="brand" href="<?= e(url('/')) ?>">
                    <?php if ($logo = company_logo()): ?>
                        <span class="brand-logo" aria-hidden="true">
                            <img src="<?= e(url('/media?path=' . rawurlencode($logo))) ?>" alt="" loading="lazy">
                        </span>
                    <?php else: ?>
                        <span class="brand-mark" aria-hidden="true"></span>
                    <?php endif; ?>
                    <span><?= e(company_name()) ?></span>
                </a>
                <div class="nav-links">
                    <a class="nav-link" href="<?= e(url('/')) ?>">Beranda</a>
                    <?php if ($currentUser): ?>
                        <span class="nav-link"><?= e($currentUser['nama']) ?></span>
                        <?php if (($currentUser['role'] ?? 'client') === 'admin'): ?>
                            <a class="nav-link" href="<?= e(url('/admin/dashboard')) ?>">Dashboard Admin</a>
                        <?php else: ?>
                            <a class="nav-link" href="<?= e(url('/dashboard')) ?>">Dashboard</a>
                        <?php endif; ?>
                        <form class="logout-form" action="<?= e(url('/logout')) ?>" method="post">
                            <?= csrf() ?>
                            <button class="button-secondary" type="submit">Logout</button>
                        </form>
                    <?php else: ?>
                        <a class="nav-link" href="<?= e(url('/login')) ?>">Login</a>
                        <a class="button-primary" href="<?= e(url('/register')) ?>">Daftar</a>
                    <?php endif; ?>
                </div>
            </nav>
        </div>
    </header>
    <main>
        <?= $content ?>
    </main>
    <footer class="site-footer">
        <div class="container">
            <p>Fokus awal: register dan login dengan keamanan dasar yang sudah dipasang.</p>
        </div>
    </footer>
</div>
</body>
</html>
