<?php

declare(strict_types=1);

final class Navbar
{
    public static function render(array $config, ?array $user): string
    {
        $appName = (string)($config['app']['name'] ?? 'App');
        $fullName = (string)($user['full_name'] ?? '');
        $email = (string)($user['email'] ?? '');

        ob_start();
        ?>
        <header class="border-b bg-white">
            <div class="mx-auto max-w-7xl px-4 py-4 flex items-center justify-between">
                <div class="font-semibold tracking-tight"><?= e($appName) ?></div>
                <div class="flex items-center gap-3">
                    <div class="text-right">
                        <div class="text-sm font-medium leading-tight"><?= e($fullName) ?></div>
                        <div class="text-xs text-slate-500 leading-tight"><?= e($email) ?></div>
                    </div>
                    <a class="inline-flex items-center justify-center rounded-lg border px-3 py-2 text-sm hover:bg-slate-50" href="/pest/public/logout.php">Logout</a>
                </div>
            </div>
        </header>
        <?php
        return (string)ob_get_clean();
    }
}
