<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Admin Dashboard</title>

    <script src="https://cdn.tailwindcss.com"></script>

    <script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>

    <style>
        /* Prevent layout flicker before Alpine loads */
        [x-cloak] { display: none !important; }
        
        .custom-scrollbar::-webkit-scrollbar { width: 4px; }
        .custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
        .custom-scrollbar::-webkit-scrollbar-thumb { background: #4b5563; border-radius: 10px; }
    </style>
</head>
<body class="bg-gray-100 font-sans antialiased">

<div x-data="{ sidebarOpen: false, openMenu: null }" class="flex flex-col h-screen overflow-hidden">

    <header class="z-50 flex items-center justify-between px-6 py-2 bg-gray-900 shadow-lg sticky top-0">
        <div class="flex items-center space-x-4">
            <button @click="sidebarOpen = !sidebarOpen" class="text-gray-300 hover:text-white transition-colors focus:outline-none">
                <i data-lucide="menu" class="w-6 h-6"></i>
            </button>

            <a href="#" class="flex items-center text-white font-bold text-lg tracking-wider uppercase">
                <i data-lucide="zap" class="w-5 h-5 mr-2 text-blue-500"></i>
                <span>Admin<span class="text-blue-500">Panel</span></span>
            </a>
        </div>

        <div class="flex items-center space-x-4">
            <div class="relative" x-data="{ notifyOpen: false }" @click.away="notifyOpen = false">
                <button @click="notifyOpen = !notifyOpen" class="relative p-2 text-gray-300 hover:text-white transition-colors">
                    <i data-lucide="bell" class="w-6 h-6"></i>
                    <span class="absolute top-1.5 right-1.5 flex h-2.5 w-2.5">
                        <span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-red-400 opacity-75"></span>
                        <span class="relative inline-flex rounded-full h-2.5 w-2.5 bg-red-500 border-2 border-gray-900"></span>
                    </span>
                </button>

                <div x-show="notifyOpen" x-cloak x-transition 
                     class="absolute right-0 mt-3 w-80 bg-gray-800 border border-gray-700 rounded-xl shadow-2xl overflow-hidden">
                    <div class="px-4 py-3 border-b border-gray-700 flex justify-between items-center bg-gray-900/50">
                        <span class="text-white font-semibold">Notifications</span>
                        <button class="text-xs text-blue-400 hover:underline">Mark all read</button>
                    </div>
                    <div class="max-h-64 overflow-y-auto custom-scrollbar">
                        <a href="#" class="block px-4 py-3 hover:bg-gray-700 transition border-b border-gray-700 last:border-0">
                            <p class="text-sm text-gray-200">New system alert: Server load high</p>
                            <span class="text-[10px] text-gray-500 uppercase">2 mins ago</span>
                        </a>
                        <a href="#" class="block px-4 py-3 hover:bg-gray-700 transition">
                            <p class="text-sm text-gray-200">New user registration</p>
                            <span class="text-[10px] text-gray-500 uppercase">1 hour ago</span>
                        </a>
                    </div>
                </div>
            </div>

            <div class="relative" x-data="{ profileOpen: false }" @click.away="profileOpen = false">
                <button @click="profileOpen = !profileOpen" class="flex items-center space-x-3 text-gray-300 hover:text-white transition-colors focus:outline-none">
                    <div class="h-8 w-8 rounded-full bg-gradient-to-tr from-blue-500 to-indigo-600 flex items-center justify-center text-white font-bold text-xs">
                        AD
                    </div>
                    <i data-lucide="chevron-down" class="w-4 h-4 transition-transform" :class="profileOpen ? 'rotate-180' : ''"></i>
                </button>

                <div x-show="profileOpen" x-cloak x-transition 
                     class="absolute right-0 mt-3 w-48 bg-gray-800 border border-gray-700 rounded-xl shadow-2xl py-2">
                    <a href="#" class="flex items-center px-4 py-2 text-sm text-gray-300 hover:bg-gray-700 hover:text-white transition">
                        <i data-lucide="user" class="w-4 h-4 mr-3"></i> My Profile
                    </a>
                    <a href="#" class="flex items-center px-4 py-2 text-sm text-gray-300 hover:bg-gray-700 hover:text-white transition">
                        <i data-lucide="settings" class="w-4 h-4 mr-3"></i> Settings
                    </a>
                    <hr class="my-2 border-gray-700">
                    <a href="#" class="flex items-center px-4 py-2 text-sm text-red-400 hover:bg-gray-700 transition">
                        <i data-lucide="log-out" class="w-4 h-4 mr-3"></i> Logout
                    </a>
                </div>
            </div>
        </div>
    </header>

    <div class="flex flex-1 overflow-hidden">
        <div x-show="sidebarOpen" 
             @click="sidebarOpen = false" 
             x-transition:enter="transition opacity-0 ease-out duration-300"
             x-transition:enter-start="opacity-0"
             x-transition:enter-end="opacity-100"
             x-transition:leave="transition opacity-100 ease-in duration-200"
             class="fixed inset-0 z-40 bg-black/50 lg:hidden" x-cloak>
        </div>

        <aside :class="sidebarOpen ? 'translate-x-0' : '-translate-x-full'"
               class="fixed inset-y-0 left-0 z-50 w-64 transition-transform duration-300 transform bg-gray-900 border-r border-gray-800 lg:translate-x-0 lg:static lg:inset-0 flex flex-col">
            
            <nav class="flex-1 mt-6 px-4 space-y-2 overflow-y-auto custom-scrollbar">
                <a href="#" class="flex items-center px-4 py-3 text-sm font-medium text-white bg-blue-600 rounded-lg">
                    <i data-lucide="layout-dashboard" class="w-5 h-5 mr-3"></i> Dashboard
                </a>

                <div class="pt-4 pb-2 text-[10px] font-bold uppercase tracking-widest text-gray-500 px-4">
                    Management
                </div>

                <div>
                    <button @click="openMenu === 'users' ? openMenu = null : openMenu = 'users'" 
                            class="w-full flex items-center justify-between px-4 py-3 text-sm font-medium text-gray-400 rounded-lg hover:bg-gray-800 hover:text-white transition">
                        <div class="flex items-center">
                            <i data-lucide="users" class="w-5 h-5 mr-3"></i> Users
                        </div>
                        <i data-lucide="chevron-right" class="w-4 h-4 transition-transform" :class="openMenu === 'users' ? 'rotate-90' : ''"></i>
                    </button>
                    <div x-show="openMenu === 'users'" x-cloak x-transition class="mt-1 space-y-1 pl-12">
                        <a href="#" class="block py-2 text-sm text-gray-500 hover:text-white">All Users</a>
                        <a href="#" class="block py-2 text-sm text-gray-500 hover:text-white">Permissions</a>
                    </div>
                </div>

                <a href="#" class="flex items-center px-4 py-3 text-sm font-medium text-gray-400 rounded-lg hover:bg-gray-800 hover:text-white transition">
                    <i data-lucide="database" class="w-5 h-5 mr-3"></i> Financials
                </a>
                
                <a href="#" class="flex items-center px-4 py-3 text-sm font-medium text-gray-400 rounded-lg hover:bg-gray-800 hover:text-white transition">
                    <i data-lucide="shield-check" class="w-5 h-5 mr-3"></i> Security
                </a>
            </nav>

            <div class="p-4 bg-gray-950/50 border-t border-gray-800">
                <div class="text-[10px] text-gray-600 text-center uppercase tracking-tighter">System Version 4.0.2</div>
            </div>
        </aside>

        <main class="flex-1 overflow-y-auto p-8">
            <div class="max-w-7xl mx-auto">
                <h1 class="text-2xl font-bold text-gray-800">Welcome back, Admin!</h1>
                <p class="text-gray-500 mt-2">Everything is running smoothly today.</p>
                
                <div class="mt-8 grid grid-cols-1 md:grid-cols-3 gap-6">
                    <div class="bg-white p-6 rounded-2xl shadow-sm border border-gray-200 h-32"></div>
                    <div class="bg-white p-6 rounded-2xl shadow-sm border border-gray-200 h-32"></div>
                    <div class="bg-white p-6 rounded-2xl shadow-sm border border-gray-200 h-32"></div>
                </div>
            </div>
        </main>
    </div>
</div>

<script src="https://unpkg.com/lucide@latest"></script>
<script>
    // Initialize icons
    lucide.createIcons();
    
    // If using Livewire or dynamic content, call this after DOM updates:
    // lucide.createIcons();
</script>

</body>
</html>