<?php
$current = basename($_SERVER['PHP_SELF']);
$dir = basename(dirname($_SERVER['PHP_SELF']));
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?= isset($pageTitle) ? e($pageTitle) . ' | CMS' : 'CMS Admin' ?></title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css" rel="stylesheet">
<style>
  body { background:#f5f7fa; }
  .navbar-brand { font-weight:700; }
  .thumb { width:60px; height:60px; object-fit:cover; border-radius:6px; margin:2px; }
  .img-preview { width:100px; height:100px; object-fit:cover; border-radius:6px; }
  .card { border:none; box-shadow:0 1px 3px rgba(0,0,0,.06); }
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-4">
  <div class="container-fluid">
    <a class="navbar-brand" href="<?= BASE_URL ?>/index.php"><i class="bi bi-grid-3x3-gap-fill"></i> CMS Admin</a>
    <button class="navbar-toggler" data-bs-toggle="collapse" data-bs-target="#nav"><span class="navbar-toggler-icon"></span></button>
    <div class="collapse navbar-collapse" id="nav">
      <ul class="navbar-nav me-auto">
        <li class="nav-item"><a class="nav-link <?= $dir==='projects'?'active':'' ?>" href="<?= BASE_URL ?>/projects/index.php">Projects</a></li>
        <li class="nav-item"><a class="nav-link <?= $dir==='categories'?'active':'' ?>" href="<?= BASE_URL ?>/categories/index.php">Categories</a></li>
        <li class="nav-item"><a class="nav-link <?= $dir==='subcategories'?'active':'' ?>" href="<?= BASE_URL ?>/subcategories/index.php">Subcategories</a></li>
        <li class="nav-item"><a class="nav-link <?= $dir==='products'?'active':'' ?>" href="<?= BASE_URL ?>/products/index.php">Products</a></li>
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle <?= in_array($dir,['keyword_categories','keywords','product_keywords'])?'active':'' ?>" data-bs-toggle="dropdown" href="#">Keywords</a>
          <ul class="dropdown-menu">
            <li><a class="dropdown-item" href="<?= BASE_URL ?>/keyword_categories/index.php">Keyword Categories</a></li>
            <li><a class="dropdown-item" href="<?= BASE_URL ?>/keywords/index.php">Keywords</a></li>
            <li><a class="dropdown-item" href="<?= BASE_URL ?>/product_keywords/index.php">Assign to Products</a></li>
          </ul>
        </li>
      </ul>
      <ul class="navbar-nav">
        <li class="nav-item"><span class="nav-link"><i class="bi bi-person-circle"></i> <?= e($_SESSION['admin_username'] ?? '') ?></span></li>
        <li class="nav-item"><a class="nav-link" href="<?= BASE_URL ?>/logout.php"><i class="bi bi-box-arrow-right"></i> Logout</a></li>
      </ul>
    </div>
  </div>
</nav>
<div class="container-fluid">
<?php if ($m = flash('success')): ?><div class="alert alert-success"><?= e($m) ?></div><?php endif; ?>
<?php if ($m = flash('error')): ?><div class="alert alert-danger"><?= e($m) ?></div><?php endif; ?>
