<!DOCTYPE html>
<html lang="nl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CodePress Admin</title>
    <link rel="stylesheet" href="assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="assets/css/bootstrap-icons.css">
    <style>
        body { background-color: #f5f6fa; min-height: 100vh; }
        .admin-sidebar { background-color: #0a369d; min-height: 100vh; width: 240px; position: fixed; top: 0; left: 0; z-index: 100; }
        .admin-sidebar .nav-link { color: rgba(255,255,255,0.8); padding: 0.75rem 1.25rem; border-radius: 0; }
        .admin-sidebar .nav-link:hover { color: #fff; background-color: rgba(255,255,255,0.1); }
        .admin-sidebar .nav-link.active { color: #fff; background-color: rgba(255,255,255,0.2); border-left: 3px solid #fff; }
        .admin-sidebar .nav-link i { width: 24px; text-align: center; margin-right: 0.5rem; }
        .admin-main { margin-left: 240px; padding: 2rem; }
        .admin-brand { color: #fff; padding: 1.25rem; font-size: 1.1rem; border-bottom: 1px solid rgba(255,255,255,0.15); }
        .admin-brand i { margin-right: 0.5rem; }
        .stat-card { border: none; border-radius: 0.5rem; }
        .stat-card .stat-icon { font-size: 2rem; opacity: 0.7; }
        .admin-user { color: rgba(255,255,255,0.6); padding: 0.75rem 1.25rem; font-size: 0.85rem; border-top: 1px solid rgba(255,255,255,0.15); position: absolute; bottom: 0; width: 100%; }
        @media (max-width: 768px) {
            .admin-sidebar { width: 100%; min-height: auto; position: relative; }
            .admin-main { margin-left: 0; }
        }
    </style>
</head>
<body>
    <!-- Sidebar -->
    <nav class="admin-sidebar d-flex flex-column">
        <div class="admin-brand">
            <i class="bi bi-gear-fill"></i> CodePress Admin
        </div>
        <ul class="nav flex-column mt-2">
            <li class="nav-item">
                <a class="nav-link <?= ($route ?? '') === 'dashboard' || ($route ?? '') === '' ? 'active' : '' ?>" href="admin.php?route=dashboard">
                    <i class="bi bi-speedometer2"></i> Dashboard
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link <?= ($route ?? '') === 'content' || str_starts_with($route ?? '', 'content') ? 'active' : '' ?>" href="admin.php?route=content">
                    <i class="bi bi-file-earmark-text"></i> Content
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link <?= ($route ?? '') === 'config' ? 'active' : '' ?>" href="admin.php?route=config">
                    <i class="bi bi-sliders"></i> Configuratie
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link <?= ($route ?? '') === 'plugins' ? 'active' : '' ?>" href="admin.php?route=plugins">
                    <i class="bi bi-plug"></i> Plugins
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link <?= ($route ?? '') === 'users' ? 'active' : '' ?>" href="admin.php?route=users">
                    <i class="bi bi-people"></i> Gebruikers
                </a>
            </li>
            <li class="nav-item mt-3">
                <a class="nav-link" href="index.php" target="_blank">
                    <i class="bi bi-box-arrow-up-right"></i> Website bekijken
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link text-warning" href="admin.php?route=logout">
                    <i class="bi bi-box-arrow-left"></i> Uitloggen
                </a>
            </li>
        </ul>
        <div class="admin-user">
            <i class="bi bi-person-circle"></i> <?= htmlspecialchars($user['username'] ?? '') ?>
        </div>
    </nav>

    <!-- Main content -->
    <main class="admin-main">
        <?php if (!empty($message)): ?>
            <div class="alert alert-<?= $messageType ?? 'info' ?> alert-dismissible fade show" role="alert">
                <?= htmlspecialchars($message) ?>
                <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
            </div>
        <?php endif; ?>

        <?php
        $currentRoute = $route ?? 'dashboard';
        switch ($currentRoute) {
            case 'dashboard':
            case '':
                require __DIR__ . '/pages/dashboard.php';
                break;
            case 'content':
                require __DIR__ . '/pages/content.php';
                break;
            case 'content-edit':
                require __DIR__ . '/pages/content-edit.php';
                break;
            case 'content-new':
                require __DIR__ . '/pages/content-new.php';
                break;
            case 'config':
                require __DIR__ . '/pages/config.php';
                break;
            case 'plugins':
                require __DIR__ . '/pages/plugins.php';
                break;
            case 'users':
                require __DIR__ . '/pages/users.php';
                break;
        }
        ?>
    </main>

    <script src="assets/js/bootstrap.bundle.min.js"></script>
</body>
</html>
