<?php
require_once JLFC_ROOT . '/app/core/csrf.php';
require_once JLFC_ROOT . '/app/modules/transfers/helpers.php';

$user = current_user();
$transferWindowSnapshot = transfer_active_window_snapshot();
$topbarWindow = $transferWindowSnapshot['window'];
$topbarCountdown = $transferWindowSnapshot['countdown'];
?>
<header class="topbar-panel">
    <div class="d-flex align-items-center gap-3">
        <button class="btn btn-topbar-icon d-lg-none" type="button" data-sidebar-toggle>
            <i class="bi bi-list"></i>
        </button>
        <div>
            <p class="eyebrow mb-1">Jalingo Local Football Council</p>
            <h1 class="page-heading mb-0"><?php echo e($pageTitle ?? 'Dashboard'); ?></h1>
        </div>
    </div>

    <div class="topbar-actions">
        <?php if ($topbarWindow !== null && $topbarCountdown !== null): ?>
            <div class="topbar-meta" data-transfer-countdown data-deadline="<?php echo e($topbarCountdown['deadline_iso']); ?>">
                <i class="bi bi-hourglass-split text-success"></i>
                <span>
                    <strong><?php echo e($topbarWindow['name']); ?></strong>
                    closes in
                    <span data-transfer-countdown-value><?php echo e((string) $topbarCountdown['days_remaining']); ?>d 00h 00m 00s</span>
                </span>
            </div>
        <?php endif; ?>
        <div class="topbar-meta d-none d-md-flex">
            <i class="bi bi-shield-check"></i>
            <span>Secure admin session</span>
        </div>
        <div class="topbar-profile">
            <span class="topbar-profile-name"><?php echo e($user['full_name'] ?? ''); ?></span>
            <span class="badge text-bg-light"><?php echo e($user['role_name'] ?? ''); ?></span>
        </div>
        <form action="<?php echo e(base_url('logout.php')); ?>" method="post" class="m-0">
            <?php echo csrf_input(); ?>
            <button type="submit" class="btn btn-outline-jlfc">
                <i class="bi bi-box-arrow-right"></i>
                Sign out
            </button>
        </form>
    </div>
</header>
<main class="admin-content container-fluid py-4">
    <?php render_module_page_navigation(); ?>