<?php
$adminPages = [
    ['href' => $baseUrl . '/admin', 'label' => 'Dashboard', 'icon' => 'dashboard', 'match' => '/admin'],
    ['href' => $baseUrl . '/admin/leads', 'label' => 'Leads', 'icon' => 'group', 'match' => '/admin/leads'],
    ['href' => $baseUrl . '/admin/projects', 'label' => 'Projects', 'icon' => 'apartment', 'match' => '/admin/projects'],
    ['href' => $baseUrl . '/admin/quotations', 'label' => 'Quotations', 'icon' => 'request_quote', 'match' => '/admin/quotations'],
    ['href' => $baseUrl . '/admin/invoices', 'label' => 'Invoices', 'icon' => 'receipt_long', 'match' => '/admin/invoices'],
    ['href' => $baseUrl . '/admin/customers', 'label' => 'Customers', 'icon' => 'person', 'match' => '/admin/customers'],
    ['href' => $baseUrl . '/admin/documents', 'label' => 'Documents', 'icon' => 'description', 'match' => '/admin/documents'],
    ['href' => $baseUrl . '/admin/project-photos', 'label' => 'Project Photos', 'icon' => 'photo_library', 'match' => '/admin/project-photos'],
    ['href' => $baseUrl . '/admin/cms-slides', 'label' => 'Hero Slides', 'icon' => 'view_carousel', 'match' => '/admin/cms-slides'],
    ['href' => $baseUrl . '/admin/cms-services', 'label' => 'Services', 'icon' => 'design_services', 'match' => '/admin/cms-services'],
    ['href' => $baseUrl . '/admin/blog', 'label' => 'Blog', 'icon' => 'article', 'match' => '/admin/blog'],
    ['href' => $baseUrl . '/admin/gallery', 'label' => 'Gallery', 'icon' => 'image', 'match' => '/admin/gallery'],
    ['href' => $baseUrl . '/admin/settings', 'label' => 'Settings', 'icon' => 'settings', 'match' => '/admin/settings'],
    ['href' => $baseUrl . '/admin/users', 'label' => 'Users', 'icon' => 'admin_panel_settings', 'match' => '/admin/users'],
];

$currentPath = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) ?? '';
$currentPath = str_replace('\\', '/', $currentPath);
if (str_starts_with($currentPath, '/index.php')) {
    $currentPath = substr($currentPath, strlen('/index.php'));
}
if ($currentPath === '' || $currentPath === false) {
    $currentPath = '/';
}
?>
<div class="flex min-h-screen bg-slate-50">
<aside class="w-64 bg-slate-900 text-slate-300 min-h-screen p-6 hidden md:block">
    <div class="mb-8">
        <a href="<?= htmlspecialchars($baseUrl) ?>/admin" class="text-xl font-bold text-white">Balorp Admin</a>
        <p class="text-xs text-slate-500 mt-1">Management Dashboard</p>
    </div>
    <nav class="space-y-1">
        <?php foreach ($adminPages as $page): 
            $isActive = str_starts_with($currentPath, $page['match']);
            $activeClass = $isActive ? 'bg-slate-800 text-white' : 'hover:bg-slate-800 hover:text-white';
        ?>
            <a href="<?= htmlspecialchars($page['href']) ?>" class="flex items-center gap-3 px-4 py-3 rounded-xl text-sm font-medium transition-colors <?= $activeClass ?>">
                <span class="material-symbols-outlined text-lg"><?= htmlspecialchars($page['icon']) ?></span>
                <?= htmlspecialchars($page['label']) ?>
            </a>
        <?php endforeach; ?>
    </nav>
    <div class="mt-8 pt-6 border-t border-slate-800">
        <a href="<?= htmlspecialchars($baseUrl) ?>/logout" class="flex items-center gap-3 px-4 py-3 rounded-xl text-sm font-medium text-rose-300 hover:bg-slate-800 hover:text-rose-200 transition-colors">
            <span class="material-symbols-outlined text-lg">logout</span>
            Logout
        </a>
    </div>
</aside>
