<?php
if (defined('AH_NAV_PRINTED')) return;
define('AH_NAV_PRINTED', 1);
$navActive = $navActive ?? '';
$loggedIn  = function_exists('isLoggedIn') ? isLoggedIn() : false;
?>
<link rel="preload" as="image" href="assets/img/logo.svg">

<header class="nav" id="siteNav" role="banner">
  <div class="wrap nav-inner">
    <a href="index.php" class="brand" aria-label="AdityaHost home">
      <span class="brand-mark"><svg width="28" height="28" viewBox="0 0 32 32" fill="none"><rect width="32" height="32" rx="8" fill="#a370fc"/><path d="M8 12l-3 3 3 3M24 12l3 3-3 3M21 8l-2 12" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/></svg></span>
      Aditya<b>Host</b>
    </a>

    <nav class="nav-links" aria-label="Main navigation">
      <a href="index.php" class="<?= $navActive === 'index' ? 'active' : '' ?>">Home</a>
      <a href="index.php#features" class="<?= $navActive === 'features' ? 'active' : '' ?>">Features</a>
      <a href="index.php#pricing" class="<?= $navActive === 'pricing' ? 'active' : '' ?>">Pricing</a>
      <a href="blog.php" class="<?= $navActive === 'blog' ? 'active' : '' ?>">Blog</a>
      <a href="docs.php" class="<?= $navActive === 'docs' ? 'active' : '' ?>">Developers</a>
      <a href="contact.php" class="<?= $navActive === 'contact' ? 'active' : '' ?>">Support</a>
    </nav>

    <div class="nav-actions">
      <?php if ($loggedIn): ?>
        <a href="dashboard.php" class="btn btn-primary btn-sm">Dashboard</a>
      <?php else: ?>
        <a href="login.php" class="btn btn-ghost btn-sm">Sign in</a>
        <a href="register.php" class="btn btn-primary btn-sm">Get API Free</a>
      <?php endif; ?>
      <button class="nav-burger" id="navBurger" aria-label="Open menu" aria-expanded="false">
        <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="4" y1="6" x2="20" y2="6"/><line x1="4" y1="12" x2="20" y2="12"/><line x1="4" y1="18" x2="20" y2="18"/></svg>
      </button>
    </div>
  </div>
  <div class="mobile-menu" id="mobileMenu" role="navigation" aria-label="Mobile menu">
    <a href="index.php">Home</a>
    <a href="index.php#features">Features</a>
    <a href="index.php#pricing">Pricing</a>
    <a href="blog.php">Blog</a>
    <a href="docs.php">Developers</a>
    <a href="contact.php">Support</a>
    <?php if (!$loggedIn): ?>
      <a href="login.php">Sign in</a>
      <a href="register.php" style="color:#a370fc">Get API Free</a>
    <?php else: ?>
      <a href="dashboard.php" style="color:#a370fc">Dashboard</a>
    <?php endif; ?>
  </div>
</header>

<script>
(function(){
  var b=document.getElementById('navBurger'),m=document.getElementById('mobileMenu');
  if(!b)return;
  b.addEventListener('click',function(){
    var open = m.classList.toggle('open');
    b.setAttribute('aria-expanded', open);
  });
  document.querySelectorAll('#mobileMenu a').forEach(function(a){
    a.addEventListener('click',function(){m.classList.remove('open');});
  });
})();
</script>