<?php
// Function to determine active link
$current_page = $_SERVER['REQUEST_URI'];
function isActiveUser($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 ?>/user/profil" class="flex items-center px-4 py-2.5 font-medium transition-colors rounded-xl <?= isActiveUser('/user/profil') ?>">
                <i class="fas fa-user w-6 text-center me-3 text-lg opacity-90"></i>
                <span>Profil</span>
            </a>

            <a href="<?= BASE_URL ?>/user/riwayat" class="flex items-center px-4 py-2.5 font-medium transition-colors rounded-xl <?= isActiveUser('/user/riwayat') ?>">
                <i class="fas fa-clock-rotate-left w-6 text-center me-3 text-lg opacity-90"></i>
                <span>Riwayat Kunjungan</span>
            </a>

            <a href="<?= BASE_URL ?>/user/edukasi" class="flex items-center px-4 py-2.5 font-medium transition-colors rounded-xl <?= isActiveUser('/user/edukasi') ?>">
                <i class="fas fa-book-medical w-6 text-center me-3 text-lg opacity-90"></i>
                <span>Edukasi</span>
            </a>

            <a href="<?= BASE_URL ?>/user/jadwal" class="flex items-center px-4 py-2.5 font-medium transition-colors rounded-xl <?= isActiveUser('/user/jadwal') ?>">
                <i class="fas fa-calendar-alt w-6 text-center me-3 text-lg opacity-90"></i>
                <span>Jadwal</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-white/80 hover:bg-white/10 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>
