<!DOCTYPE html>
<html lang="pt-BR">
<head>
    <meta charset="UTF-8">
    <title>Painel RH</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/2.0.8/css/dataTables.bootstrap5.css">
    <link rel="stylesheet" href="<?= e(asset('css/app.css')) ?>?v=<?= @filemtime(dirname(__DIR__, 3) . '/public/assets/css/app.css') ?>">
</head>
<body class="bg-admin">
<?php
use App\Models\AdminUser;

$currentPath = parse_url($_SERVER['REQUEST_URI'] ?? '', PHP_URL_PATH) ?: '';
$isAdmissionsRoute = str_contains($currentPath, '/admin/admissoes');
$isUsersRoute = str_contains($currentPath, '/admin/usuarios');
$isDiagnosticsRoute = str_contains($currentPath, '/admin/diagnostico');
$canManageAdmins = AdminUser::isAdmin($adminUser ?? null);
?>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark shadow-sm">
    <div class="container-fluid px-4 gap-3">
        <a class="navbar-brand fw-semibold" href="<?= e(baseUrl('admin/admissoes')) ?>">Painel RH</a>

        <div class="d-flex flex-wrap align-items-center gap-2 me-auto">
            <a href="<?= e(baseUrl('admin/admissoes')) ?>" class="btn btn-sm <?= $isAdmissionsRoute ? 'btn-light text-dark' : 'btn-outline-light' ?>">Admissões</a>

            <?php if ($canManageAdmins): ?>
                <a href="<?= e(baseUrl('admin/usuarios')) ?>" class="btn btn-sm <?= $isUsersRoute ? 'btn-light text-dark' : 'btn-outline-light' ?>">Usuários do painel</a>
                <a href="<?= e(baseUrl('admin/diagnostico')) ?>" class="btn btn-sm <?= $isDiagnosticsRoute ? 'btn-light text-dark' : 'btn-outline-light' ?>">Diagnóstico</a>
            <?php endif; ?>
        </div>

        <div class="d-flex align-items-center gap-3 text-white">
            <span class="small text-white-50">
                <?= e($adminUser['name'] ?? 'Usuário') ?>
                <?php if (!empty($adminUser['role'])): ?>
                    • <?= e(AdminUser::roleLabel((string) $adminUser['role'])) ?>
                <?php endif; ?>
            </span>
            <a href="<?= e(baseUrl('admin/logout')) ?>" class="btn btn-outline-light btn-sm">Sair</a>
        </div>
    </div>
</nav>
<main class="container-fluid py-4 px-lg-4"><?= $content ?></main>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="https://cdn.datatables.net/2.0.8/js/dataTables.js"></script>
<script src="https://cdn.datatables.net/2.0.8/js/dataTables.bootstrap5.js"></script>
<script src="<?= e(asset('js/app.js')) ?>?v=<?= @filemtime(dirname(__DIR__, 3) . '/public/assets/js/app.js') ?>"></script>
</body>
</html>
