    </div><!-- /admin-content -->
    <footer class="admin-footer">
        &copy; <?= date('Y') ?> <?= e($siteName ?? 'Admin') ?> —
        <a href="<?= BASE_URL ?>/index.php" target="_blank">সাইট দেখুন</a>
        <a href="<?= BASE_URL ?>/logout.php">লগআউট</a>
    </footer>
</div><!-- /admin-main -->
</div><!-- /admin-wrapper -->

<script>
// ── Sidebar toggle ──────────────────────────────────────────
(function(){
    var sidebar  = document.getElementById('adminSidebar');
    var overlay  = document.getElementById('sidebarOverlay');
    var btn      = document.getElementById('sidebarToggle');
    if(!sidebar||!overlay||!btn) return;

    function open(){
        sidebar.classList.add('open');
        overlay.classList.add('open');
        document.body.style.overflow='hidden';
        btn.setAttribute('aria-expanded','true');
    }
    function close(){
        sidebar.classList.remove('open');
        overlay.classList.remove('open');
        document.body.style.overflow='';
        btn.setAttribute('aria-expanded','false');
    }

    btn.addEventListener('click', function(){
        sidebar.classList.contains('open') ? close() : open();
    });
    overlay.addEventListener('click', close);

    // Close on nav link click (mobile)
    sidebar.querySelectorAll('.sidebar-link').forEach(function(link){
        link.addEventListener('click', function(){
            if(window.innerWidth <= 900) close();
        });
    });

    // Escape key
    document.addEventListener('keydown', function(e){
        if(e.key==='Escape') close();
    });
})();

// ── Page title in topbar ────────────────────────────────────
(function(){
    var el = document.querySelector('.admin-content h2');
    var t  = document.getElementById('pageTitle');
    if(el && t) t.textContent = el.textContent.trim();
})();

// ── Confirm delete ──────────────────────────────────────────
document.querySelectorAll('[data-confirm]').forEach(function(el){
    el.addEventListener('click', function(e){
        if(!confirm(this.dataset.confirm || 'আপনি কি নিশ্চিত?')) e.preventDefault();
    });
});

// ── Auto-hide alerts ────────────────────────────────────────
setTimeout(function(){
    document.querySelectorAll('.alert').forEach(function(a){
        a.style.transition='opacity .5s';
        a.style.opacity='0';
        setTimeout(function(){if(a.parentNode)a.parentNode.removeChild(a);},500);
    });
}, 5000);
</script>
</body>
</html>
