<nav id="navmenu" class="navmenu">
    <ul>
        <?php
            // Se for home, os arquivos ficam em "pages/"
            $isHome     = ($pagename === 'home');
            $rootPrefix = $isHome ? ''        : '../';
            $pagePrefix = $isHome ? 'pages/'  : '';

            // Qual item deve ficar ativo em cada página
            $activeMap = [
                'home'           => 'home',
                'products'       => 'products',
                'services'       => 'services',
                'about'          => 'about',
                'service-detail' => 'services',
                'project-detail' => 'products',
                'quote'          => '',        // não tem item de menu próprio
                'term'           => 'about',
                'privacy'        => 'about',
                'contacts'       => 'contacts',
            ];

            $current = isset($activeMap[$pagename]) ? $activeMap[$pagename] : '';

            // Itens principais
            $navItems = [
                'home' => [
                    'href'  => $rootPrefix . 'index.php',
                    'label' => 'Inicio',
                ],
                'products' => [
                    'href'  => $pagePrefix . 'products.php',
                    'label' => 'Produtos',
                ],
                'services' => [
                    'href'  => $pagePrefix . 'services.php',
                    'label' => 'Serviços',
                ],
                'about' => [
                    'href'  => $pagePrefix . 'about.php',
                    'label' => 'Sobre',
                ],
                'contacts' => [
                    'href'  => $pagePrefix . 'contact.php',
                    'label' => 'Contatos',
                ],
            ];

            foreach ($navItems as $key => $item) {
                $activeClass = ($key === $current) ? ' class="active"' : '';
                echo '<li><a href="' . $item['href'] . '"' . $activeClass . '>' . $item['label'] . '</a></li>';
            }
        ?>
        <li class="nav-item ms-sm-3">
            <a
                href="<?php echo $pagePrefix; ?>quote.php"
                class="btn-getstarted  rounded-pill px-4 py-2 d-none d-sm-inline-flex align-items-center gap-2"
                title="Pedir uma cotação"
            >
                <i class="bi bi-chat-dots"></i>
                <span>Pedir Cotação</span>
            </a>
        </li> 
    </ul>
    <i class="mobile-nav-toggle d-xl-none bi bi-list"></i>
</nav>