<?php

declare(strict_types=1);

require_once __DIR__ . '/bootstrap.php';
require_once dirname(__DIR__) . '/core/csrf.php';
require_once dirname(__DIR__) . '/modules/transfers/helpers.php';

$loginCanvasRequested = isset($_GET['login']) && $_GET['login'] === '1';

$stats = [
    'clubs' => 0,
    'players' => 0,
    'fixtures' => 0,
    'news' => 0,
];
$nextMatches = [];
$latestPosts = [];
$standings = [];
$topScorers = [];
$transferWindowSnapshot = ['window' => null, 'countdown' => null];

try {
    $transferWindowSnapshot = transfer_active_window_snapshot();
    $stats['clubs'] = (int) db_fetch_value('SELECT COUNT(*) FROM clubs WHERE status = "active"');
    $stats['players'] = (int) db_fetch_value('SELECT COUNT(*) FROM players WHERE status = "active"');
    $stats['fixtures'] = (int) db_fetch_value('SELECT COUNT(*) FROM match_results WHERE result_status = "verified"');
    $stats['news'] = (int) db_fetch_value('SELECT COALESCE(SUM(home_score + away_score), 0) FROM match_results WHERE result_status = "verified"');

    $nextMatches = db_fetch_all(
        'SELECT f.id, f.matchday, f.match_date, f.match_time, f.status, f.stage_type, f.group_label, f.knockout_round,
            NULL AS postponement_reason,
            hc.name AS home_club, hc.short_name AS home_short_name, hc.logo AS home_club_logo,
            ac.name AS away_club, ac.short_name AS away_short_name, ac.logo AS away_club_logo,
            c.name AS competition_name, c.type AS competition_type, c.status AS competition_status, v.name AS venue_name,
            s.status AS season_status
         FROM fixtures f
         INNER JOIN clubs hc ON hc.id = f.home_club_id
         INNER JOIN clubs ac ON ac.id = f.away_club_id
         INNER JOIN competitions c ON c.id = f.competition_id
         INNER JOIN seasons s ON s.id = f.season_id
         LEFT JOIN venues v ON v.id = f.venue_id
         WHERE (
             f.status = "live"
             OR (
                 f.status IN ("scheduled", "postponed")
                 AND f.match_date IS NOT NULL
                 AND (
                     f.match_date > CURDATE()
                     OR (
                         f.match_date = CURDATE()
                         AND COALESCE(f.match_time, "23:59:59") >= CURTIME()
                     )
                 )
             )
         )
         ORDER BY
             CASE WHEN f.match_date IS NULL THEN 1 ELSE 0 END ASC,
             f.match_date ASC,
             CASE WHEN f.match_time IS NULL THEN 1 ELSE 0 END ASC,
             f.match_time ASC,
             f.id ASC
         LIMIT 2'
    );

    foreach ($nextMatches as $index => $match) {
        $nextMatches[$index]['countdown'] = null;

        if ($match['status'] !== 'scheduled' || ($match['season_status'] ?? '') !== 'active' || ($match['competition_status'] ?? '') !== 'active' || empty($match['match_date'])) {
            continue;
        }

        $deadline = strtotime(trim((string) $match['match_date'] . ' ' . (!empty($match['match_time']) ? (string) $match['match_time'] : '23:59:59')));
        if ($deadline === false) {
            continue;
        }

        $secondsRemaining = max(0, $deadline - time());
        $nextMatches[$index]['countdown'] = [
            'deadline_iso' => date('c', $deadline),
            'days_remaining' => (int) floor($secondsRemaining / 86400),
        ];
    }

    $latestPosts = db_fetch_all(
        'SELECT title, slug, fixture_id, body, featured_image, published_at, created_at
         FROM news_posts
         WHERE status = :status
         ORDER BY COALESCE(published_at, created_at) DESC
         LIMIT 6',
        ['status' => 'published']
    );

    $standings = db_fetch_all(
        'SELECT lt.position, lt.played, lt.goal_difference, lt.points, c.name AS club_name, cp.name AS competition_name
         FROM league_table lt
         INNER JOIN clubs c ON c.id = lt.club_id
         INNER JOIN competitions cp ON cp.id = lt.competition_id
         ORDER BY lt.points DESC, lt.goal_difference DESC, lt.goals_for DESC, lt.position ASC
         LIMIT 8'
    );

    $topScorers = db_fetch_all(
        'SELECT p.first_name, p.last_name, c.name AS club_name, SUM(ps.goals) AS total_goals
         FROM player_statistics ps
         INNER JOIN players p ON p.id = ps.player_id
         INNER JOIN clubs c ON c.id = ps.club_id
         GROUP BY ps.player_id, p.first_name, p.last_name, c.name
         HAVING SUM(ps.goals) > 0
         ORDER BY total_goals DESC, p.last_name ASC, p.first_name ASC
         LIMIT 10'
    );
} catch (Throwable) {
}

