<?php
// Dynamic PWA manifest
header('Content-Type: application/json');
require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/db.php';
$p = db_fetch("SELECT * FROM pwa_settings LIMIT 1");
$icon192 = $p['icon_192'] ? url($p['icon_192']) : url('assets/images/icon-192.png');
$icon512 = $p['icon_512'] ? url($p['icon_512']) : url('assets/images/icon-512.png');
echo json_encode([
  'name' => $p['app_name'] ?? 'QuranClassPro',
  'short_name' => $p['short_name'] ?? 'Quran',
  'description' => $p['description'] ?? 'Learn Quran online',
  'start_url' => $p['start_url'] ?? '/',
  'display' => $p['display'] ?? 'standalone',
  'orientation' => $p['orientation'] ?? 'portrait',
  'theme_color' => $p['theme_color'] ?? '#0d5c3f',
  'background_color' => $p['background_color'] ?? '#ffffff',
  'icons' => [
    ['src' => $icon192, 'sizes' => '192x192', 'type' => 'image/png'],
    ['src' => $icon512, 'sizes' => '512x512', 'type' => 'image/png'],
  ],
], JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
