<?php
/**
 * EduTrack Admin/Staff PWA Manifest
 * Served as application/manifest+json with dynamic BASE_URL paths.
 */
header('Content-Type: application/manifest+json');
header('Cache-Control: public, max-age=3600');

require_once __DIR__ . '/config.php';

$base    = rtrim(BASE_URL, '/');
$path    = rtrim((string) parse_url($base, PHP_URL_PATH), '/'); // e.g. /edutrack or ''
$iconUrl = $base . '/icons/icon.php';

echo json_encode([
    'name'             => 'EduTrack Pro',
    'short_name'       => 'EduTrack',
    'description'      => 'School Management System — manage students, fees, attendance, reports and more.',
    'start_url'        => $path . '/dashboard.php?source=pwa',
    'scope'            => $path . '/',
    'display'          => 'standalone',
    'orientation'      => 'portrait-primary',
    'background_color' => '#ffffff',
    'theme_color'      => '#2563eb',
    'lang'             => 'en',
    'categories'       => ['education', 'productivity'],
    'icons'            => [
        [
            'src'     => $iconUrl . '?size=192&bg=2563eb&letter=E',
            'sizes'   => '192x192',
            'type'    => 'image/png',
            'purpose' => 'any',
        ],
        [
            'src'     => $iconUrl . '?size=512&bg=2563eb&letter=E',
            'sizes'   => '512x512',
            'type'    => 'image/png',
            'purpose' => 'any maskable',
        ],
    ],
    'shortcuts' => [
        [
            'name'       => 'Students',
            'short_name' => 'Students',
            'url'        => $path . '/students.php?source=pwa',
            'icons'      => [['src' => $iconUrl . '?size=96&bg=2563eb&letter=S', 'sizes' => '96x96', 'type' => 'image/png']],
        ],
        [
            'name'       => 'Dashboard',
            'short_name' => 'Dashboard',
            'url'        => $path . '/dashboard.php?source=pwa',
            'icons'      => [['src' => $iconUrl . '?size=96&bg=2563eb&letter=D', 'sizes' => '96x96', 'type' => 'image/png']],
        ],
    ],
], JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
