<?php
// Function to determine active link
$current_page = $_SERVER['REQUEST_URI'];
function isActive($path) {
    global $current_page;
    return strpos($current_page, $path) !== false ? 'bg-white/20 text-white font-semibold shadow-sm' : 'text-sky-100 hover:bg-white/10 hover:text-white';
}
?>
<aside :class="sidebarOpen ? 'translate-x-0' : '-translate-x-full'" class="absolute z-30 flex flex-col w-64 h-screen px-4 py-8 overflow-y-auto bg-primary border-r border-white/10 lg:static lg:translate-x-0 transition-transform duration-300 ease-in-out shadow-2xl lg:shadow-none">
    <div class="flex items-center justify-center gap-3 mb-8 mt-2">
        <img src="<?= getLogoUrl() ?>" alt="Logo" class="w-10 h-10 object-contain drop-shadow-sm bg-white rounded-full p-1">
        <h1 class="text-xl font-bold tracking-wider text-white uppercase drop-shadow-sm">Posyandu</h1>
    </div>

    <div class="flex flex-col justify-between flex-1 mt-2">
        <nav class="space-y-1.5">
            <a href="<?= BASE_URL ?>/admin/dashboard" class="flex items-center px-4 py-2.5 font-medium transition-colors rounded-xl <?= isActive('/admin/dashboard') ?>">
                <i class="fas fa-home w-6 text-center me-3 text-lg opacity-90"></i>
                <span>Dashboard</span>
            </a>
            
            <p class="px-4 pt-5 pb-2 text-[10px] font-bold text-white/50 uppercase tracking-widest">Modul Inti</p>
            
            <a href="<?= BASE_URL ?>/admin/ibu_hamil/" class="flex items-center px-4 py-2.5 font-medium transition-colors rounded-xl <?= isActive('/admin/ibu_hamil') ?>">
                <i class="fas fa-female w-6 text-center me-3 text-lg opacity-90"></i>
                <span>Data Ibu Hamil</span>
            </a>
            <a href="<?= BASE_URL ?>/admin/kunjungan/" class="flex items-center px-4 py-2.5 font-medium transition-colors rounded-xl <?= isActive('/admin/kunjungan') ?>">
                <i class="fas fa-notes-medical w-6 text-center me-3 text-lg opacity-90"></i>
                <span>Rekam Medis</span>
            </a>
            <a href="<?= BASE_URL ?>/admin/laporan/" class="flex items-center px-4 py-2.5 font-medium transition-colors rounded-xl <?= isActive('/admin/laporan') ?>">
                <i class="fas fa-file-pdf w-6 text-center me-3 text-lg opacity-90"></i>
                <span>Laporan</span>
            </a>
            
            <p class="px-4 pt-5 pb-2 text-[10px] font-bold text-white/50 uppercase tracking-widest">Konten Publik</p>
            
            <a href="<?= BASE_URL ?>/admin/jadwal/" class="flex items-center px-4 py-2.5 font-medium transition-colors rounded-xl <?= isActive('/admin/jadwal') ?>">
                <i class="fas fa-calendar-alt w-6 text-center me-3 text-lg opacity-90"></i>
                <span>Jadwal Posyandu</span>
            </a>
            <a href="<?= BASE_URL ?>/admin/edukasi/" class="flex items-center px-4 py-2.5 font-medium transition-colors rounded-xl <?= isActive('/admin/edukasi') ?>">
                <i class="fas fa-book-medical w-6 text-center me-3 text-lg opacity-90"></i>
                <span>Edukasi</span>
            </a>
            
            <p class="px-4 pt-5 pb-2 text-[10px] font-bold text-white/50 uppercase tracking-widest">Pengaturan</p>
            
            <a href="<?= BASE_URL ?>/admin/users/" class="flex items-center px-4 py-2.5 font-medium transition-colors rounded-xl <?= isActive('/admin/users') ?>">
                <i class="fas fa-users-cog w-6 text-center me-3 text-lg opacity-90"></i>
                <span>Manajemen User</span>
            </a>
            
            <a href="<?= BASE_URL ?>/admin/profil/" class="flex items-center px-4 py-2.5 font-medium transition-colors rounded-xl <?= isActive('/admin/profil') ?>">
                <i class="fas fa-sliders-h w-6 text-center me-3 text-lg opacity-90"></i>
                <span>Profil Website</span>
            </a>
        </nav>

        <div class="mt-8 pt-6 border-t border-white/10">
            <a href="<?= BASE_URL ?>/logout" class="flex items-center px-4 py-2.5 text-red-100 hover:bg-red-500/20 hover:text-white font-medium transition-colors rounded-xl group">
                <i class="fas fa-sign-out-alt w-6 text-center me-3 text-lg group-hover:rotate-180 transition-transform duration-300"></i>
                <span>Keluar</span>
            </a>
        </div>
    </div>
</aside>


