<?php
$currentPage = $currentPage ?? basename($_SERVER['PHP_SELF'], '.php');

$mobileNavItems = [
    ['page' => 'dashboard', 'href' => '/notifier/dashboard/', 'label' => 'Home', 'icon' => 'dashboard'],
    ['page' => 'notifications', 'href' => '/notifier/notifications/', 'label' => 'Alerts', 'icon' => 'bell'],
    ['page' => 'categories', 'href' => '/notifier/categories/', 'label' => 'Tags', 'icon' => 'tag'],
    ['page' => 'history', 'href' => '/notifier/history/', 'label' => 'History', 'icon' => 'clock'],
    ['page' => 'console', 'href' => '/notifier/console/', 'label' => 'Console', 'icon' => 'code'],
];

function getMobileIcon($type) {
    switch($type) {
        case 'dashboard':
            return '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"/>';
        case 'bell':
            return '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"/>';
        case 'tag':
            return '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z"/>';
        case 'clock':
            return '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>';
        case 'code':
            return '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"/>';
        default:
            return '';
    }
}
?>
<nav class="lg:hidden fixed bottom-0 left-0 right-0 bg-white border-t border-slate-200 px-2 py-1 flex justify-around z-50">
    <?php foreach ($mobileNavItems as $item): ?>
        <?php $isActive = $currentPage === $item['page'] || ($item['page'] === 'notifications' && $currentPage === 'notification-edit'); ?>
        <a href="<?= $item['href'] ?>"
           class="flex flex-col items-center gap-0.5 py-1.5 px-3 rounded-lg <?= $isActive ? 'text-indigo-500' : 'text-slate-400' ?> transition-colors">
            <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <?= getMobileIcon($item['icon']) ?>
            </svg>
            <span class="text-[10px] font-medium"><?= $item['label'] ?></span>
        </a>
    <?php endforeach; ?>
</nav>
