<?php

include_once 'auth.php';
include_once '../config/database.php';
include_once '../template/lang.php';

$page = isset($_GET['page'])
    ? $_GET['page']
    : 'dashboard';

?>
<!DOCTYPE html>
<html lang="<?php echo h(current_lang()); ?>">

<head>

    <meta charset="UTF-8">

    <meta name="viewport"
          content="width=device-width, initial-scale=1.0">

    <title>Admin Dashboard — UK Trail Run 2026</title>

    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>

    <link rel="stylesheet"
      href="assets/css/admin.css?v=<?php echo time(); ?>">

    <link rel="icon"
          type="image/webp"
          href="../assets/img/logo.webp">

</head>

<body>

    <div class="admin-layout">

        <?php include 'navbar.php'; ?>

        <div class="sidebar-overlay" id="sidebarOverlay"></div>

        <div class="admin-main">

            <!-- TOPBAR -->
            <header class="topbar">

                <div class="topbar-left">

                    <button class="hamburger" id="hamburgerBtn"
                            aria-label="Toggle Menu">
                        <svg viewBox="0 0 24 24">
                            <line x1="3" y1="6" x2="21" y2="6"/>
                            <line x1="3" y1="12" x2="21" y2="12"/>
                            <line x1="3" y1="18" x2="21" y2="18"/>
                        </svg>
                    </button>

                    <span class="topbar-title">
                        <?php
                        switch($page){
                            case 'participants':
                                echo tr('Participants','Peserta');
                                break;
                            case 'verified_list':
                                echo tr('Verified List','Daftar Terverifikasi');
                                break;
                            case 'racepack':
                                echo 'Race Pack';
                                break;
                            case 'scanner':
                                echo 'QR Scanner';
                                break;
                            default:
                                echo tr('Dashboard','Dashboard');
                        }
                        ?>
                    </span>

                </div>

                <div class="topbar-right">

                    <span class="topbar-date">
                        <?php echo date('l, d M Y'); ?>
                    </span>

                    <div class="topbar-avatar">
                        <?php
                        echo strtoupper(
                            substr(
                                $_SESSION['admin_username'] ?? 'A',
                                0,
                                2
                            )
                        );
                        ?>
                    </div>

                </div>

            </header>

            <!-- CONTENT -->
            <div class="admin-content">

                <?php

                switch($page){

                    case 'participants':
                        include 'participants.php';
                        break;

                    case 'verified_list':
                        include 'verified_list.php';
                        break;

                    case 'scanner':
                        include 'scanner.php';
                        break;

                    case 'racepack':
                        include 'racepack.php';
                        break;

                    case 'dashboard':
                    default:
                        include 'dashboard.php';
                        break;

                        case 'rfid':
                    include 'rfid.php';
                    break;
                }
                ?>

            </div>

            <?php include 'footer.php'; ?>

        </div>

    </div>

    <script src="assets/js/admin.js?v=<?php echo time(); ?>"></script>

</body>
</html>