<?php
// Admin sidebar include
$admin_page = basename($_SERVER['PHP_SELF'], '.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title><?= $page_title ?? 'Admin Panel' ?> | Balimeen Admin</title>
<link rel="stylesheet" href="<?= SITE_URL ?>/assets/css/admin.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
</head>
<body>

<aside class="sidebar">
  <div class="sidebar-brand">
    <div class="brand-icon"><span class="bm">BM</span><span class="sub">ADMIN</span></div>
    <div><h2>Balimeen Admin</h2><p>Control Panel</p></div>
  </div>
  <nav class="sidebar-nav">
    <div class="nav-section-label">Main</div>
    <a href="<?= SITE_URL ?>/admin/index.php" class="<?= $admin_page==='index'?'active':'' ?>"><i class="fas fa-tachometer-alt"></i> Dashboard</a>

    <div class="nav-section-label">Catalog</div>
    <a href="<?= SITE_URL ?>/admin/products.php" class="<?= $admin_page==='products'?'active':'' ?>"><i class="fas fa-box"></i> Products</a>
    <a href="<?= SITE_URL ?>/admin/products.php?action=add" class="<?= ($admin_page==='products'&&($_GET['action']??'')==='add')?'active':'' ?>"><i class="fas fa-plus-circle"></i> Add Product</a>
    <a href="<?= SITE_URL ?>/admin/categories.php" class="<?= $admin_page==='categories'?'active':'' ?>"><i class="fas fa-tags"></i> Categories</a>

    <div class="nav-section-label">Sales & CRM</div>
    <a href="<?= SITE_URL ?>/admin/orders.php" class="<?= $admin_page==='orders'?'active':'' ?>"><i class="fas fa-shopping-bag"></i> Orders</a>
    <a href="<?= SITE_URL ?>/admin/leads.php" class="<?= $admin_page==='leads'?'active':'' ?>"><i class="fas fa-bullseye"></i> CRM Leads</a>
    <a href="<?= SITE_URL ?>/admin/customers.php" class="<?= $admin_page==='customers'?'active':'' ?>"><i class="fas fa-users"></i> Customers</a>
    <a href="<?= SITE_URL ?>/admin/dealers.php" class="<?= $admin_page==='dealers'?'active':'' ?>"><i class="fas fa-handshake"></i> Dealers</a>
    <a href="<?= SITE_URL ?>/admin/inquiries.php" class="<?= $admin_page==='inquiries'?'active':'' ?>"><i class="fas fa-envelope"></i> Inquiries</a>

    <div class="nav-section-label">System</div>
    <a href="<?= SITE_URL ?>/admin/employees.php" class="<?= $admin_page==='employees'?'active':'' ?>"><i class="fas fa-id-badge"></i> Employees</a>
    <a href="<?= SITE_URL ?>/admin/hr_doc_verify.php" class="<?= $admin_page==='hr_doc_verify'?'active':'' ?>"><i class="fas fa-user-check"></i> HR Doc Verify</a>
    <a href="<?= SITE_URL ?>/admin/reports.php" class="<?= $admin_page==='reports'?'active':'' ?>"><i class="fas fa-chart-line"></i> Reports & Analytics</a>
    <a href="<?= SITE_URL ?>/admin/testimonials.php" class="<?= $admin_page==='testimonials'?'active':'' ?>"><i class="fas fa-star"></i> Testimonials</a>

    <div class="nav-section-label">Mega Enterprise OS</div>
    <a href="<?= SITE_URL ?>/admin/hq_dashboard.php" class="<?= $admin_page==='hq_dashboard'?'active':'' ?>"><i class="fas fa-building"></i> HQ Control Tower</a>
    <a href="<?= SITE_URL ?>/admin/factory_twin.php" class="<?= $admin_page==='factory_twin'?'active':'' ?>"><i class="fas fa-industry"></i> Digital Twin Factory</a>
    <a href="<?= SITE_URL ?>/admin/procurement.php" class="<?= $admin_page==='procurement'?'active':'' ?>"><i class="fas fa-shopping-cart"></i> Smart Procurement</a>
    <a href="<?= SITE_URL ?>/admin/warehouse.php" class="<?= $admin_page==='warehouse'?'active':'' ?>"><i class="fas fa-warehouse"></i> Warehouse Automation</a>
    <a href="<?= SITE_URL ?>/admin/finance.php" class="<?= $admin_page==='finance'?'active':'' ?>"><i class="fas fa-file-invoice-dollar"></i> Advanced Finance</a>
    <a href="<?= SITE_URL ?>/admin/esg.php" class="<?= $admin_page==='esg'?'active':'' ?>"><i class="fas fa-leaf"></i> Sustainability (ESG)</a>
    <a href="<?= SITE_URL ?>/admin/plm.php" class="<?= $admin_page==='plm'?'active':'' ?>"><i class="fas fa-cogs"></i> PLM & Innovation</a>
    <a href="<?= SITE_URL ?>/admin/global_trade.php" class="<?= $admin_page==='global_trade'?'active':'' ?>"><i class="fas fa-globe-asia"></i> Export & Global Trade</a>
    <a href="<?= SITE_URL ?>/admin/legal.php" class="<?= $admin_page==='legal'?'active':'' ?>"><i class="fas fa-balance-scale"></i> Legal & Secretarial</a>
    <a href="<?= SITE_URL ?>/admin/soc.php" class="<?= $admin_page==='soc'?'active':'' ?>"><i class="fas fa-shield-alt"></i> Security Ops Center</a>
    <a href="<?= SITE_URL ?>/admin/ai_brain.php" class="<?= $admin_page==='ai_brain'?'active':'' ?>"><i class="fas fa-brain"></i> AI Enterprise Brain</a>
    <a href="<?= SITE_URL ?>/admin/future.php" class="<?= $admin_page==='future'?'active':'' ?>"><i class="fas fa-rocket"></i> Future Stack (IoT/Web3)</a>

    <div class="nav-section-label">Enterprise OS v2</div>
    <a href="<?= SITE_URL ?>/admin/master_data.php" class="<?= $admin_page==='master_data'?'active':'' ?>"><i class="fas fa-database"></i> Master Data</a>
    <a href="<?= SITE_URL ?>/admin/workflow_engine.php" class="<?= $admin_page==='workflow_engine'?'active':'' ?>"><i class="fas fa-project-diagram"></i> Workflow Engine</a>
    <a href="<?= SITE_URL ?>/admin/notification_hub.php" class="<?= $admin_page==='notification_hub'?'active':'' ?>"><i class="fas fa-bell"></i> Notification Hub</a>
    <a href="<?= SITE_URL ?>/admin/unified_search.php" class="<?= $admin_page==='unified_search'?'active':'' ?>"><i class="fas fa-search"></i> Unified Search</a>
    <a href="<?= SITE_URL ?>/admin/doc_intelligence.php" class="<?= $admin_page==='doc_intelligence'?'active':'' ?>"><i class="fas fa-file-alt"></i> Doc Intelligence</a>
    <a href="<?= SITE_URL ?>/admin/nocode_builder.php" class="<?= $admin_page==='nocode_builder'?'active':'' ?>"><i class="fas fa-puzzle-piece"></i> No-Code Builder</a>
    <a href="<?= SITE_URL ?>/admin/integration_hub.php" class="<?= $admin_page==='integration_hub'?'active':'' ?>"><i class="fas fa-plug"></i> Integration Hub</a>
    <a href="<?= SITE_URL ?>/admin/knowledge_os.php" class="<?= $admin_page==='knowledge_os'?'active':'' ?>"><i class="fas fa-book-open"></i> Knowledge OS</a>
    <a href="<?= SITE_URL ?>/admin/franchise_os.php" class="<?= $admin_page==='franchise_os'?'active':'' ?>"><i class="fas fa-store"></i> Franchise OS</a>
    <a href="<?= SITE_URL ?>/admin/pmo.php" class="<?= $admin_page==='pmo'?'active':'' ?>"><i class="fas fa-tasks"></i> Project Management</a>
    <a href="<?= SITE_URL ?>/admin/procurement_intel.php" class="<?= $admin_page==='procurement_intel'?'active':'' ?>"><i class="fas fa-brain"></i> Procurement Intel</a>
    <a href="<?= SITE_URL ?>/admin/quality4.php" class="<?= $admin_page==='quality4'?'active':'' ?>"><i class="fas fa-microscope"></i> Quality 4.0</a>
    <a href="<?= SITE_URL ?>/admin/logistics_intel.php" class="<?= $admin_page==='logistics_intel'?'active':'' ?>"><i class="fas fa-shipping-fast"></i> Logistics Intel</a>
    <a href="<?= SITE_URL ?>/admin/revenue_engine.php" class="<?= $admin_page==='revenue_engine'?'active':'' ?>"><i class="fas fa-rocket"></i> Revenue Engine</a>
    <a href="<?= SITE_URL ?>/admin/experience_cloud.php" class="<?= $admin_page==='experience_cloud'?'active':'' ?>"><i class="fas fa-cloud"></i> Experience Cloud</a>
    <a href="<?= SITE_URL ?>/admin/corp_university.php" class="<?= $admin_page==='corp_university'?'active':'' ?>"><i class="fas fa-university"></i> Corp University</a>
    <a href="<?= SITE_URL ?>/admin/innovation.php" class="<?= $admin_page==='innovation'?'active':'' ?>"><i class="fas fa-lightbulb"></i> Innovation Lab</a>
    <a href="<?= SITE_URL ?>/admin/csr_cloud.php" class="<?= $admin_page==='csr_cloud'?'active':'' ?>"><i class="fas fa-hands-helping"></i> ESG/CSR Cloud</a>
    <a href="<?= SITE_URL ?>/admin/risk_center.php" class="<?= $admin_page==='risk_center'?'active':'' ?>"><i class="fas fa-shield-alt"></i> Risk Center</a>
    <a href="<?= SITE_URL ?>/admin/market_intel.php" class="<?= $admin_page==='market_intel'?'active':'' ?>"><i class="fas fa-binoculars"></i> Market Intel</a>
    <a href="<?= SITE_URL ?>/admin/media_studio.php" class="<?= $admin_page==='media_studio'?'active':'' ?>"><i class="fas fa-photo-video"></i> Media Studio</a>
    <a href="<?= SITE_URL ?>/admin/smart_contracts.php" class="<?= $admin_page==='smart_contracts'?'active':'' ?>"><i class="fas fa-file-contract"></i> Smart Contracts</a>
    <a href="<?= SITE_URL ?>/admin/procurement_marketplace.php" class="<?= $admin_page==='procurement_marketplace'?'active':'' ?>"><i class="fas fa-store-alt"></i> Procurement Market</a>
    <a href="<?= SITE_URL ?>/admin/commerce_api.php" class="<?= $admin_page==='commerce_api'?'active':'' ?>"><i class="fas fa-code"></i> Commerce API</a>
    <a href="<?= SITE_URL ?>/admin/identity_federation.php" class="<?= $admin_page==='identity_federation'?'active':'' ?>"><i class="fas fa-fingerprint"></i> Identity Fed</a>
    <a href="<?= SITE_URL ?>/admin/command_wall.php" class="<?= $admin_page==='command_wall'?'active':'' ?>"><i class="fas fa-tv"></i> Command Wall</a>
    <a href="<?= SITE_URL ?>/admin/hyper_automation.php" class="<?= $admin_page==='hyper_automation'?'active':'' ?>"><i class="fas fa-robot"></i> Hyper Automation</a>
    <a href="<?= SITE_URL ?>/admin/data_platform.php" class="<?= $admin_page==='data_platform'?'active':'' ?>"><i class="fas fa-database"></i> Data Platform</a>
    <a href="<?= SITE_URL ?>/admin/ai_copilot.php" class="<?= $admin_page==='ai_copilot'?'active':'' ?>"><i class="fas fa-magic"></i> AI Copilot Suite</a>
    <a href="<?= SITE_URL ?>/admin/dev_platform.php" class="<?= $admin_page==='dev_platform'?'active':'' ?>"><i class="fas fa-terminal"></i> Developer Platform</a>
    <a href="<?= SITE_URL ?>/admin/localization.php" class="<?= $admin_page==='localization'?'active':'' ?>"><i class="fas fa-globe"></i> Localization</a>
    <a href="<?= SITE_URL ?>/admin/ma_integration.php" class="<?= $admin_page==='ma_integration'?'active':'' ?>"><i class="fas fa-handshake"></i> M&A Integration</a>
    <a href="<?= SITE_URL ?>/admin/governance.php" class="<?= $admin_page==='governance'?'active':'' ?>"><i class="fas fa-landmark"></i> Governance</a>
    <a href="<?= SITE_URL ?>/admin/disaster_recovery.php" class="<?= $admin_page==='disaster_recovery'?'active':'' ?>"><i class="fas fa-server"></i> Disaster Recovery</a>
    <a href="<?= SITE_URL ?>/admin/holding_company.php" class="<?= $admin_page==='holding_company'?'active':'' ?>"><i class="fas fa-city"></i> Holding Company</a>

    <div class="nav-section-label">System</div>
    <a href="<?= SITE_URL ?>" target="_blank"><i class="fas fa-globe"></i> View Website</a>
    <a href="<?= SITE_URL ?>/admin/logout.php"><i class="fas fa-sign-out-alt"></i> Logout</a>
  </nav>
  <div class="sidebar-footer">Logged in as <?= h($_SESSION['admin_name'] ?? 'Admin') ?></div>
</aside>

<div class="main">
  <header class="topbar">
    <h1><?= $page_title ?? 'Dashboard' ?></h1>
    <div class="topbar-actions">
      <a href="<?= SITE_URL ?>" target="_blank"><i class="fas fa-external-link-alt"></i> Website</a>
      <a href="<?= SITE_URL ?>/admin/logout.php"><i class="fas fa-sign-out-alt"></i> Logout</a>
    </div>
  </header>
  <div class="content">
