<?php
function render_nav_link($href, $icon, $label, $active_page) {
    $active = ($href == $active_page) ? 'bg-gray-200 text-gray-900 font-semibold' : 'hover:bg-gray-200 text-gray-700';
    echo "<a href=\"$href\" class=\"flex items-center py-2.5 px-4 rounded transition duration-200 $active\">";
    echo "<i data-lucide=\"$icon\" class=\"w-5 h-5 mr-3\"></i>$label";
    echo "</a>";
}

$current_page = basename($_SERVER['PHP_SELF']);
?>
<div class="w-64 bg-white shadow-md">
    <?php if (isset($_SESSION['original_user_id'])) : ?>
        <div class="p-4 bg-yellow-400 text-yellow-900 text-center">
            <p class="font-bold">Viewing as Employee</p>
            <a href="stop_impersonating.php" class="text-sm underline">Return to Your View</a>
        </div>
    <?php endif; ?>
    <div class="p-6">
        <a href="app.php">
            <img src="assets/pasted-20251120-051320-b2b0cdfa.png" alt="FinMox Logo" style="height: 32px;">
        </a>
    </div>
    <nav class="mt-6">
        <?php
        render_nav_link('dashboard.php', 'layout-dashboard', 'Dashboard', $current_page);
        render_nav_link('candidates.php', 'users', 'Candidates', $current_page);
        render_nav_link('hr_cases.php', 'briefcase', 'HR Cases', $current_page);
        render_nav_link('onboarding.php', 'clipboard-list', 'Onboarding', $current_page);
        render_nav_link('hr_employee_overview.php', 'user-cog', 'HR Overview', $current_page);
        render_nav_link('weekly_summary.php', 'bar-chart-2', 'Weekly Summary', $current_page);
        render_nav_link('workflows.php', 'bot', 'Automation', $current_page);
        render_nav_link('chat.php', 'sparkles', 'AI Copilot', $current_page);
        render_nav_link('integrations.php', 'plug', 'Integrations', $current_page);
        render_nav_link('settings.php', 'settings', 'Settings', $current_page);
        ?>
        <a href="logout.php" class="flex items-center py-2.5 px-4 rounded transition duration-200 hover:bg-gray-200 text-gray-700">
            <i data-lucide="log-out" class="w-5 h-5 mr-3"></i>Logout
        </a>
    </nav>
</div>
<script src="https://unpkg.com/lucide@latest"></script>
<script>
    lucide.createIcons();
</script>