<?php
require __DIR__ . '/bootstrap.php';
$settings = Settings::safeAll();
$name = trim($settings['site_name'] ?? '') ?: 'CFC AUTOESCOLA CRISTO REI';
$iconVersion = substr(sha1(($settings['logo_path'] ?? '') . '|' . $name), 0, 12);
header('Content-Type: application/manifest+json; charset=utf-8');
echo json_encode([
    'name' => $name,
    'short_name' => substr($name, 0, 18),
    'description' => 'Sistema online de autoescola com área do aluno, agendamentos e painel administrativo.',
    'start_url' => rtrim(dirname($_SERVER['SCRIPT_NAME'] ?? '/index.php'), '/') . '/index.php?r=home',
    'scope' => '/',
    'display' => 'standalone',
    'orientation' => 'portrait-primary',
    'background_color' => '#ffffff',
    'theme_color' => '#e7b708',
    'categories' => ['education', 'business'],
    'icons' => [
        ['src' => '/pwa-icon.php?size=192&v=' . $iconVersion, 'sizes' => '192x192', 'type' => 'image/png'],
        ['src' => '/pwa-icon.php?size=512&v=' . $iconVersion, 'sizes' => '512x512', 'type' => 'image/png'],
        ['src' => '/pwa-icon.php?size=512&maskable=1&v=' . $iconVersion, 'sizes' => '512x512', 'type' => 'image/png', 'purpose' => 'maskable'],
    ],
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
