<!-- PACK503I_ACTIVE_ADMIN_INDEX role=<?php echo htmlspecialchars((string)($_SESSION['conference_role'] ?? $_SESSION['role'] ?? $_SESSION['user_role'] ?? ''), ENT_QUOTES, 'UTF-8'); ?> -->
<?php
// Pack503F: robust permission helper loading for old admin dashboard.
if (!function_exists('ec_can_menu')) {
    $permFile = dirname(__DIR__, 2) . '/helpers/permissions.php';
    if (file_exists($permFile)) {
        require_once $permFile;
    }
}
if (!function_exists('ec_legacy_can_menu')) {
    function ec_legacy_can_menu(string $url): bool
    {
        $sensitive = [
            '/easychair/admin/email-templates',
            '/easychair/admin/test-email',
            '/easychair/admin/rbac-matrix',
        ];

        if (function_exists('ec_can_menu')) {
            return ec_can_menu($url);
        }

        return !in_array($url, $sensitive, true);
    }
}
?>

<?php
if (defined('BASE_PATH') && file_exists(BASE_PATH . '/app/helpers/permissions.php')) {
    require_once BASE_PATH . '/app/helpers/permissions.php';
}
?>

<?php require __DIR__ . '/../layouts/header.php'; ?>

<div class="d-flex justify-content-between align-items-center mb-4">
    <div>
        <h1 class="page-title"><i class="fa-solid fa-house me-2"></i><?= e(trans('admin_home')) ?></h1>
        <div class="text-muted"><?= e(trans('dashboard')) ?></div>
    </div>
</div>

<div class="row g-4 mb-4">
    <div class="col-md-6 col-lg-3">
        <div class="stat-card p-4 h-100">
            <div class="kpi-value"><?= e((string) ($stats['users'] ?? '0')) ?></div>
            <div class="kpi-label"><?= e(trans('users')) ?></div>
        </div>
    </div>
    <div class="col-md-6 col-lg-3">
        <div class="stat-card p-4 h-100">
            <div class="kpi-value"><?= e((string) ($stats['conferences'] ?? '0')) ?></div>
            <div class="kpi-label"><?= e(trans('conference_list')) ?></div>
        </div>
    </div>
    <div class="col-md-6 col-lg-3">
        <div class="stat-card p-4 h-100">
            <div class="kpi-value"><?= e((string) ($stats['submissions'] ?? '0')) ?></div>
            <div class="kpi-label"><?= e(trans('submissions')) ?></div>
        </div>
    </div>
    <div class="col-md-6 col-lg-3">
        <div class="stat-card p-4 h-100">
            <div class="kpi-value"><?= e((string) ($stats['reviews'] ?? '0')) ?></div>
            <div class="kpi-label"><?= e(trans('review_assignments')) ?></div>
        </div>
    </div>
</div>

