<?php
$currentPage = basename($_SERVER['PHP_SELF']);
$pageTitle = $pageTitle ?? 'Admin Panel';
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title><?= e($pageTitle) ?> - MANIAR Admin</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="stylesheet" href="<?= BASE_URL ?>assets/css/style.css">
    <link rel="stylesheet" href="<?= BASE_URL ?>assets/css/admin.css">
    <link rel="stylesheet" href="<?= BASE_URL ?>assets/css/part5.css">
    <link rel="stylesheet" href="<?= BASE_URL ?>assets/css/part6.css">
    <link rel="stylesheet" href="<?= BASE_URL ?>assets/css/part7.css">

    <style>
        :root {
            --blue: <?= e($site['main_color'] ?? '#009DFF') ?>;
            --orange: <?= e($site['second_color'] ?? '#FF7A00') ?>;
        }
    </style>
</head>
<body>

<div class="admin-layout">
    <aside class="admin-sidebar">
        <a href="dashboard.php" class="admin-logo">
            <div class="brand-icon">M</div>

            <div>
                <strong>MANIAR</strong>
                <span>Admin Panel</span>
            </div>
        </a>

        <nav class="admin-menu">
            <a href="dashboard.php" class="<?= $currentPage === 'dashboard.php' ? 'active' : '' ?>">📊 Dashboard</a>

            <a href="products.php" class="<?= in_array($currentPage, ['products.php','add-product.php','edit-product.php']) ? 'active' : '' ?>">📦 Products</a>

            <a href="categories.php" class="<?= $currentPage === 'categories.php' ? 'active' : '' ?>">🏷️ Categories</a>

            <a href="orders.php" class="<?= in_array($currentPage, ['orders.php','order-view.php','print-order.php']) ? 'active' : '' ?>">🛒 Orders</a>

            <a href="payments.php" class="<?= $currentPage === 'payments.php' ? 'active' : '' ?>">💳 Payments</a>

            <a href="design.php" class="<?= $currentPage === 'design.php' ? 'active' : '' ?>">🎨 Design</a>

            <a href="settings.php" class="<?= $currentPage === 'settings.php' ? 'active' : '' ?>">⚙️ Settings</a>

            <a href="<?= BASE_URL ?>track-order.php" target="_blank">🔎 Track Page</a>

            <a href="<?= BASE_URL ?>index.php" target="_blank">🌍 View Site</a>

            <a href="logout.php" class="logout-link">🚪 Logout</a>
        </nav>
    </aside>

    <main class="admin-content">