<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}" class="scroll-smooth">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    {{-- SEO from admin (Admin → CMS → Global SEO Defaults). When the
         admin saves values there, every page on the site picks them up
         automatically — title, description, OG, and Twitter card all
         from the same data so social previews stay consistent. --}}
    @php
        $__ldTitle = \App\Models\SystemSetting::get('seo_default_title', config('app.name') . ' — AI-Powered Email Automation');
        $__ldDesc  = \App\Models\SystemSetting::get('seo_default_description', 'All-in-one AI email platform. Unified inbox, smart replies, campaigns, CRM, pipeline, 5-channel messaging. Self-hosted.');
        $__ldOg    = \App\Models\SystemSetting::get('seo_og_image', '');
    @endphp
    <title>{{ $__ldTitle }}</title>
    <meta name="description" content="{{ $__ldDesc }}">
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <!-- Open Graph -->
    <meta property="og:title" content="{{ $__ldTitle }}">
    <meta property="og:description" content="{{ $__ldDesc }}">
    @if($__ldOg)
        <meta property="og:image" content="{{ $__ldOg }}">
        <meta name="twitter:image" content="{{ $__ldOg }}">
        <meta name="twitter:card" content="summary_large_image">
    @else
        <meta property="og:image" content="{{ asset('images/og-image.png') }}">
        <meta name="twitter:card" content="summary">
    @endif
    <meta property="og:type" content="website">
    <meta property="og:url" content="{{ url('/') }}">
    <meta name="twitter:title" content="{{ $__ldTitle }}">
    <meta name="twitter:description" content="{{ $__ldDesc }}">

    <!-- Favicon -->
    @php
        $__landFav = \App\Models\SystemSetting::get('favicon');
        $__pwaOn = \App\Models\SystemSetting::get('pwa_enabled', 'false') === 'true';
    @endphp
    @if($__landFav)
    <link rel="icon" href="{{ asset('storage/' . $__landFav) }}" type="image/png">
    <link rel="apple-touch-icon" href="{{ asset('storage/' . $__landFav) }}">
    @else
    <link rel="icon" href="{{ asset('favicon.ico') }}" sizes="any">
    <link rel="icon" href="{{ asset('favicon.svg') }}" type="image/svg+xml">
    <link rel="apple-touch-icon" href="{{ asset('apple-touch-icon.png') }}">
    @endif
    @if($__pwaOn)
    <link rel="manifest" href="{{ route('pwa.manifest') }}">
    <meta name="theme-color" content="{{ \App\Models\SystemSetting::get('pwa_theme_color', '#6366f1') }}">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    @else
    <meta name="theme-color" content="#6C3CE7">
    @endif

    <!-- Fonts -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">

    @vite(['resources/css/landing.css', 'resources/js/landing-app.js'])

    <style>[x-cloak] { display: none !important; }</style>
</head>
<body class="landing-body">
    @yield('content')

    @if($__pwaOn ?? false)
    <script>
    if ('serviceWorker' in navigator) {
        navigator.serviceWorker.register('{{ asset("sw.js") }}').catch(function() {});
    }
    </script>
    @endif
</body>
</html>