$publicOpenWindow = $transferWindowSnapshot['window'];
$publicWindowCountdown = $transferWindowSnapshot['countdown'];
$leagueLogoPath = league_logo_path();
?>
<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=0.4">
    <meta name="description" content="JLFC public portal for the Jalingo Local Football Council.">
    <title><?php echo e(league_short_name()); ?> - Public Portal</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;600;700&family=DM+Sans:wght@400;500;700&display=swap" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" rel="stylesheet">
    <link href="<?php echo e(asset_url('css/app.css')); ?>" rel="stylesheet">
</head>

<body class="public-body">
    <header class="public-hero public-home-hero">
        <div class="container py-4 py-lg-5">
            <nav class="navbar navbar-expand-lg navbar-dark px-0 mb-4">
                <div class="container-fluid px-0">
                    <a class="navbar-brand fw-bold" href="<?php echo e(base_url('app/public/index.php')); ?>">
                        <?php if ($leagueLogoPath !== null): ?>
                            <img class="navbar-brand-logo" src="<?php echo e(base_url($leagueLogoPath)); ?>" alt="<?php echo e(league_short_name()); ?> logo">
                        <?php endif; ?>
                        <span><?php echo e(league_short_name()); ?></span>
                    </a>
                    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#homePublicNav" aria-controls="homePublicNav" aria-expanded="false" aria-label="Toggle navigation">
                        <span class="navbar-toggler-icon"></span>
                    </button>
                    <div class="collapse navbar-collapse" id="homePublicNav">
                        <ul class="navbar-nav ms-auto gap-lg-2">
                            <?php foreach (public_navigation() as $item): ?>
                                <li class="nav-item"><a class="nav-link" href="<?php echo e(base_url($item['path'])); ?>"><?php echo e($item['label']); ?></a></li>
                            <?php endforeach; ?>
                        </ul>
                    </div>
                </div>
            </nav>

            <div class="row g-4 align-items-end mb-4">
                <div class="col-12">
                    <span class="hero-pill mb-3 d-inline-flex">
                        <?php if ($leagueLogoPath !== null): ?>
                            <img class="hero-pill-logo" src="<?php echo e(base_url($leagueLogoPath)); ?>" alt="<?php echo e(league_short_name()); ?> logo">
                        <?php else: ?>
                            <i class="bi bi-trophy"></i>
                        <?php endif; ?>
                        Official match centre
                    </span>
                    <h1 class="display-4 fw-bold mb-3"><?php echo e(league_name()); ?></h1>
                    <p class="lead text-white-50 mb-4">Follow fixtures, standings, league news, and transfer updates from the official JLFC public portal.</p>
                    <?php if ($publicOpenWindow !== null && $publicWindowCountdown !== null): ?>
                        <div class="panel-card public-transfer-countdown mb-4 d-inline-flex flex-column flex-md-row align-items-md-center gap-3" data-transfer-countdown data-deadline="<?php echo e($publicWindowCountdown['deadline_iso']); ?>">
                            <div>
                                <p class="eyebrow mb-1">Transfer window</p>
                                <strong><?php echo e($publicOpenWindow['name']); ?></strong>
                                <div class="small public-transfer-countdown-date">Window closes on <?php echo e(date('F j, Y', strtotime((string) $publicOpenWindow['end_date']))); ?>.</div>
                            </div>
                            <div class="ms-md-auto text-md-end">
                                <div class="small text-uppercase">Time remaining</div>
                                <div class="h5 mb-0" data-transfer-countdown-value><?php echo e((string) $publicWindowCountdown['days_remaining']); ?>d 00h 00m 00s</div>
                            </div>
                        </div>
                    <?php endif; ?>
                    <div class="d-flex flex-wrap gap-3">
                        <a class="btn btn-light btn-lg" href="#next-matches">Next matches</a>
                        <a class="btn btn-outline-light btn-lg" href="#latest-news">Latest news</a>
                    </div>
                </div>
            </div>

            <section id="next-matches" class="next-matches-strip">
                <div class="section-title-row mb-3">
                    <div>
                        <p class="eyebrow mb-1">Near the top</p>
                        <h2 class="h3 text-white mb-0">Next matches</h2>
                    </div>
                    <a class="btn btn-sm btn-outline-light" href="<?php echo e(base_url('app/public/fixtures.php')); ?>">Full fixtures</a>
                </div>

                <?php if ($nextMatches === []): ?>
                    <div class="panel-card">
                        <p class="text-muted mb-0">Next fixtures will appear here once scheduling is published.</p>
                    </div>
                <?php else: ?>
                    <div class="row g-3 homepage-match-rail">
                        <?php foreach ($nextMatches as $match): ?>
                            <?php $stageLabel = competition_stage_label($match); ?>
                            <div class="col-12 col-md-6 col-xl-6 homepage-match-card-col">
                                <article class="match-card homepage-match-card h-100">
                                    <div class="match-card-top">
                                        <div>
                                            <span class="eyebrow text-dark mb-0"><?php echo e($match['competition_name']); ?></span>
                                            <div class="match-card-stage"><?php echo e($stageLabel); ?></div>
                                        </div>
                                        <span class="match-status-pill"><?php echo e(ucfirst((string) $match['status'])); ?></span>
                                    </div>
                                    <?php if ($match['countdown'] !== null): ?>
                                        <div class="match-card-countdown" data-live-countdown data-deadline="<?php echo e($match['countdown']['deadline_iso']); ?>">
                                            <span class="small text-uppercase">Kickoff in</span>
                                            <strong data-live-countdown-value><?php echo e((string) $match['countdown']['days_remaining']); ?>d 00h 00m 00s</strong>
                                        </div>
                                    <?php elseif (($match['season_status'] ?? '') === 'paused'): ?>
                                        <div class="match-card-note">Season paused. Countdown resumes after the calendar is updated.</div>
                                    <?php elseif (($match['competition_status'] ?? '') === 'paused'): ?>
                                        <div class="match-card-note">Competition paused. Another competition may currently be active in this season.</div>
                                    <?php elseif ($match['status'] === 'postponed'): ?>
                                        <div class="match-card-note"><?php echo e($match['postponement_reason'] ?: 'Fixture postponed. A new date will be published.'); ?></div>
                                    <?php endif; ?>
                                    <div class="match-card-body">
                                        <div class="club-line club-line-with-logo">
                                            <div class="club-logo-chip">
                                                <?php if (!empty($match['home_club_logo'])): ?>
                                                    <img src="<?php echo e(base_url((string) $match['home_club_logo'])); ?>" alt="<?php echo e($match['home_club']); ?> logo">
                                                <?php else: ?>
                                                    <span><?php echo e($match['home_short_name'] ?: mb_substr((string) $match['home_club'], 0, 3)); ?></span>
                                                <?php endif; ?>
                                            </div>
                                            <div>
                                                <span><?php echo e($match['home_club']); ?></span>
                                                <strong><?php echo e($match['home_short_name'] ?: $match['home_club']); ?></strong>
                                            </div>
                                        </div>
                                        <div class="match-vs">vs</div>
                                        <div class="club-line club-line-with-logo">
                                            <div class="club-logo-chip">
                                                <?php if (!empty($match['away_club_logo'])): ?>
                                                    <img src="<?php echo e(base_url((string) $match['away_club_logo'])); ?>" alt="<?php echo e($match['away_club']); ?> logo">
                                                <?php else: ?>
                                                    <span><?php echo e($match['away_short_name'] ?: mb_substr((string) $match['away_club'], 0, 3)); ?></span>
                                                <?php endif; ?>
                                            </div>
                                            <div>
                                                <span><?php echo e($match['away_club']); ?></span>
                                                <strong><?php echo e($match['away_short_name'] ?: $match['away_club']); ?></strong>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="match-card-meta">
                                        <span><i class="bi bi-calendar-event"></i> <?php echo e(format_match_date_time($match['match_date'] ?? null, $match['match_time'] ?? null, 'Date TBC', 'Time TBC')); ?></span>
                                        <span><i class="bi bi-geo-alt"></i> <?php echo e($match['venue_name'] ?? 'Venue TBC'); ?></span>
                                    </div>
                                    <div class="match-card-actions mt-2">
                                        <a class="btn btn-outline-jlfc btn-sm w-100" href="<?php echo e(base_url('app/public/match-details.php?id=' . (int) $match['id'])); ?>">More</a>
                                    </div>
                                </article>
                            </div>
                        <?php endforeach; ?>
                    </div>
                <?php endif; ?>
            </section>
        </div>
    </header>

    <main class="container py-5" id="public-stats">
        <section class="row g-4 mb-5 homepage-stats-rail">
            <div class="col-12 col-md-6 col-xl-3 homepage-stat-col">
                <div class="public-stat-card"><strong><?php echo e((string) $stats['clubs']); ?></strong><span>Active clubs</span></div>
            </div>
            <div class="col-12 col-md-6 col-xl-3 homepage-stat-col">
                <div class="public-stat-card"><strong><?php echo e((string) $stats['players']); ?></strong><span>Registered players</span></div>
            </div>
            <div class="col-12 col-md-6 col-xl-3 homepage-stat-col">
                <div class="public-stat-card"><strong><?php echo e((string) $stats['fixtures']); ?></strong><span>Total matches played</span></div>
            </div>
            <div class="col-12 col-md-6 col-xl-3 homepage-stat-col">
                <div class="public-stat-card"><strong><?php echo e((string) $stats['news']); ?></strong><span>Total goals scored</span></div>
            </div>
        </section>

        <section class="row g-4 align-items-start">
            <div class="col-xl-3 order-2 order-xl-1">
                <aside class="standings-rail panel-card sticky-xl-top">
                    <div class="panel-card-header mb-3">
                        <div>
                            <p class="eyebrow mb-1">Left rail</p>
                            <h2 class="h4 mb-0">Table standings</h2>
                        </div>
                    </div>
                    <?php if ($standings === []): ?>
                        <p class="text-muted mb-0">Standings will appear after verified results are recorded.</p>
                    <?php else: ?>
                        <div class="standings-list">
                            <?php foreach ($standings as $row): ?>
                                <div class="standing-row">
                                    <div class="standing-rank"><?php echo e((string) $row['position']); ?></div>
                                    <div class="standing-club">
                                        <strong><?php echo e($row['club_name']); ?></strong>
                                        <span><?php echo e($row['competition_name']); ?></span>
                                    </div>
                                    <div class="standing-points">
                                        <strong><?php echo e((string) $row['points']); ?></strong>
                                        <span>PTS</span>
                                    </div>
                                </div>
                            <?php endforeach; ?>
                        </div>
                        <a class="btn btn-outline-jlfc btn-sm w-100 mt-3" href="<?php echo e(base_url('app/public/table.php')); ?>">Open full table</a>
                    <?php endif; ?>
                </aside>
            </div>

            <div class="col-xl-9 order-1 order-xl-2">
                <section id="latest-news" class="panel-card mb-4">
                    <div class="panel-card-header mb-3">
                        <div>
                            <p class="eyebrow mb-1">Middle page</p>
                            <h2 class="h3 mb-0">Latest news and transfer desk</h2>
                        </div>
                        <a class="btn btn-outline-jlfc btn-sm" href="<?php echo e(base_url('app/public/news.php')); ?>">All news</a>
                    </div>

                    <?php if ($latestPosts === []): ?>
                        <p class="text-muted mb-0">Latest league stories and transfer updates will appear here once news is published.</p>
                    <?php else: ?>
                        <div class="news-home-grid">
                            <?php foreach ($latestPosts as $index => $post): ?>
                                <?php $postUrl = absolute_url('app/public/news-details.php?slug=' . urlencode((string) $post['slug'])); ?>
                                <?php $postShareTitle = (string) $post['title']; ?>
                                <?php $postWhatsAppShareUrl = 'https://wa.me/?text=' . rawurlencode($postShareTitle . ' ' . $postUrl); ?>
                                <?php $postFacebookShareUrl = 'https://www.facebook.com/sharer/sharer.php?u=' . rawurlencode($postUrl); ?>
                                <article class="news-home-card <?php echo $index === 0 ? 'news-home-card-featured' : ''; ?>">
                                    <?php if (!empty($post['featured_image'])): ?>
                                        <img class="news-home-image" src="<?php echo e(base_url((string) $post['featured_image'])); ?>" alt="<?php echo e($post['title']); ?>">
                                    <?php endif; ?>
                                    <div class="news-home-copy">
                                        <p class="eyebrow mb-2"><?php echo $index === 0 ? 'Lead story' : 'News update'; ?></p>
                                        <h3 class="<?php echo $index === 0 ? 'h2' : 'h4'; ?> mb-2"><?php echo e($post['title']); ?></h3>
                                        <p class="text-muted mb-3"><?php echo e(mb_strimwidth(strip_tags((string) $post['body']), 0, $index === 0 ? 240 : 160, '...')); ?></p>
                                        <div class="news-home-meta">
                                            <span><?php echo e((string) ($post['published_at'] ?? $post['created_at'])); ?></span>
                                            <div class="d-flex gap-2 flex-wrap justify-content-end">
                                                <a class="btn btn-outline-jlfc btn-sm" href="<?php echo e(base_url('app/public/news-details.php?slug=' . urlencode((string) $post['slug']))); ?>">Read story</a>
                                                <?php if (!empty($post['fixture_id'])): ?>
                                                    <a class="btn btn-outline-jlfc btn-sm" href="<?php echo e(base_url('app/public/match-details.php?id=' . (int) $post['fixture_id'])); ?>">Match details</a>
                                                <?php endif; ?>
                                                <a class="btn btn-outline-jlfc btn-sm" href="<?php echo e($postWhatsAppShareUrl); ?>" target="_blank" rel="noopener noreferrer">
                                                    <i class="bi bi-whatsapp"></i> WhatsApp
                                                </a>
                                                <a class="btn btn-outline-jlfc btn-sm" href="<?php echo e($postFacebookShareUrl); ?>" target="_blank" rel="noopener noreferrer">
                                                    <i class="bi bi-facebook"></i> Facebook
                                                </a>
                                            </div>
                                        </div>
                                    </div>
                                </article>
                            <?php endforeach; ?>
                        </div>
                    <?php endif; ?>
                </section>

                <section class="panel-card mb-4">
                    <div class="panel-card-header">
                        <div>
                            <p class="eyebrow mb-1">Quick access</p>
                            <h2 class="h4 mb-0">Use the portal</h2>
                        </div>
                    </div>
                    <div class="row g-3 mt-1">
                        <div class="col-md-4">
                            <div class="feature-tile"><i class="bi bi-calendar-week"></i>
                                <div>
                                    <h4>Fixtures</h4>
                                    <p>Check scheduled matches, kickoff dates, and venue details from the latest fixture list.</p>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="feature-tile"><i class="bi bi-newspaper"></i>
                                <div>
                                    <h4>News</h4>
                                    <p>Read official league announcements, match stories, and verified transfer updates as they are published.</p>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="feature-tile"><i class="bi bi-graph-up-arrow"></i>
                                <div>
                                    <h4>Standings and scorers</h4>
                                    <p>Track the league table and open the top scorers panel at any time while browsing the public site.</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>

                <section class="public-badge-card">
                    <span class="eyebrow mb-2">League office</span>
                    <h2 class="h4 mb-2"><?php echo e(organization_name()); ?></h2>
                    <p class="mb-3 text-muted">Official updates, competition coverage, and match information from the JLFC management desk.</p>
                    <div class="hero-quick-stats">
                        <div><strong><?php echo e((string) $stats['clubs']); ?></strong><span>clubs</span></div>
                        <div><strong><?php echo e((string) $stats['players']); ?></strong><span>players</span></div>
                        <div><strong><?php echo e((string) $stats['news']); ?></strong><span>stories</span></div>
                    </div>
                </section>
            </div>
        </section>
    </main>

    <a class="floating-utility floating-utility-left" data-bs-toggle="offcanvas" href="#topScorersCanvas" role="button" aria-controls="topScorersCanvas">
        <i class="bi bi-stars"></i>
        <span>Top scorers</span>
    </a>
    <a class="floating-utility floating-utility-right" data-bs-toggle="offcanvas" href="#loginCanvas" role="button" aria-controls="loginCanvas">
        <i class="bi bi-box-arrow-in-right"></i>
        <span>Login</span>
    </a>

    <div class="offcanvas offcanvas-start scorers-canvas" tabindex="-1" id="topScorersCanvas" aria-labelledby="topScorersCanvasLabel">
        <div class="offcanvas-header">
            <div>
                <p class="eyebrow mb-1">Floating panel</p>
                <h2 class="h4 mb-0" id="topScorersCanvasLabel">Top scorers</h2>
            </div>
            <button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
        </div>
        <div class="offcanvas-body">
            <?php if ($topScorers === []): ?>
                <p class="text-muted mb-0">Top scorers will appear after player statistics are updated.</p>
            <?php else: ?>
                <div class="scorers-list">
                    <?php foreach ($topScorers as $index => $scorer): ?>
                        <div class="scorer-row">
                            <div class="scorer-rank"><?php echo e((string) ($index + 1)); ?></div>
                            <div class="scorer-player">
                                <strong><?php echo e(trim($scorer['first_name'] . ' ' . $scorer['last_name'])); ?></strong>
                                <span><?php echo e($scorer['club_name']); ?></span>
                            </div>
                            <div class="scorer-goals"><?php echo e((string) $scorer['total_goals']); ?></div>
                        </div>
                    <?php endforeach; ?>
                </div>
            <?php endif; ?>
        </div>
    </div>

    <div class="offcanvas offcanvas-end login-canvas" tabindex="-1" id="loginCanvas" aria-labelledby="loginCanvasLabel">
        <div class="offcanvas-header align-items-start">
            <div>
                <p class="eyebrow mb-1">Floating panel</p>
                <h2 class="h4 mb-1" id="loginCanvasLabel">Admin login</h2>
                <p class="text-muted mb-0">Open the secured JLFC backend from the homepage.</p>
            </div>
            <button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
        </div>
        <div class="offcanvas-body">
            <?php require dirname(__DIR__) . '/includes/flash.php'; ?>

            <form action="<?php echo e(base_url('login.php')); ?>" method="post" class="login-canvas-form" novalidate>
                <?php echo csrf_input(); ?>
                <div class="mb-3">
                    <label class="form-label" for="canvas-email">Email address</label>
                    <input class="form-control form-control-lg" id="canvas-email" name="email" type="email" value="<?php echo e((string) old('email')); ?>" required autocomplete="username">
                </div>
                <div class="mb-3">
                    <label class="form-label" for="canvas-password">Password</label>
                    <input class="form-control form-control-lg" id="canvas-password" name="password" type="password" required autocomplete="current-password">
                </div>
                <button type="submit" class="btn btn-jlfc btn-lg w-100 mb-3">
                    <i class="bi bi-shield-lock"></i>
                    Sign in to JLFC
                </button>
            </form>

            <div class="login-canvas-meta mb-3">
                <div>
                    <span class="label">Security</span>
                    <strong>Session and CSRF protected</strong>
                </div>
                <div>
                    <span class="label">Access</span>
                    <strong>League administration panel</strong>
                </div>
            </div>
        </div>
    </div>

    <?php render_public_notification_prompt(); ?>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
    <script src="<?php echo e(asset_url('js/app.js')); ?>"></script>
    <?php if ($loginCanvasRequested): ?>
        <script>
            document.addEventListener('DOMContentLoaded', function() {
                var loginCanvasElement = document.getElementById('loginCanvas');
                if (!loginCanvasElement || typeof bootstrap === 'undefined' || !bootstrap.Offcanvas) {
                    return;
                }

                bootstrap.Offcanvas.getOrCreateInstance(loginCanvasElement).show();
            });
        </script>
    <?php endif; ?>
</body>

</html>