<?php
require_once __DIR__ . '/functions.php';

$current_user = is_logged_in() ? get_user() : null;
$current_role = get_role();
?>
<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?= $page_title ?? 'ANATL Portal' ?></title>
    <link rel="stylesheet" href="<?= BASE_URL ?>/assets/css/style.css">
</head>
<body>
<header class="header">
    <div class="header__container">
        <div class="header__logo">
            <h1>ANATL</h1>
            <p>Airport Portal</p>
        </div>
        <nav class="header__nav">
            <a href="<?= BASE_URL ?>" class="nav-link">Beranda</a>
            <a href="<?= BASE_URL ?>/live-flights-3countries.php" class="nav-link">🌏 Live Flights 3</a>
            <a href="<?= BASE_URL ?>/live-flights.php" class="nav-link">🛰️ Jakarta Live</a>
            <a href="<?= BASE_URL ?>/penerbangan.php" class="nav-link">Penerbangan</a>
            <a href="<?= BASE_URL ?>/fasilitas.php" class="nav-link">Fasilitas</a>
            <a href="<?= BASE_URL ?>/kepabeanan.php" class="nav-link">Kepabeanan</a>
            <a href="<?= BASE_URL ?>/tenant-unit.php" class="nav-link">Unit Sewa</a>
            <?php if ($current_user): ?>
                <span class="nav-user"><?= esc($current_user['username']) ?> (<?= esc($current_user['role']) ?>)</span>
                <a href="<?= BASE_URL ?>/logout.php" class="nav-link nav-link--danger">Keluar</a>
            <?php else: ?>
                <a href="<?= BASE_URL ?>/login.php" class="nav-link nav-link--primary">Masuk</a>
            <?php endif; ?>
        </nav>
    </div>
</header>

<?php if ($flash = get_flash()): ?>
<div class="alert alert--<?= esc($flash['type']) ?>">
    <?= esc($flash['msg']) ?>
</div>
<?php endif; ?>

<main class="main">
