<?php
/**
 * Shared admin layout header. Every protected admin page must:
 *   require_once __DIR__ . '/../../includes/functions.php';
 *   requireAdmin();
 *   $pageTitle = 'Something';
 * before requiring this file.
 */
require_once __DIR__ . '/../../includes/functions.php';
requireAdmin();
$pageTitle = $pageTitle ?? 'Admin';

$navItems = [
    'index.php' => ['icon' => 'bi-speedometer2', 'label' => 'Dashboard'],
    'settings.php' => ['icon' => 'bi-gear-fill', 'label' => 'Site Settings'],
    'nav-links.php' => ['icon' => 'bi-list', 'label' => 'Navigation Bar'],
    'seo.php' => ['icon' => 'bi-search', 'label' => 'SEO'],
    'hero-slides.php' => ['icon' => 'bi-images', 'label' => 'Hero Slides'],
    'services.php' => ['icon' => 'bi-briefcase-fill', 'label' => 'Services'],
    'downloads.php' => ['icon' => 'bi-cloud-download-fill', 'label' => 'Downloads'],
    'testimonials.php' => ['icon' => 'bi-chat-quote-fill', 'label' => 'Testimonials'],
    'industries.php' => ['icon' => 'bi-building', 'label' => 'Industries'],
    'gallery.php' => ['icon' => 'bi-image-fill', 'label' => 'Gallery'],
    'team.php' => ['icon' => 'bi-people-fill', 'label' => 'Team Members'],
    'tally-features.php' => ['icon' => 'bi-stars', 'label' => 'TallyPrime Features'],
    'about-content.php' => ['icon' => 'bi-file-text-fill', 'label' => 'About Page Content'],
    'messages.php' => ['icon' => 'bi-envelope-fill', 'label' => 'Contact Messages'],
    'account.php' => ['icon' => 'bi-person-circle', 'label' => 'My Account'],
];
$currentFile = basename($_SERVER['SCRIPT_NAME']);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><?= e($pageTitle) ?> · PIMS Nepal Admin</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Poppins:wght@500;600;700;800&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css">
<script src="https://cdn.tailwindcss.com"></script>
<script>
  tailwind.config = { theme: { extend: {
    colors: { primary: '#0D6EFD', secondary: '#1E3A8A', accent: '#F59E0B', bgsoft: '#F8FAFC' },
    fontFamily: { heading: ['Poppins','sans-serif'], sans: ['Inter','sans-serif'] }
  } } }
</script>
<style>
  body { font-family: 'Inter', sans-serif; }
  .font-heading { font-family: 'Poppins', sans-serif; }
  .admin-nav-link.active { background:#0D6EFD; color:#fff; }
  .admin-nav-link:hover:not(.active) { background:#EFF6FF; }
</style>
</head>
<body class="bg-bgsoft text-gray-800 antialiased">
<div class="flex min-h-screen">
  <aside class="w-64 bg-white border-r border-gray-100 shrink-0 hidden md:flex flex-col">
    <div class="h-20 flex items-center px-6 border-b border-gray-100">
      <img src="../assets/images/pims-logo.png" alt="PIMS Nepal" class="h-10 w-10 object-contain mr-2" />
      <span class="font-heading font-bold text-sm">PIMS Nepal<br /><span class="text-xs font-normal text-gray-400">Admin Panel</span></span>
    </div>
    <nav class="flex-1 overflow-y-auto py-4 px-3 space-y-1 text-sm">
      <?php foreach ($navItems as $file => $item): ?>
        <a href="<?= e($file) ?>" class="admin-nav-link flex items-center gap-3 px-3 py-2.5 rounded-lg font-medium text-gray-600 <?= $currentFile === $file ? 'active' : '' ?>">
          <i class="bi <?= e($item['icon']) ?>"></i> <?= e($item['label']) ?>
        </a>
      <?php endforeach; ?>
    </nav>
    <div class="p-3 border-t border-gray-100">
      <a href="logout.php" class="flex items-center gap-3 px-3 py-2.5 rounded-lg font-medium text-red-600 hover:bg-red-50 text-sm"><i class="bi bi-box-arrow-right"></i> Log Out</a>
    </div>
  </aside>

  <div class="flex-1 flex flex-col min-w-0">
    <header class="h-16 bg-white border-b border-gray-100 flex items-center justify-between px-6">
      <h1 class="font-heading font-bold text-lg"><?= e($pageTitle) ?></h1>
      <div class="flex items-center gap-3 text-sm text-gray-500">
        <a href="../index.php" target="_blank" class="hover:text-primary"><i class="bi bi-box-arrow-up-right"></i> View Site</a>
        <span class="hidden sm:inline">|</span>
        <span class="hidden sm:inline"><?= e($_SESSION['admin_name'] ?? 'Admin') ?></span>
      </div>
    </header>
    <main class="flex-1 p-6">
