<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Secure Terminal | Dashboard</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600&family=Inter:wght@300;400;500;600&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Inter', sans-serif;
            background-color: #0a0e17;
            background-image: 
                radial-gradient(circle at 20% 50%, rgba(16, 185, 129, 0.02) 0%, transparent 50%),
                radial-gradient(circle at 80% 80%, rgba(59, 130, 246, 0.02) 0%, transparent 50%);
            color: #cbd5e1;
        }
        .mono { font-family: 'JetBrains Mono', monospace; }
        
        /* Terminal UI Elements */
        .glass-panel {
            background-color: rgba(15, 23, 42, 0.8);
            backdrop-filter: blur(4px);
            border: 1px solid #1e293b;
        }
        
        .corner-bracket {
            position: absolute;
            width: 8px;
            height: 8px;
            border: 2px solid rgba(16, 185, 129, 0.4);
        }
        .corner-tl { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
        .corner-tr { top: -1px; right: -1px; border-left: 0; border-bottom: 0; }
        .corner-bl { bottom: -1px; left: -1px; border-right: 0; border-top: 0; }
        .corner-br { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

        /* Sidebar Hover Effects */
        .nav-item:hover .nav-cursor { opacity: 1; transform: translateX(0); }
        .nav-cursor { opacity: 0; transform: translateX(-10px); transition: all 0.2s; }
    </style>
</head>
<body class="min-h-screen flex flex-col">

    <header class="glass-panel sticky top-0 z-50 border-b border-slate-800">
        <div class="px-6 py-4 flex items-center justify-between">
            
            <div class="flex items-center gap-4">
                <button id="mobile-menu-btn" class="md:hidden text-slate-400 hover:text-emerald-400 focus:outline-none transition-colors">
                    <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"></path></svg>
                </button>

                <div class="relative flex h-3 w-3">
                  <span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"></span>
                  <span class="relative inline-flex rounded-full h-3 w-3 bg-emerald-500"></span>
                </div>
                <span class="mono text-sm text-emerald-500 tracking-widest font-semibold hidden sm:inline-block">SYS.ADMIN_NODE</span>
            </div>

            <div class="flex items-center gap-6">
                <div class="text-right hidden md:block">
                    <div class="mono text-xs text-slate-400">USER: <span class="text-slate-200"><?php echo htmlspecialchars($_SESSION['admin_username'] ?? 'UNKNOWN'); ?></span></div>
                    <div class="mono text-[10px] text-slate-500">IP: <?php echo $_SERVER['REMOTE_ADDR']; ?></div>
                </div>
                
                <a href="logout.php" class="mono text-xs px-4 py-2 border border-red-500/30 text-red-400 rounded hover:bg-red-500/10 hover:border-red-500/50 transition-all">
                    [ DISCONNECT ]
                </a>
            </div>
        </div>
    </header>

    <script>
        document.addEventListener('DOMContentLoaded', () => {
            const btn = document.getElementById('mobile-menu-btn');
            const sidebar = document.getElementById('admin-sidebar');
            const overlay = document.getElementById('sidebar-overlay');

            function toggleSidebar() {
                // Check if sidebar is open
                const isOpen = sidebar.classList.contains('translate-x-0');
                
                if (isOpen) {
                    // Close sidebar
                    sidebar.classList.remove('translate-x-0');
                    sidebar.classList.add('-translate-x-full');
                    overlay.classList.add('hidden', 'opacity-0');
                    overlay.classList.remove('opacity-100');
                } else {
                    // Open sidebar
                    sidebar.classList.remove('-translate-x-full');
                    sidebar.classList.add('translate-x-0');
                    overlay.classList.remove('hidden');
                    // Timeout ensures CSS transition applies after removing 'hidden'
                    setTimeout(() => {
                        overlay.classList.remove('opacity-0');
                        overlay.classList.add('opacity-100');
                    }, 10);
                }
            }

            if(btn) btn.addEventListener('click', toggleSidebar);
            if(overlay) overlay.addEventListener('click', toggleSidebar);
        });
    </script>