<?php
// Proteksi hanya untuk role guru
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

if (!isset($_SESSION['user']) || $_SESSION['user']['role'] !== 'guru') {
    header("Location: /presensi_v1/preview.php");
    exit;
}
?>

<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">

<title>Dashboard - Guru</title>
<meta name="viewport" content="width=device-width, initial-scale=1">

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css" rel="stylesheet">

<!-- FONT POPPINS -->
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">

<!-- MAIN STYLE -->
<link rel="stylesheet" href="/presensi_v1/assets/css/style.css">

<!-- SweetAlert2 -->
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>

</head>

<script>
// Live clock
function updateLiveClock() {
    const el = document.getElementById("nav-live-clock");
    if (!el) return;

    const now = new Date();
    const time = now.toLocaleTimeString("id-ID", {
        hour: "2-digit",
        minute: "2-digit",
        second: "2-digit"
    });

    el.innerText = time + " WIB";
}

document.addEventListener("DOMContentLoaded", () => {
    updateLiveClock();
    setInterval(updateLiveClock, 1000);
});
</script>

<body>

<!-- HEADER TOP -->
<nav class="navbar matrix-header shadow-sm">
    <div class="container-fluid d-flex justify-content-between align-items-center">

        <!-- LEFT: BRAND -->
        <div class="d-flex align-items-center">
            <button class="btn btn-sm btn-dark me-3" id="sidebarToggle">
                <i class="bi bi-list"></i>
            </button>

            <span class="matrix-brand">Presensi <span class="brand-light">V1</span></span>
        </div>

        <!-- RIGHT -->
        <div class="d-flex align-items-center gap-3">
            <div class="text-white fw-bold" id="nav-live-clock">00:00:00</div>

            <span class="text-white fw-semibold">
                Guru
            </span>

            <a href="/presensi_v1/auth/logout.php" class="btn btn-danger btn-sm">
                Logout
            </a>
        </div>
    </div>
</nav>

<!-- SIDEBAR GURU -->
<div id="matrixSidebar" class="matrix-sidebar">
    <ul class="matrix-menu">

        <!-- MENU KHUSUS GURU -->
        <li>
            <a href="/presensi_v1/pages/dashboard_guru.php">
                <i class="bi bi-graph-up"></i>
                <span>Dashboard</span>
            </a>
        </li>

        <li>
            <a href="/presensi_v1/pages/rekap.php">
                <i class="bi bi-person-vcard-fill"></i>
                <span>Presensi Siswa</span>
            </a>
        </li>

    </ul>
</div>

<!-- MAIN CONTENT WRAPPER -->
<div class="matrix-content">
