<?php
/**
 * EduTrack Parent Portal PWA Manifest
 */
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), '/');
$iconUrl = $base . '/icons/icon.php';

echo json_encode([
    'name'             => 'EduTrack Parent Portal',
    'short_name'       => 'EduTrack Parents',
    'description'      => 'Monitor your child\'s progress — fees, grades, attendance and more.',
    'start_url'        => $path . '/parent-portal/dashboard.php?source=pwa',
    'scope'            => $path . '/parent-portal/',
    'display'          => 'standalone',
    'orientation'      => 'portrait-primary',
    'background_color' => '#ffffff',
    'theme_color'      => '#16a34a',
    'lang'             => 'en',
    'categories'       => ['education'],
    'icons'            => [
        [
            'src'     => $iconUrl . '?size=192&bg=16a34a&letter=E',
            'sizes'   => '192x192',
            'type'    => 'image/png',
            'purpose' => 'any',
        ],
        [
            'src'     => $iconUrl . '?size=512&bg=16a34a&letter=E',
            'sizes'   => '512x512',
            'type'    => 'image/png',
            'purpose' => 'any maskable',
        ],
    ],
    'shortcuts' => [
        [
            'name'       => 'My Children',
            'short_name' => 'Children',
            'url'        => $path . '/parent-portal/dashboard.php?source=pwa',
            'icons'      => [['src' => $iconUrl . '?size=96&bg=16a34a&letter=C', 'sizes' => '96x96', 'type' => 'image/png']],
        ],
        [
            'name'       => 'Fee Balance',
            'short_name' => 'Fees',
            'url'        => $path . '/parent-portal/fees.php?source=pwa',
            'icons'      => [['src' => $iconUrl . '?size=96&bg=16a34a&letter=F', 'sizes' => '96x96', 'type' => 'image/png']],
        ],
    ],
], JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
