<?php

// Public customer-facing storefront — the CurryPot.lk Online Ordering PWA.
// No login required. Renders a standalone mobile app shell; all data comes from /api/* endpoints.
class ShopController extends Controller
{
    public function index(): void
    {
        $logoPath = setting('logo_path', '');
        $this->view('shop.index', [
            'pageTitle'   => setting('company_name', 'CurryPot.lk') . ' — Order Online',
            'companyName' => setting('company_name', 'CurryPot.lk'),
            'companyPhone' => setting('company_phone', ''),
            'logoUrl'     => $logoPath ? BASE_URL . '/' . $logoPath : null,
        ], null); // standalone — no admin layout
    }

    public function manifest(): void
    {
        $name = setting('company_name', 'CurryPot.lk');
        header('Content-Type: application/manifest+json');
        echo json_encode([
            'name'             => $name . ' — Online Ordering',
            'short_name'       => $name,
            'description'      => 'Order fresh rice & curry online from ' . $name . ' — browse the menu, order, and track delivery.',
            'start_url'        => BASE_URL . '/shop',
            'scope'            => BASE_URL . '/',
            'display'          => 'standalone',
            'orientation'      => 'portrait',
            'background_color' => '#F4F6FB',
            'theme_color'      => '#16305C',
            'icons' => [
                ['src' => BASE_URL . '/assets/icons/icon-192.png', 'sizes' => '192x192', 'type' => 'image/png', 'purpose' => 'any maskable'],
                ['src' => BASE_URL . '/assets/icons/icon-512.png', 'sizes' => '512x512', 'type' => 'image/png', 'purpose' => 'any maskable'],
            ],
        ]);
        exit;
    }
}