<?php
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), '/');
$icon = $base . '/icons/icon.php';

echo json_encode([
    'name'             => 'EduTrack Teacher Portal',
    'short_name'       => 'TP',
    'description'      => 'Manage lessons, marks, attendance and homework on the go.',
    'start_url'        => $path . '/teacher-portal/index.php?source=pwa',
    'scope'            => $path . '/teacher-portal/',
    'display'          => 'standalone',
    'orientation'      => 'portrait-primary',
    'background_color' => '#ffffff',
    'theme_color'      => '#4f46e5',
    'lang'             => 'en',
    'categories'       => ['education', 'productivity'],
    'icons'            => [
        [
            'src'     => $icon . '?size=192&bg=4f46e5&letter=T',
            'sizes'   => '192x192',
            'type'    => 'image/png',
            'purpose' => 'any',
        ],
        [
            'src'     => $icon . '?size=512&bg=4f46e5&letter=T',
            'sizes'   => '512x512',
            'type'    => 'image/png',
            'purpose' => 'any maskable',
        ],
    ],
    'shortcuts' => [
        [
            'name'  => 'Today',
            'url'   => $path . '/teacher-portal/index.php?tab=today&source=pwa',
            'icons' => [['src' => $icon . '?size=96&bg=4f46e5&letter=T', 'sizes' => '96x96', 'type' => 'image/png']],
        ],
        [
            'name'  => 'Attendance',
            'url'   => $path . '/teacher-portal/index.php?tab=attendance&source=pwa',
            'icons' => [['src' => $icon . '?size=96&bg=4f46e5&letter=A', 'sizes' => '96x96', 'type' => 'image/png']],
        ],
    ],
], JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
