<!DOCTYPE html>
<html lang="en" class="dark">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AnonChat Admin - Enterprise</title>
    
    <!-- Tailwind CSS -->
    <script src="https://cdn.tailwindcss.com"></script>
    <script>
        tailwind.config = {
            darkMode: 'class',
            theme: {
                extend: {
                    colors: {
                        primary: '#6366f1', // Indigo 500
                        secondary: '#ec4899', // Violet 500
                        dark: '#0f172a', // Slate 900
                        darker: '#020617', // Slate 950
                        surface: '#1e293b', // Slate 800
                    }
                }
            }
        }
    </script>

    <!-- Alpine.js -->
    <script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
    
    <!-- Icons -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">

    <style>
        [x-cloak] { display: none !important; }
        /* Custom Scrollbar */
        ::-webkit-scrollbar { width: 6px; height: 6px; }
        ::-webkit-scrollbar-track { background: #0f172a; }
        ::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
        ::-webkit-scrollbar-thumb:hover { background: #475569; }
    </style>
</head>
<body class="bg-darker text-gray-100 font-sans antialiased" x-data="{ sidebarOpen: true }">

<?php if(isLoggedIn()): ?>
<div class="flex h-screen overflow-hidden">
    
    <!-- Sidebar -->
    <aside class="fixed inset-y-0 z-50 flex-shrink-0 w-64 mt-16 overflow-y-auto bg-surface border-r border-gray-700 transition-transform transform lg:static lg:translate-x-0 lg:mt-0"
        :class="{'translate-x-0': sidebarOpen, '-translate-x-full': !sidebarOpen}">
        
        <div class="flex items-center justify-center h-16 bg-dark border-b border-gray-700">
            <span class="text-2xl font-bold tracking-wider text-primary">ANON<span class="text-white">CHAT</span></span>
        </div>

        <nav class="px-4 py-6 space-y-2">
            
            <p class="px-2 text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2">Overview</p>
            
            <a href="dashboard.php" class="flex items-center px-4 py-2.5 text-gray-300 rounded-lg hover:bg-primary hover:text-white transition-colors group <?= basename($_SERVER['PHP_SELF'])=='dashboard.php'?'bg-primary text-white':'' ?>">
                <i class="fas fa-chart-line w-5 h-5 mr-3 text-gray-400 group-hover:text-white"></i>
                Dashboard
            </a>

            <p class="px-2 text-xs font-semibold text-gray-400 uppercase tracking-wider mt-6 mb-2">Management</p>

            <a href="users.php" class="flex items-center px-4 py-2.5 text-gray-300 rounded-lg hover:bg-primary hover:text-white transition-colors group <?= basename($_SERVER['PHP_SELF'])=='users.php'?'bg-primary text-white':'' ?>">
                <i class="fas fa-users w-5 h-5 mr-3 text-gray-400 group-hover:text-white"></i>
                Users
            </a>

            <a href="premium_management.php" class="flex items-center px-4 py-2.5 text-gray-300 rounded-lg hover:bg-primary hover:text-white transition-colors group <?= basename($_SERVER['PHP_SELF'])=='premium_management.php'?'bg-primary text-white':'' ?>">
                <i class="fas fa-crown w-5 h-5 mr-3 text-gray-400 group-hover:text-white"></i>
                Premium Management
            </a>
            
            <a href="chats.php" class="flex items-center px-4 py-2.5 text-gray-300 rounded-lg hover:bg-primary hover:text-white transition-colors group <?= basename($_SERVER['PHP_SELF'])=='chats.php'?'bg-primary text-white':'' ?>">
                <i class="fas fa-comments w-5 h-5 mr-3 text-gray-400 group-hover:text-white"></i>
                Live Chats
            </a>

            <a href="bots.php" class="flex items-center px-4 py-2.5 text-gray-300 rounded-lg hover:bg-primary hover:text-white transition-colors group <?= basename($_SERVER['PHP_SELF'])=='bots.php'?'bg-primary text-white':'' ?>">
                <i class="fas fa-robot w-5 h-5 mr-3 text-gray-400 group-hover:text-white"></i>
                AI Agents
            </a>

            <p class="px-2 text-xs font-semibold text-gray-400 uppercase tracking-wider mt-6 mb-2">Moderation</p>

            <a href="reports.php" class="flex items-center px-4 py-2.5 text-gray-300 rounded-lg hover:bg-primary hover:text-white transition-colors group <?= basename($_SERVER['PHP_SELF'])=='reports.php'?'bg-primary text-white':'' ?>">
                <i class="fas fa-flag w-5 h-5 mr-3 text-gray-400 group-hover:text-white"></i>
                Reports
            </a>

            <a href="broadcast.php" class="flex items-center px-4 py-2.5 text-gray-300 rounded-lg hover:bg-primary hover:text-white transition-colors group <?= basename($_SERVER['PHP_SELF'])=='broadcast.php'?'bg-primary text-white':'' ?>">
                <i class="fas fa-bullhorn w-5 h-5 mr-3 text-gray-400 group-hover:text-white"></i>
                Broadcast
            </a>

        </nav>
    </aside>

    <!-- Main Content -->
    <div class="flex-1 flex flex-col overflow-hidden">
        
        <!-- Top Bar -->
        <header class="flex items-center justify-between h-16 px-6 bg-surface border-b border-gray-700">
            <div class="flex items-center">
                <button @click="sidebarOpen = !sidebarOpen" class="text-gray-400 focus:outline-none lg:hidden">
                    <i class="fas fa-bars w-6 h-6"></i>
                </button>
                
                <!-- Search (Global Command Palette Placeholder) -->
                <div class="relative mx-4 lg:mx-0 hidden lg:block">
                    <span class="absolute inset-y-0 left-0 flex items-center pl-3">
                        <i class="fas fa-search text-gray-500"></i>
                    </span>
                    <input class="w-64 pl-10 pr-4 py-2 bg-dark border border-gray-600 rounded-lg focus:outline-none focus:border-primary text-sm text-gray-300 placeholder-gray-500" type="text" placeholder="Search (Ctrl+K)">
                </div>
            </div>

            <div class="flex items-center space-x-4">
                <button class="relative p-1 text-gray-400 hover:text-white">
                    <i class="fas fa-bell w-6 h-6"></i>
                    <span class="absolute top-0 right-0 inline-flex items-center justify-center px-2 py-1 text-xs font-bold leading-none text-red-100 transform translate-x-1/2 -translate-y-1/2 bg-red-600 rounded-full">3</span>
                </button>
                
                <div x-data="{ dropdownOpen: false }" class="relative">
                    <button @click="dropdownOpen = !dropdownOpen" class="flex items-center space-x-2 focus:outline-none">
                        <img class="w-8 h-8 rounded-full border-2 border-gray-600" src="https://ui-avatars.com/api/?name=Admin&background=6366f1&color=fff" alt="Admin">
                        <span class="text-sm font-medium text-gray-300">Admin</span>
                        <i class="fas fa-chevron-down text-xs text-gray-500"></i>
                    </button>

                    <div x-show="dropdownOpen" @click.away="dropdownOpen = false" class="absolute right-0 mt-2 w-48 bg-surface rounded-md shadow-lg py-1 ring-1 ring-black ring-opacity-5 z-50 border border-gray-700" x-cloak>
                        <a href="#" class="block px-4 py-2 text-sm text-gray-300 hover:bg-dark hover:text-white">Profile</a>
                        <a href="#" class="block px-4 py-2 text-sm text-gray-300 hover:bg-dark hover:text-white">Settings</a>
                        <div class="border-t border-gray-700 my-1"></div>
                        <a href="logout.php" class="block px-4 py-2 text-sm text-red-400 hover:bg-dark hover:text-red-300">Sign out</a>
                    </div>
                </div>
            </div>
        </header>

        <!-- Page Content -->
        <main class="flex-1 overflow-x-hidden overflow-y-auto bg-darker p-6">
<?php endif; ?>
