<?php
/**
 * Standard platform top navbar for CONSOLE (non-project) pages — brand, an optional
 * back link + page title on the left, and the uniform right cluster: notifications,
 * theme switcher and the account dropdown. Fixed / sticky.
 *
 * Required in scope: $baseUrl, $user.
 * Optional in scope (set BEFORE including):
 *   $navBrandLabel  string  — page title shown beside the brand mark
 *   $navBrandIcon   string  — bootstrap-icon name for the title (default 'hdd-stack')
 *   $navBack        array   — ['url'=>, 'label'=>, 'icon'=>?] a "back" link
 *   $navExtra       string  — raw HTML inserted at the start of the right cluster
 *                             (page-specific chips/buttons, e.g. a plan badge)
 *
 * Pages including this MUST load bootstrap.bundle.min.js (for the dropdowns) and add
 * top padding equal to the navbar height (~56px) to their scroll container.
 */
$__nbLabel = (string) ($navBrandLabel ?? '');
$__nbIcon  = (string) ($navBrandIcon ?? 'hdd-stack');
$__nbBack  = is_array($navBack ?? null) ? $navBack : null;
$__nbExtra = (string) ($navExtra ?? '');
?>
<nav class="navbar navbar-top navbar-dark bg-dark px-2 px-md-3 fixed-top shadow-sm" style="z-index:1040">
    <div class="d-flex align-items-center gap-2" style="min-width:0">
        <a class="navbar-brand d-flex align-items-center m-0" href="<?= htmlspecialchars((string) $baseUrl) ?>/projects" title="PPPHP">
            <?= \PpPhp\Core\Brand::mark(30, 'logo-svg flex-shrink-0') ?>
        </a>
        <?php if ($__nbLabel !== ''): ?>
            <span class="d-none d-md-inline text-white-50">/</span>
            <span class="d-none d-md-inline-flex align-items-center text-white fw-semibold text-truncate" style="max-width:230px">
                <i class="bi bi-<?= htmlspecialchars($__nbIcon) ?> me-2 text-primary"></i><?= htmlspecialchars($__nbLabel) ?>
            </span>
        <?php endif; ?>
        <?php if ($__nbBack !== null): ?>
            <a class="btn btn-sm btn-outline-light ms-1 ms-md-2" href="<?= htmlspecialchars((string) $__nbBack['url']) ?>"
               title="<?= htmlspecialchars((string) $__nbBack['label']) ?>">
                <i class="bi bi-<?= htmlspecialchars((string) ($__nbBack['icon'] ?? 'arrow-left')) ?>"></i>
                <span class="d-none d-md-inline ms-1"><?= htmlspecialchars((string) $__nbBack['label']) ?></span>
            </a>
        <?php endif; ?>
    </div>

    <div class="d-flex align-items-center gap-2">
        <?php if ($__nbExtra !== ''): echo $__nbExtra; endif; ?>
        <?php include constant('BASE_PATH') . '/core/views/notification-bell.php'; ?>
        <?php include constant('BASE_PATH') . '/core/views/theme-toggle.php'; ?>
        <?php include constant('BASE_PATH') . '/core/views/console-user-menu.php'; ?>
    </div>
</nav>
