<?php
namespace App\Services;

class PwaService {
    public function __construct(private \PDO $pdo) {}

    public function manifest(): array {
        $pwa = $this->pdo->query("SELECT * FROM pwa_settings WHERE is_enabled = 1 LIMIT 1")->fetch() ?: [];
        return [
            'name' => $pwa['app_name'] ?? 'CIX Orbit Academy',
            'short_name' => $pwa['short_name'] ?? 'CIX Academy',
            'description' => $pwa['description'] ?? 'Learn. Build. Automate. Grow.',
            'start_url' => $pwa['start_url'] ?? '/',
            'display' => $pwa['display_mode'] ?? 'standalone',
            'orientation' => $pwa['orientation'] ?? 'portrait',
            'background_color' => $pwa['background_color'] ?? '#ffffff',
            'theme_color' => $pwa['theme_color'] ?? '#ff6b00',
            'icons' => [
                ['src' => '/public/assets/images/icon-192.png', 'sizes' => '192x192', 'type' => 'image/png', 'purpose' => 'any'],
                ['src' => '/public/assets/images/icon-512.png', 'sizes' => '512x512', 'type' => 'image/png', 'purpose' => 'any'],
                ['src' => '/public/assets/images/maskable-icon.png', 'sizes' => '512x512', 'type' => 'image/png', 'purpose' => 'maskable'],
            ],
        ];
    }
}
