<?php include "data/auth.php"; ?>
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Admin Panel</title>
  <link rel="shortcut icon" href="https://icons.iconarchive.com/icons/bokehlicia/pacifica/48/utilities-system-monitor-icon.png">
  <?php include "data/styles.php"?>
  <style>
    @keyframes fade-in {
      0% { opacity: 0; transform: translateY(20px); }
      100% { opacity: 1; transform: translateY(0); }
    }
    .animate-fade-in { animation: fade-in 0.7s ease-out both; }
  </style>
</head>
<body class="bg-gradient-to-br from-slate-100 via-white to-slate-200 min-h-screen text-gray-800">
  <div class="flex h-screen">
    <!-- Sidebar -->
    <aside id="sidebar" class="w-72 h-full bg-white/80 backdrop-blur-md shadow-xl fixed md:static md:flex flex-col hidden z-40 transition-all duration-300">
      <div class="p-6 border-gray-200 flex justify-between items-center">
	  <a target="_blank" href="../">
      <div class="text-2xl font-semibold flex items-center gap-2">
        <div class="bg-blue-500 text-white p-2 rounded-full shadow"><i data-lucide="layout-dashboard" class="w-6 h-6 text-white"></i></div> AdminPanel
      </div></a>
        <button onclick="toggleSidebar()" class="md:hidden">
          <i data-lucide="x" class="w-5 h-5"></i>
        </button>
      </div>
      <nav class="flex-1 p-4 text-sm">
        <div class="space-y-1">
          <a href="#" onclick="loadPage('Dashboard', 'dashboard.php', this)" class="menu-item"> <i data-lucide="layout-dashboard" class="w-4 h-4"></i> Dashboard </a>
          <div>
            <div class="mt-4 mb-1 text-xs font-medium text-gray-400 uppercase">Tools</div>
            <a href="#" onclick="loadPage('Edit Tools Content', 'install-tools.php?edit', this)" class="menu-item"> <i data-lucide="edit" class="w-4 h-4"></i> Tools Content</a>
			<a href="#" onclick="loadPage('Edit New Tools', 'edit-tools.php', this)" class="menu-item"> <i data-lucide="box" class="w-4 h-4"></i> Edit Tools </a>
            <a href="#" onclick="loadPage('Install New Tools', 'install-tools.php', this)" class="menu-item"> <i data-lucide="download" class="w-4 h-4"></i> Install New Tools </a>
          </div>
          <div>
            <div class="mt-4 mb-1 text-xs font-medium text-gray-400 uppercase">Pages</div>
            <a href="#" onclick="loadPage('Edit Pages', 'edit-pages.php', this)" class="menu-item"> <i data-lucide="layers" class="w-4 h-4"></i> Edit Pages </a>
            <a href="#" onclick="loadPage('Edit Header Menu', 'edit-header.php', this)" class="menu-item"> <i data-lucide="panels-top-left" class="w-4 h-4"></i> Edit Header </a>
            <a href="#" onclick="loadPage('Edit Footer Menu', 'edit-footer.php', this)" class="menu-item"> <i data-lucide="panel-bottom" class="w-4 h-4"></i> Edit Footer </a>
          </div>
          <div>
            <div class="mt-4 mb-1 text-xs font-medium text-gray-400 uppercase">Settings</div>
            <a href="#" onclick="loadPage('Site Settings', 'site-settings.php', this)" class="menu-item"> <i data-lucide="settings" class="w-4 h-4"></i> Site Settings </a>
            <a href="#" onclick="loadPage('Ads Settings', 'ads-settings.php', this)" class="menu-item"> <i data-lucide="dollar-sign" class="w-4 h-4"></i> Ads Settings </a>
            <a href="#" onclick="loadPage('Email Settings', 'edit-email.php', this)" class="menu-item"> <i data-lucide="mail-check" class="w-4 h-4"></i> Email Settings </a>
            <a href="#" onclick="loadPage('Branded URL', 'branded-url.php', this)" class="menu-item"> <i data-lucide="link" class="w-4 h-4"></i> Branded URL</a>
          </div>
          <div class="mt-4">
		   <div class="mt-4 mb-1 text-xs font-medium text-gray-400 uppercase">User</div>
			<a href="#" onclick="loadPage('Change Password', 'admin.php?page=change-pass', this)" class="menu-item"> <i data-lucide="key" class="w-4 h-4"></i> Change Password </a>
            <a href="admin.php?page=logout" class="menu-item"><i data-lucide="log-out" class="w-4 h-4"></i> Logout</a>
          </div>
        </div>
      </nav>
    </aside>

    <!-- Main Content -->
    <div class="flex-1 flex flex-col">
      <header class="bg-white/70 backdrop-blur border-b shadow-sm flex items-center justify-between px-4 py-3 sticky top-0 z-10">
        <div class="flex items-center gap-4">
          <button class="md:hidden" onclick="toggleSidebar()">
            <i data-lucide="menu" class="w-6 h-6"></i>
          </button>
          <h2 id="pageTitle" class="text-xl font-semibold">Dashboard</h2>
        </div>
        <div class="flex items-center gap-4">
          <button class="hover:text-blue-600 transition"><i data-lucide="bell" class="w-5 h-5"></i></button>
          <img src="https://i.pravatar.cc/40" class="w-9 h-9 rounded-full border" alt="User" />
        </div>
      </header>

      <main class="flex-1 overflow-auto">
        <iframe id="contentFrame" src="dashboard.php" class="w-full h-full min-h-[calc(100vh-70px)]"></iframe>
      </main>
    </div>
  </div>

  <script>
    function toggleSidebar() {
      const sidebar = document.getElementById('sidebar');
      sidebar.classList.toggle('hidden');
    }

    function loadPage(title, file, el) {
      document.getElementById('pageTitle').textContent = title;
      const iframe = document.getElementById('contentFrame');
      iframe.src = file;

      document.querySelectorAll('.menu-item').forEach(i => i.classList.remove('bg-blue-50', 'text-blue-600'));
      el.classList.add('bg-blue-50', 'text-blue-600');
    }

    document.getElementById('contentFrame').addEventListener('error', () => {
      document.getElementById('contentFrame').srcdoc = '<div class="flex justify-center items-center h-full text-2xl text-red-500">404 - Page Not Found</div>';
    });
  </script>

  <style>
    .menu-item {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      padding: 0.5rem 0.75rem;
      border-radius: 0.5rem;
      transition: all 0.2s;
    }
	.menu-item {
	  border-radius: 0.75rem;
	  padding: 0.75rem;
	  gap: 0.75rem;
	  font-size: 15px;
	  padding-left: 1rem;
	}
	
    .menu-item:hover {
      background-color: #eff6ff;
      color: #2563eb;
    }
  </style>
</body>
</html>