<?php

// if (!function_exists('isActive')) {
//     function isActive($page)
//     {
//         $currentRoute = request()->route()->getName();
        
//         if (str_contains($currentRoute, 'services')) {
//             return $currentRoute == $page ? 'active' : '';
//         } else {
//             return $currentRoute == $page ? 'class="active"' : '';
//         }
//     }
// }

if (!function_exists('isActive')) {
    // Navbar active state helper (single route)
    function isActive($routeName)
    {
        $currentRoute = request()->route()?->getName();

        // Special handling for services routes (kept from your original logic)
        if ($currentRoute && str_contains($currentRoute, 'services')) {
            return $currentRoute === $routeName ? 'active' : '';
        }

        return request()->routeIs($routeName) ? 'class="active"' : '';
    }
}

if (!function_exists('isActiveMultiple')) {
    // Navbar active state helper (multiple routes)
    function isActiveMultiple(array $routeNames)
    {
        foreach ($routeNames as $route) {
            if (request()->routeIs($route)) {
                return 'class="active"';
            }
        }
        return '';
    }
}
