<?php
$requiresWhatsappVerification = !empty($requiresWhatsappVerification);
$profileLink = $requiresWhatsappVerification ? page_url('VerifyWhatsapp') : page_url('Profile');
$profileLabel = $requiresWhatsappVerification ? 'Verifikasi WhatsApp' : 'Profile';
$profileIcon = $requiresWhatsappVerification ? 'bi-whatsapp' : 'bi-person';
$currentPageTitle = $pageTitles[$page ?? 'dashboard'] ?? 'Dashboard';
$agentName = trim((string)($data_admin['agent_name'] ?? 'Agent'));
$agentLevel = trim((string)($data_admin['agent_level'] ?? 'agent'));
$agentInitial = strtoupper(substr($agentName !== '' ? $agentName : 'A', 0, 1));
?>
<header>
    <nav class="navbar navbar-expand navbar-light navbar-top app-navbar-modern">
        <div class="container-fluid">
            <a href="#" class="burger-btn d-block nav-icon-button" aria-label="Toggle sidebar">
                <span class="hamburger-lines" aria-hidden="true"></span>
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse"
                data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
                aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarSupportedContent">
                <div class="nav-page-context d-none d-md-flex">
                    <div>
                        <div class="nav-page-label">Current Page</div>
                        <div class="nav-page-title"><?= htmlspecialchars($currentPageTitle, ENT_QUOTES, 'UTF-8') ?></div>
                    </div>
                </div>
                <div class="nav-announcement d-none d-xl-flex align-items-center flex-grow-1 mx-3">
                    <i class="bi bi-megaphone"></i>
                    <div class="nav-announcement-text">
                        <span><?= isset($annountcement) ? $annountcement : ''; ?></span>
                    </div>
                </div>
                <div class="dropdown ms-auto">
                    <a href="#" class="user-menu-modern" data-bs-toggle="dropdown" aria-expanded="false">
                        <div class="user-menu d-flex align-items-center">
                            <div class="user-name text-end me-2 d-none d-sm-block">
                                <h6 class="mb-0"><?= htmlspecialchars($agentName, ENT_QUOTES, 'UTF-8') ?></h6>
                                <p class="mb-0"><?= htmlspecialchars(strtoupper($agentLevel), ENT_QUOTES, 'UTF-8') ?></p>
                            </div>
                            <div class="user-img d-flex align-items-center">
                                <div class="nav-avatar">
                                    <i class="bi bi-person-fill"></i>
                                </div>
                            </div>
                        </div>
                    </a>
                    <ul class="dropdown-menu dropdown-menu-end nav-profile-menu" aria-labelledby="navbarSupportedContent">
                        <li>
                            <h6 class="dropdown-header">Hello, <?= htmlspecialchars($agentName !== '' ? $agentName : 'Agent', ENT_QUOTES, 'UTF-8') ?>!</h6>
                        </li>
                        <li>
                            <a class="dropdown-item" href="<?php echo $profileLink; ?>">
                                <i class="icon-mid bi <?php echo $profileIcon; ?> me-2"></i> <?php echo $profileLabel; ?>
                            </a>
                        </li>
                        <li>
                            <a class="dropdown-item" href="function/log-out.php">
                                <i class="icon-mid bi bi-box-arrow-left me-2"></i> Log Out
                            </a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </nav>
</header>
