<?php
function isActive($paths, $exact = false) {
    $current = $_SERVER['REQUEST_URI'] ?? '';
    if ($exact) {
        return ($current == $paths || $current == $paths . '/') ? 'active' : '';
    }
    foreach ((array)$paths as $path) {
        if (strpos($current, $path) !== false) {
            return 'active';
        }
    }
    return '';
}
?>

<!-- ====== HEADER ====== -->
<header class="app-header">
    <div class="header-container">
        <div class="logo">
            <i class="fas fa-trophy"></i>
            <span>EST Concours</span>
        </div>
        <nav class="header-nav">
            <ul>
                <li><a href="/est-concours/app/view/admin/dashboard/main" class="<?php echo isActive('admin/dashboard', true); ?>"><i class="fas fa-home"></i> Accueil</a></li>
                <li><a href="/est-concours/app/view/admin/pedagogie/departement/list" class="<?php echo isActive('admin/pedagogie'); ?>"><i class="fas fa-chart-pie"></i> Pedagogie</a></li>
                <li><a href="/est-concours/app/view/admin/espace-avancement/avancement/list" class="<?php echo isActive('admin/espace-avancement'); ?>"><i class="fas fa-chart-pie"></i> Avancement</a></li>
                <li><a href="/est-concours/app/view/admin/espace-concours/concours/list" class="<?php echo isActive('admin/espace-concours'); ?>"><i class="fas fa-list-ul"></i> Concours</a></li>
                <li><a href="/est-concours/app/view/admin/espace-demande-doc/demande_document/list" class="<?php echo isActive('admin/espace-demande-doc'); ?>"><i class="fas fa-calendar-alt"></i> Demande Doc</a></li>
                <li><a href="/est-concours/app/view/admin/espace-personnel/employee/list" class="<?php echo isActive('admin/espace-personnel'); ?>"><i class="fas fa-cog"></i> Personnel</a></li>
                <li><a href="/est-concours/app/view/admin/espace-student/student/list" class="<?php echo isActive('admin/espace-student'); ?>"><i class="fas fa-archive"></i> Student</a></li>
                <li><a href="/est-concours/app/view/admin/espace-dossier-admin/dossier_document_admin/list" class="<?php echo isActive('admin/espace-dossier-admin'); ?>"><i class="fas fa-calendar-alt"></i> Dossier Admin</a></li>
            </ul>
        </nav>
        <div class="user-profile">
            <i class="fas fa-user-circle"></i>
            <span>Admin</span>
        </div>
    </div>
</header>
