<!-- TEST SIDEBAR LOADED -->


<?php
// Load navigation config
$nav_items = include __DIR__ . '/../config/navigation.php';

// Sort by 'order'
usort($nav_items, function($a, $b) {
    return $a['order'] <=> $b['order'];
});

// Determine user role
// Replace this with your actual auth system
$user_role = ((isset($_SESSION['role']) && $_SESSION['role'] === 'admin') || (isset($_SESSION['is_admin']) && $_SESSION['is_admin'])) ? 'admin' : 'public';
?>

<div class="sidebar">
    <div class="sidebar-inner">

        <?php foreach ($nav_items as $item): ?>

            <?php
            // Skip invisible items
            if (!$item['visible']) continue;

            // Skip items the user doesn't have permission for
            if (!in_array($user_role, $item['roles'])) continue;

            // Divider before
            if ($item['divider_before']): ?>
                <div class="sidebar-divider"></div>
            <?php endif; ?>

            <!-- Menu Item -->
            <a href="<?= $item['url']; ?>"
               class="sidebar-item <?= $item['custom_class']; ?>"
               data-neon="<?= $item['neon_color']; ?>">

                <!-- Neon Icon -->
                <span class="sidebar-icon icon-<?= $item['icon']; ?>"></span>

                <!-- Label (revealed on hover) -->
                <span class="sidebar-label"><?= $item['label']; ?></span>

                <!-- Badge (optional) -->
                <?php if (!empty($item['badge'])): ?>
                    <span class="sidebar-badge"
                          style="background-color: <?= $item['badge_color']; ?>;">
                        <?= $item['badge']; ?>
                    </span>
                <?php endif; ?>

                <!-- Music Note Drift -->
                <span class="music-notes">
                    <span class="note n1">♪</span>
                    <span class="note n2">♫</span>
                    <span class="note n3">♬</span>
                </span>

            </a>

            <!-- Divider after -->
            <?php if ($item['divider_after']): ?>
                <div class="sidebar-divider"></div>
            <?php endif; ?>

        <?php endforeach; ?>

    </div>
</div>
