<?php
// admin/admin-nav.php
$currentPage = basename($_SERVER['PHP_SELF']);
?>
<div class="dashboard-layout">

  <!-- Mobile Top Bar -->
  <div class="mobile-header">
    <div class="mobile-brand">
      <img src="../assets/img/logo-navbar-bright.png" alt="FamGateway" style="height:26px;width:auto;display:block;object-fit:contain;">
      <span style="background:#ef4444;color:#fff;font-size:10px;padding:2px 7px;border-radius:4px;margin-left:8px;font-weight:700;letter-spacing:0.5px;">ADMIN</span>
    </div>
    <button class="mobile-menu-btn" onclick="openSidebar()">
      <i data-lucide="menu" style="width:22px;height:22px;"></i>
    </button>
  </div>

  <!-- Sidebar -->
  <aside class="sidebar" id="sidebar">
    <div class="sidebar-header">
      <div style="display:flex; justify-content:space-between; align-items:center;">
        <div class="sidebar-brand">
          <img src="../assets/img/logo-navbar-bright.png" alt="FamGateway" style="height:26px;width:auto;display:block;object-fit:contain;">
          <span style="background:#ef4444;color:#fff;font-size:10px;padding:2px 7px;border-radius:4px;margin-left:8px;font-weight:700;letter-spacing:0.5px;">ADMIN</span>
        </div>
        <button class="mobile-menu-btn" id="closeSidebarBtn" style="display:none;" onclick="closeSidebar()">
          <i data-lucide="x" style="width:20px;height:20px;"></i>
        </button>
      </div>
    </div>

    <nav class="sidebar-nav">
      <div class="sidebar-section-label">Overview</div>
      <a href="dashboard.php" class="sidebar-item <?= $currentPage === 'dashboard.php' ? 'active' : '' ?>">
        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-layout-dashboard"><rect width="7" height="9" x="3" y="3" rx="1"/><rect width="7" height="5" x="14" y="3" rx="1"/><rect width="7" height="9" x="14" y="12" rx="1"/><rect width="7" height="5" x="3" y="16" rx="1"/></svg> Overview
      </a>

      <div class="sidebar-section-label">Management</div>
      <a href="simulate.php" class="sidebar-item <?= $currentPage === 'simulate.php' ? 'active' : '' ?>">
        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-test-tube"><path d="M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5h0c-1.4 0-2.5-1.1-2.5-2.5V2"/><path d="M8.5 2h7"/><path d="M14.5 16h-5"/></svg> Simulate Payment
      </a>
      <a href="users.php" class="sidebar-item <?= ($currentPage === 'users.php' || $currentPage === 'user-edit.php') ? 'active' : '' ?>">
        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-users"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg> Manage Users
      </a>
      <a href="settings.php" class="sidebar-item <?= $currentPage === 'settings.php' ? 'active' : '' ?>">
        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-settings"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.38a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg> Gateway Settings
      </a>
      <a href="site-settings.php" class="sidebar-item <?= $currentPage === 'site-settings.php' ? 'active' : '' ?>">
        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-sliders"><line x1="4" x2="4" y1="21" y2="14"/><line x1="4" x2="4" y1="10" y2="3"/><line x1="12" x2="12" y1="21" y2="12"/><line x1="12" x2="12" y1="8" y2="3"/><line x1="20" x2="20" y1="21" y2="16"/><line x1="20" x2="20" y1="12" y2="3"/><line x1="2" x2="6" y1="14" y2="14"/><line x1="10" x2="14" y1="8" y2="8"/><line x1="18" x2="22" y1="16" y2="16"/></svg> Site Settings
      </a>
      <a href="smtp-settings.php" class="sidebar-item <?= $currentPage === 'smtp-settings.php' ? 'active' : '' ?>">
        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-mail"><rect width="20" height="16" x="2" y="4" rx="2"/><path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"/></svg> SMTP Settings
      </a>
      <a href="email-templates.php" class="sidebar-item <?= $currentPage === 'email-templates.php' ? 'active' : '' ?>">
        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-layout-template"><rect width="18" height="7" x="3" y="3" rx="1"/><rect width="9" height="7" x="3" y="14" rx="1"/><rect width="5" height="7" x="16" y="14" rx="1"/></svg> Email Templates
      </a>
      <a href="logs.php" class="sidebar-item <?= $currentPage === 'logs.php' ? 'active' : '' ?>">
        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-terminal"><polyline points="4 17 10 11 4 5"/><line x1="12" x2="20" y1="19" y2="19"/></svg> System Logs
      </a>



    </nav>

    <div class="sidebar-footer">
      <div class="sidebar-user-card" style="cursor:default;">
        <div style="width:34px;height:34px;border-radius:50%;background:linear-gradient(135deg,#ef4444,#b91c1c);color:#fff;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:15px;flex-shrink:0;border:2px solid rgba(255,255,255,0.12);">A</div>
        <div style="overflow:hidden;min-width:0;">
          <div class="sidebar-user-name">Administrator</div>
          <div class="sidebar-user-role">Super Admin</div>
        </div>
      </div>
      <a href="../logout.php" class="sidebar-logout">
        <svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-log-out"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" x2="9" y1="12" y2="12"/></svg> Sign Out
      </a>
    </div>
  </aside>

  <div class="sidebar-overlay" id="sidebarOverlay" onclick="closeSidebar()"></div>

  <main class="main-content">
    <script>
    function openSidebar() {
      document.getElementById('sidebar').classList.add('open');
      document.getElementById('sidebarOverlay').style.display = 'block';
      if(document.getElementById('closeSidebarBtn')) document.getElementById('closeSidebarBtn').style.display = 'flex';
    }
    function closeSidebar() {
      document.getElementById('sidebar').classList.remove('open');
      document.getElementById('sidebarOverlay').style.display = 'none';
      if(document.getElementById('closeSidebarBtn')) document.getElementById('closeSidebarBtn').style.display = 'none';
    }
    document.addEventListener("DOMContentLoaded", function() {
      if (window.lucide) { lucide.createIcons(); }
    });
    </script>
