<?php
// /elms/admin/reports/index.php
declare(strict_types=1);

if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

if (!defined('APP_ROOT')) {
    define('APP_ROOT', dirname(__DIR__, 2)); // .../elms
}

$PAGE_TITLE = 'Reports Center';
$ACTIVE = 'reports';



require_once APP_ROOT . '/includes/admin_auth.php';
require_once APP_ROOT . '/includes/db.php';
if (!function_exists('h')) {
    function h($value): string {
        return htmlspecialchars((string)$value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
    }
}
require_once APP_ROOT . '/includes/admin_layout_top.php';

function rc_e($v): string {
    return htmlspecialchars((string)$v, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
}

$reports = [
    [
        'group' => 'Academic Reports',
        'items' => [
            [
                'title' => 'Assessment Analytics',
                'desc'  => 'Read-only gradebook summary, scores, statuses and corrected files.',
                'url'   => '/elms/admin/assessments/gradebook.php',
                'icon'  => 'bi-clipboard-data',
                'tone'  => 'primary',
            ],
            [
                'title' => 'Quiz Reports',
                'desc'  => 'Quiz attempts, scores and student performance summary.',
                'url'   => '/elms/admin/reports/quiz_report.php',
                'icon'  => 'bi-patch-question',
                'tone'  => 'success',
            ],
        ],
    ],
    [
        'group' => 'Student Reports',
        'items' => [
            [
                'title' => 'Full Student Report',
                'desc'  => 'Complete student academic performance report.',
                'url'   => '/elms/admin/reports/student_full_report.php',
                'icon'  => 'bi-person-lines-fill',
                'tone'  => 'danger',
            ],
        ],
    ],
    [
        'group' => 'Progress / Tracking',
        'items' => [
            [
                'title' => 'Tracking Sheet',
                'desc'  => 'Batch-wise student × assessment progress matrix.',
                'url'   => '/elms/admin/reports/tracking_sheet.php',
                'icon'  => 'bi-table',
                'tone'  => 'primary',
            ],
        ],
    ],
];
?>

<style>
.reports-center{
    display:grid;
    gap:16px;
}

.reports-hero{
    background:linear-gradient(135deg,#ffffff 0%,#f8fbff 55%,#eaf1ff 100%);
    border:1px solid #dbe7ff;
    border-radius:20px;
    padding:22px;
    box-shadow:0 10px 26px rgba(15,23,42,.045);
}

.reports-hero h2{
    margin:0;
    color:#020617;
    font-size:26px;
    font-weight:950;
    letter-spacing:-.03em;
}

.reports-hero p{
    margin:6px 0 0;
    color:#64748b;
    font-size:14px;
}

.reports-section{
    background:#fff;
    border:1px solid #e2e8f0;
    border-radius:20px;
    padding:18px;
    box-shadow:0 8px 22px rgba(15,23,42,.045);
}

.reports-section-title{
    margin:0 0 14px;
    color:#020617;
    font-size:15px;
    font-weight:950;
}

.report-card-link{
    display:block;
    height:100%;
    color:inherit;
    text-decoration:none;
}

.report-card{
    height:100%;
    background:linear-gradient(180deg,#ffffff,#f8fafc);
    border:1px solid #dbe3ef;
    border-radius:18px;
    padding:20px;
    transition:.18s ease;
    position:relative;
    overflow:hidden;
}

.report-card:before{
    content:"";
    position:absolute;
    inset:0 0 auto 0;
    height:4px;
    background:linear-gradient(90deg,#2563eb,#38bdf8);
    opacity:.8;
}

.report-card:hover{
    transform:translateY(-3px);
    border-color:#93c5fd;
    box-shadow:0 18px 36px rgba(15,23,42,.09);
}

.report-icon{
    width:48px;
    height:48px;
    border-radius:16px;
    display:grid;
    place-items:center;
    font-size:23px;
    margin-bottom:16px;
    background:#eff6ff;
    color:#2563eb;
}

.report-title{
    color:#020617;
    font-size:17px;
    font-weight:950;
    margin-bottom:6px;
}

.report-desc{
    color:#64748b;
    font-size:13px;
    line-height:1.5;
    margin:0;
    min-height:38px;
}

.report-open{
    margin-top:16px;
    display:inline-flex;
    align-items:center;
    gap:7px;
    font-size:13px;
    font-weight:900;
    color:#2563eb;
}

.report-card:hover .report-open{
    gap:10px;
}

@media(max-width:768px){
    .reports-hero{
        padding:18px;
    }

    .reports-hero h2{
        font-size:22px;
    }

    .reports-section{
        padding:14px;
    }

    .report-card{
        padding:18px;
    }
}
</style>

<div class="reports-center">

    <div class="reports-hero">
        <div class="d-flex flex-column flex-lg-row justify-content-between gap-3">
            <div>
                <h2>Reports Center</h2>
                <p>Select a report type. This page is only a launcher; detailed analytics are handled in each report page.</p>
            </div>

            <div>
                <a href="/elms/admin/dashboard.php" class="btn btn-outline-primary rounded-pill">
                    <i class="bi bi-speedometer2 me-1"></i>
                    Back to Dashboard
                </a>
            </div>
        </div>
    </div>

    <?php foreach ($reports as $section): ?>
        <div class="reports-section">
            <h5 class="reports-section-title"><?= rc_e($section['group']) ?></h5>

            <div class="row g-3">
                <?php foreach ($section['items'] as $item): ?>
                    <div class="col-xl-3 col-lg-4 col-md-6">
                        <a href="<?= rc_e($item['url']) ?>" class="report-card-link">
                            <div class="report-card">
                                <div class="report-icon bg-<?= rc_e($item['tone']) ?>-subtle text-<?= rc_e($item['tone']) ?>">
                                    <i class="bi <?= rc_e($item['icon']) ?>"></i>
                                </div>

                                <div class="report-title"><?= rc_e($item['title']) ?></div>
                                <p class="report-desc"><?= rc_e($item['desc']) ?></p>

                                <div class="report-open">
                                    Open Report
                                    <i class="bi bi-arrow-right"></i>
                                </div>
                            </div>
                        </a>
                    </div>
                <?php endforeach; ?>
            </div>
        </div>
    <?php endforeach; ?>

</div>

<?php require_once APP_ROOT . '/includes/admin_layout_bottom.php'; ?>