<?php
/**
 * Admin left sidebar navigation.
 * Included by every admin page, inside .admin-layout.
 */
$_sp      = basename($_SERVER['PHP_SELF']);   // current filename
$_sa      = $_GET['action'] ?? '';            // current action param
$_inAdmin = str_starts_with($_SERVER['PHP_SELF'], '/admin/');

// Helper: active class
$_ac = fn(bool $cond): string => $cond ? ' active' : '';
?>
<aside class="admin-sidebar">
    <nav class="admin-nav" aria-label="<?= t('nav.admin') ?>">

        <!-- Dashboard -->
        <div class="admin-nav-section">
            <a href="/admin/index.php"
               class="admin-nav-item<?= $_ac($_inAdmin && $_sp === 'index.php') ?>">
                <span class="admin-nav-icon">📊</span>
                <?= t('admin.dashboard') ?>
            </a>
        </div>

        <!-- Users -->
        <div class="admin-nav-section">
            <div class="admin-nav-heading"><?= t('nav.users') ?></div>
            <a href="/admin/users.php"
               class="admin-nav-item<?= $_ac($_sp === 'users.php' && $_sa !== 'create') ?>">
                <span class="admin-nav-icon">👥</span>
                <?= t('user.list') ?>
            </a>
            <a href="/admin/users.php?action=create"
               class="admin-nav-item<?= $_ac($_sp === 'users.php' && $_sa === 'create') ?>">
                <span class="admin-nav-icon">➕</span>
                <?= t('user.create') ?>
            </a>
        </div>

        <!-- Application -->
        <div class="admin-nav-section">
            <div class="admin-nav-heading"><?= t('settings.title') ?></div>
            <a href="/admin/settings.php#appearance"
               class="admin-nav-item<?= $_ac($_sp === 'settings.php') ?>">
                <span class="admin-nav-icon">🎨</span>
                <?= t('settings.appearance') ?>
            </a>
            <a href="/admin/settings.php#debug"
               class="admin-nav-item<?= $_ac($_sp === 'settings.php') ?>">
                <span class="admin-nav-icon">🐛</span>
                <?= t('settings.debug_mode') ?>
            </a>
            <a href="/admin/settings.php#auth"
               class="admin-nav-item<?= $_ac($_sp === 'settings.php') ?>">
                <span class="admin-nav-icon">🔐</span>
                <?= t('settings.auth_methods') ?>
            </a>
            <a href="/admin/settings.php#smtp"
               class="admin-nav-item<?= $_ac($_sp === 'settings.php') ?>">
                <span class="admin-nav-icon">📧</span>
                <?= t('settings.smtp_title') ?>
            </a>
            <a href="/admin/report_subscriptions.php"
               class="admin-nav-item<?= $_ac($_sp === 'report_subscriptions.php') ?>">
                <span class="admin-nav-icon">📬</span>
                <?= t('report_sub.title') ?>
            </a>
        </div>

        <!-- Maintenance -->
        <div class="admin-nav-section">
            <div class="admin-nav-heading"><?= t('admin.maintenance') ?></div>
            <a href="/admin/backup.php"
               class="admin-nav-item<?= $_ac($_sp === 'backup.php') ?>">
                <span class="admin-nav-icon">💾</span>
                <?= t('backup.title') ?>
            </a>
            <a href="/admin/batch.php"
               class="admin-nav-item<?= $_ac($_sp === 'batch.php') ?>">
                <span class="admin-nav-icon">⏲</span>
                <?= t('batch.title') ?>
            </a>
            <a href="/admin/update.php"
               class="admin-nav-item<?= $_ac($_sp === 'update.php') ?>">
                <span class="admin-nav-icon">🔄</span>
                <?= t('update.title') ?>
            </a>
        </div>

        <!-- Modules -->
        <div class="admin-nav-section">
            <div class="admin-nav-heading"><?= t('module.title') ?></div>
            <a href="/admin/modules.php"
               class="admin-nav-item<?= $_ac($_sp === 'modules.php') ?>">
                <span class="admin-nav-icon">📦</span>
                <?= t('module.manage') ?>
            </a>
        </div>

    </nav>
</aside>