<div class="ec-card  ">
    <div class="ec-card-body p-4">
        <div class="section-title">
            <span class="dot"></span>
            <h2 class="h5 mb-0"><?= e(trans('admin_panel')) ?></h2>
        </div>

        <div class="d-flex flex-wrap gap-2">
            <a href="<?= e(base_path('admin/users')) ?>" class="btn ec-btn btn-outline-primary rounded-3"><?= e(trans('users')) ?></a>
            <a href="<?= e(base_path('admin/conferences')) ?>" class="btn ec-btn btn-outline-primary rounded-3"><?= e(trans('conference_list')) ?></a>
            <a href="<?= e(base_path('admin/tracks')) ?>" class="btn ec-btn btn-outline-primary rounded-3"><?= e(trans('tracks')) ?></a>
            <a href="<?= e(base_path('admin/dictionary')) ?>" class="btn ec-btn btn-outline-primary rounded-3"><?= e(trans('dictionary')) ?></a>
            <a href="<?= e(base_path('admin/custom-fields')) ?>" class="btn ec-btn btn-outline-primary rounded-3"><?= e(trans('custom_fields')) ?></a>
            <a href="<?= e(base_path('admin/workflow')) ?>" class="btn ec-btn btn-outline-dark rounded-3"><?= e(trans('workflow_rules')) ?></a>
            <a href="<?= e(base_path('admin/conference-blocks')) ?>" class="btn ec-btn btn-outline-primary rounded-3"><?= e(trans('conference_blocks')) ?></a>
            <a href="<?= e(base_path('admin/conference-committees')) ?>" class="btn ec-btn btn-outline-secondary rounded-3"><?= e(trans('committees')) ?></a>
            <a href="<?= e(base_path('admin/proceedings-book')) ?>" class="btn ec-btn btn-outline-success rounded-3"><?= e(trans('proceedings_book')) ?></a>
            <a href="<?= e(base_path('admin/reviewer-analytics')) ?>" class="btn ec-btn btn-outline-warning rounded-3"><?= e(trans('reviewer_analytics')) ?></a>
            <a href="<?= e(base_path('admin/submission-checks')) ?>" class="btn ec-btn btn-outline-danger rounded-3"><?= e(trans('submission_checks')) ?></a>
            <a href="<?= e(base_path('admin/homepage-blocks')) ?>" class="btn ec-btn btn-outline-dark rounded-3"><?= e(trans('homepage_blocks')) ?></a>
            <a href="<?= e(base_path('admin/schedule')) ?>" class="btn ec-btn btn-outline-primary rounded-3"><?= e(trans('conference_schedule')) ?></a>
            <a href="<?= e(base_path('admin/badges')) ?>" class="btn ec-btn btn-outline-secondary rounded-3"><?= e(trans('badges')) ?></a>
            <a href="<?= e(base_path('admin/attendance')) ?>" class="btn ec-btn btn-outline-primary rounded-3"><?= e(trans('attendance_desk')) ?></a>
            <a href="<?= e(base_path('admin/payments')) ?>" class="btn ec-btn btn-outline-success rounded-3"><?= e(trans('payment_invoices')) ?></a>
            <?php if (ec_legacy_can_menu('/easychair/admin/email-templates')): ?><a href="<?= e(base_path('admin/email-templates')) ?>" class="btn ec-btn btn-outline-dark rounded-3"><?= e(trans('email_templates')) ?></a><?php endif; ?>
            <a href="<?= e(base_path('admin/author-workflow')) ?>" class="btn ec-btn btn-outline-warning rounded-3"><?= e(trans('author_workflow')) ?></a>
            <a href="<?= e(base_path('admin/email-queue')) ?>" class="btn ec-btn btn-outline-primary rounded-3"><?= e(trans('email_queue')) ?></a>
            <a href="<?= e(base_path('admin/registration-form')) ?>" class="btn ec-btn btn-outline-secondary rounded-3"><?= e(trans('registration_form_builder')) ?></a>
            <a href="<?= e(base_path('admin/registration-submissions')) ?>" class="btn ec-btn btn-outline-dark rounded-3"><?= e(trans('registration_submissions')) ?></a>
        </div>
    </div>
</div>


<div class="ec-card   mt-4">
    <div class="ec-card-body p-4">
        <div class="section-title">
            <span class="dot"></span>
            <h2 class="h5 mb-0">Portal Modules</h2>
        </div>
        <div class="d-flex flex-wrap gap-2">
            <span class="badge ec-badge bg-primary">Homepage</span>
            <span class="badge ec-badge bg-primary">Conferences</span>
            <span class="badge ec-badge bg-primary">Tracks</span>
            <span class="badge ec-badge bg-primary">Submissions</span>
            <span class="badge ec-badge bg-primary">Submission Files</span>
            <span class="badge ec-badge bg-primary">Peer Review</span>
            <span class="badge ec-badge bg-primary">Decisions</span>
            <span class="badge ec-badge bg-primary">Notifications</span>
            <span class="badge ec-badge bg-primary">Proceedings</span>
            <span class="badge ec-badge bg-primary">Committees</span>
            <span class="badge ec-badge bg-primary">Schedule</span>
            <span class="badge ec-badge bg-primary">Presentations</span>
            <span class="badge ec-badge bg-primary">Badges</span>
            <span class="badge ec-badge bg-primary">Certificates</span>
            <span class="badge ec-badge bg-primary">Dictionary</span>
            <span class="badge ec-badge bg-primary">Custom Fields</span>
            <span class="badge ec-badge bg-primary">RBAC</span>
            <span class="badge ec-badge bg-primary">System Tools</span>
        </div>
    </div>
</div>

<?php require __DIR__ . '/../layouts/footer.php'; ?>
