<?php
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}
$user = $_SESSION['username'] ?? null;
$role = $_SESSION['role'] ?? null;
$root_path = '/ooh_project/index.php';
?>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-4" style="width:100vw;">
  <div class="container-fluid">
    <div class="navbar-collapse" style="width:80%;">
      <ul class="navbar-nav me-auto mb-2 mb-lg-0">
        <li class="nav-item"><a class="nav-link" href="<?= $root_path ?>">Home</a></li>
        <li class="nav-item"><a class="nav-link" href="<?= $root_path ?>?page=strategic_planning">Strategic Planning</a></li>
        <li class="nav-item"><a class="nav-link" href="<?= $root_path ?>?page=competitor_review">Competitor Review</a></li>
        <li class="nav-item"><a class="nav-link" href="<?= $root_path ?>?page=site_evaluation">Site Evaluation</a></li>
        <li class="nav-item"><a class="nav-link" href="<?= $root_path ?>?page=update_database">Market Overview</a></li>
      </ul>
    </div>
    <div class="d-flex justify-content-end align-items-center" style="width:20%;">
      <?php if (!$user): ?>
        <a class="btn btn-outline-light me-2" href="<?= $root_path ?>?page=login">Login</a>
        <a class="btn btn-outline-light" href="<?= $root_path ?>?page=register">Register</a>
      <?php else: ?>
        <span class="navbar-text text-light me-2">Hello, <?= htmlspecialchars($user) ?>!</span>
        <a class="btn btn-outline-danger" href="<?= $root_path ?>?page=logout">Logout</a>
      <?php endif; ?>
    </div>
  </div>
</nav>
