<?php
if (!isset($pageTitle)) $pageTitle = 'Dashboard';
$here = basename($_SERVER['PHP_SELF'] ?? '');
function adminNavActive($files) {
    global $here;
    if (!is_array($files)) $files = [$files];
    foreach ($files as $f) {
        if ($here === $f) return ' is-active';
    }
    return '';
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo htmlspecialchars($pageTitle); ?> - Admin</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="<?php echo ADMIN_SITE_ROOT; ?>/assets/css/style.css">
    <link rel="stylesheet" href="<?php echo ADMIN_SITE_ROOT; ?>/assets/css/admin.css?v=4">
</head>
<body class="admin-body admin-body--sidebar">
<button type="button" class="admin-sidebar-backdrop" id="admin-sidebar-backdrop" aria-hidden="true"></button>
<div class="admin-layout">
    <aside class="admin-sidebar" id="admin-sidebar">
        <div class="admin-sidebar-brand">
            <a href="index.php">CRIMSON Admin</a>
        </div>
        <nav class="admin-sidebar-nav">
            <div class="admin-sidebar-section">
                <span class="admin-sidebar-heading">Main</span>
                <a href="index.php" class="admin-sidebar-link<?php echo adminNavActive('index.php'); ?>">Dashboard</a>
                <a href="help.php" class="admin-sidebar-link<?php echo adminNavActive('help.php'); ?>">Help &amp; guide</a>
            </div>
            <div class="admin-sidebar-section">
                <span class="admin-sidebar-heading">Products</span>
                <a href="products.php" class="admin-sidebar-link<?php echo adminNavActive('products.php'); ?>">Products</a>
                <a href="categories.php" class="admin-sidebar-link<?php echo adminNavActive('categories.php'); ?>">Categories</a>
            </div>
            <div class="admin-sidebar-section">
                <span class="admin-sidebar-heading">Pages &amp; media</span>
                <a href="pages.php" class="admin-sidebar-link<?php echo adminNavActive('pages.php'); ?>">Pages (About, Tech)</a>
                <a href="about-edit.php" class="admin-sidebar-link<?php echo adminNavActive('about-edit.php'); ?>">About page (sections)</a>
                <a href="tech-quality-edit.php" class="admin-sidebar-link<?php echo adminNavActive('tech-quality-edit.php'); ?>">Technology &amp; Quality</a>
                <a href="gallery.php" class="admin-sidebar-link<?php echo adminNavActive('gallery.php'); ?>">Photo gallery</a>
                <a href="videos.php" class="admin-sidebar-link<?php echo adminNavActive('videos.php'); ?>">Videos</a>
            </div>
            <div class="admin-sidebar-section">
                <span class="admin-sidebar-heading">Homepage</span>
                <a href="home-sections.php" class="admin-sidebar-link<?php echo adminNavActive('home-sections.php'); ?>">Hero slider &amp; client section</a>
                <a href="home-blocks.php" class="admin-sidebar-link<?php echo adminNavActive('home-blocks.php'); ?>">Features &amp; Why choose us</a>
                <a href="stats.php" class="admin-sidebar-link<?php echo adminNavActive('stats.php'); ?>">Stats (numbers)</a>
                <a href="clients.php" class="admin-sidebar-link<?php echo adminNavActive('clients.php'); ?>">Our clients (logos)</a>
                <a href="client-feedback.php" class="admin-sidebar-link<?php echo adminNavActive('client-feedback.php'); ?>">Client Feedback (testimonials)</a>
                <a href="footer-content.php" class="admin-sidebar-link<?php echo adminNavActive('footer-content.php'); ?>">Footer</a>
            </div>
            <div class="admin-sidebar-section">
                <span class="admin-sidebar-heading">Messages &amp; site</span>
                <a href="enquiries.php" class="admin-sidebar-link<?php echo adminNavActive('enquiries.php'); ?>">Enquiries</a>
                <a href="settings.php" class="admin-sidebar-link<?php echo adminNavActive('settings.php'); ?>">Settings &amp; logo</a>
                <a href="smtp.php" class="admin-sidebar-link<?php echo adminNavActive('smtp.php'); ?>">Email (SMTP)</a>
            </div>
        </nav>
        <div class="admin-sidebar-footer">
            <a href="help.php" class="admin-sidebar-link admin-sidebar-link--ghost">Help</a>
            <a href="<?php echo ADMIN_SITE_ROOT; ?>/index.php" target="_blank" class="admin-sidebar-link admin-sidebar-link--ghost">View site</a>
            <a href="logout.php" class="admin-sidebar-link admin-sidebar-link--danger">Logout</a>
        </div>
    </aside>
    <div class="admin-content-wrap">
        <header class="admin-topbar">
            <button type="button" class="admin-sidebar-toggle" id="admin-sidebar-toggle" aria-label="Open menu">☰</button>
            <span class="admin-topbar-title"><?php echo htmlspecialchars($pageTitle); ?></span>
        </header>
        <main class="admin-main">
