<?php 
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}
 
// if (!isset($_SESSION['id'])) {
//     header("Location: login.php");
//     exit();
// }
if (isset($_SESSION['last_activity']) && time() - $_SESSION['last_activity'] > 1000) {
 session_unset(); // unset $_SESSION variable 
 session_destroy(); // destroy session data in storage
 header("Location: login.php"); // redirect to login page
}
$_SESSION['last_activity'] = time(); // update last activity time stamp
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Mail Management System</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">

    <!-- Custom CSS -->
    <style>
        body {
            background-color: #fff;
        }
        .navbar {
            background-color: orange;
        }
        .navbar-brand, .nav-link, .text-white {
            color: #fff !important;
        }
        .sidebar {
            background-color: #f8f9fa;
            min-height: 100vh;
            padding-top: 20px;
        }
        .sidebar a {
            color: orange;
            font-weight: bold;
        }
        .sidebar a:hover {
            background-color: orange;
            color: white !important;
        }
    </style>
</head>
<body>
<!-- <div id="sidebarOverlay" class="sidebar-overlay"></div> -->

<nav class="navbar navbar-expand-lg navbar-dark">
    <div class="container-fluid">
        <div class="bg-orange p-2 d-flex align-items-center">
    <i class="bi bi-list menu-toggle me-3" id="menuToggle"></i>
    <span class="text-white fw-bold">Admin Dashboard</span>
</div>
        <a class="navbar-brand" href="dashboard.php"><img src="../images/anambra.png" height="50px" width="50px"> </a>




        <div class="d-flex">
            <span class="text-white me-3">Mayor</span>
            <a href="logout.php" class="btn btn-light btn-sm">Logout</a>
        </div>
    </div>
</nav>
<div class="container-fluid">
    <div class="row">
<!-- <script>
    document.getElementById('menuToggle').addEventListener('click', function () {
        document.getElementById('sidebar').classList.toggle('collapsed');
    });
</script> -->
<!-- <script>
    const menuToggle = document.getElementById('menuToggle');
    const sidebar = document.getElementById('sidebar');
    const overlay = document.getElementById('sidebarOverlay');

    menuToggle.addEventListener('click', () => {
        if (window.innerWidth <= 768) {
            // Mobile behavior
            sidebar.classList.toggle('mobile-open');
            overlay.classList.toggle('show');
        } else {
            // Desktop behavior
            sidebar.classList.toggle('collapsed');
        }
    });

    // Close sidebar when overlay is clicked (mobile)
    overlay.addEventListener('click', () => {
        sidebar.classList.remove('mobile-open');
        overlay.classList.remove('show');
    });

    // Auto-reset when resizing screen
    window.addEventListener('resize', () => {
        if (window.innerWidth > 768) {
            sidebar.classList.remove('mobile-open');
            overlay.classList.remove('show');
        }
    });
</script> -->
<script>
    document.addEventListener("DOMContentLoaded", function () {
        const menuToggle = document.getElementById("menuToggle");
        const sidebar = document.getElementById("sidebar");

        if (!menuToggle || !sidebar) {
            console.error("Menu toggle or sidebar not found");
            return;
        }

        menuToggle.addEventListener("click", function () {
            if (window.innerWidth <= 768) {
                // Mobile slide-in behavior
                sidebar.classList.toggle("mobile-open");
            } else {
                // Desktop collapse behavior
                sidebar.classList.toggle("collapsed");
            }
        });
    });
</script>


