<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}" @class(['dark' => ($appearance ?? 'system') == 'dark'])>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        {{-- Inline script to detect system dark mode preference and apply it immediately --}}
        <script>
            (function() {
                const appearance = '{{ $appearance ?? "system" }}';

                if (appearance === 'system') {
                    const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;

                    if (prefersDark) {
                        document.documentElement.classList.add('dark');
                    }
                }
            })();
        </script>

        {{-- Inline style to set the HTML background color based on our theme in app.css --}}
        <style>
            html {
                background-color: oklch(1 0 0);
            }

            html.dark {
                background-color: oklch(0.145 0 0);
            }
        </style>

        <link rel="icon" href="/favicon.ico" sizes="any">
        <link rel="icon" href="/favicon.svg" type="image/svg+xml">
        <link rel="apple-touch-icon" href="/apple-touch-icon.png">
        <link rel="manifest" href="/manifest.json">
        <meta name="theme-color" content="#1a1a1a">
        <meta name="description" content="{{ $page['seo']['description'] ?? 'DST Collection - DST Punya Gaya' }}">
        <meta name="mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
        <meta name="apple-mobile-web-app-title" content="{{ $page['seo']['title'] ?? config('app.name', 'DST Collection') }}">

        {{-- Open Graph / Facebook --}}
        <meta property="og:type" content="website">
        <meta property="og:title" content="{{ $page['seo']['title'] ?? config('app.name', 'DST Collection') }}">
        <meta property="og:description" content="{{ $page['seo']['description'] ?? 'DST Collection - DST Punya Gaya' }}">
        <meta property="og:url" content="{{ $page['seo']['url'] ?? url()->current() }}">
        <meta property="og:site_name" content="{{ config('app.name', 'DST Collection') }}">
        <meta property="og:image" content="{{ $page['seo']['image'] ?? url('/assets/logo.png') }}">
        <meta property="og:image:width" content="1200">
        <meta property="og:image:height" content="630">

        {{-- Twitter Card --}}
        <meta name="twitter:card" content="summary_large_image">
        <meta name="twitter:title" content="{{ $page['seo']['title'] ?? config('app.name', 'DST Collection') }}">
        <meta name="twitter:description" content="{{ $page['seo']['description'] ?? 'DST Collection - DST Punya Gaya' }}">
        <meta name="twitter:image" content="{{ $page['seo']['image'] ?? url('/assets/logo.png') }}">

        @fonts

        @viteReactRefresh
        @vite(['resources/css/app.css', 'resources/js/app.tsx', "resources/js/pages/{$page['component']}.tsx"])
        <x-inertia::head>
            <title>{{ config('app.name', 'DST Collection') }}</title>
        </x-inertia::head>
    </head>
    <body class="font-sans antialiased">
        <x-inertia::app />
    </body>
</html>
