<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="csrf-token" content="{{ csrf_token() }}">

    {{-- SEO: Title --}}
    @php
        $siteName = setting('site_name', config('app.name'));
        $pageTitle = trim(@trim($__env->yieldContent('title')));
        $metaTitle = $pageTitle ? ($pageTitle . ' — ' . $siteName) : (setting('meta_title') ?: $siteName);
    @endphp
    <title>{{ $metaTitle }}</title>

    {{-- SEO: Meta tags --}}
    @if($d = setting('meta_description'))<meta name="description" content="{{ $d }}">@endif
    @if($k = setting('meta_keywords'))<meta name="keywords" content="{{ $k }}">@endif
    @if($g = setting('google_search_console'))<meta name="google-site-verification" content="{{ $g }}">@endif

    {{-- OpenGraph (Facebook/LinkedIn/WhatsApp) --}}
    <meta property="og:type" content="website">
    <meta property="og:site_name" content="{{ $siteName }}">
    <meta property="og:title" content="{{ setting('og_title') ?: $metaTitle }}">
    <meta property="og:description" content="{{ setting('og_description') ?: setting('meta_description') }}">
    <meta property="og:url" content="{{ url()->current() }}">
    @if($og = og_image())<meta property="og:image" content="{{ $og }}">@endif

    {{-- Twitter / X --}}
    <meta name="twitter:card" content="{{ setting('twitter_card', 'summary_large_image') }}">
    @if($th = setting('twitter_handle'))
        <meta name="twitter:site" content="@{{ $th }}">
        <meta name="twitter:creator" content="@{{ $th }}">
    @endif
    <meta name="twitter:title" content="{{ setting('og_title') ?: $metaTitle }}">
    <meta name="twitter:description" content="{{ setting('og_description') ?: setting('meta_description') }}">
    @if($og = og_image())<meta name="twitter:image" content="{{ $og }}">@endif

    {{-- Favicon --}}
    @if($fav = site_favicon())
        <link rel="icon" href="{{ $fav }}">
        <link rel="shortcut icon" href="{{ $fav }}">
        <link rel="apple-touch-icon" href="{{ $fav }}">
    @endif

    <link href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700;900&family=Lora:wght@400;500;700&display=swap" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="{{ asset('css/app.css') }}" rel="stylesheet">

    {{-- Google Analytics 4 --}}
    @if($ga = setting('google_analytics'))
    <script async src="https://www.googletagmanager.com/gtag/js?id={{ $ga }}"></script>
    <script>
        window.dataLayer = window.dataLayer || [];
        function gtag(){dataLayer.push(arguments);}
        gtag('js', new Date());
        gtag('config', '{{ $ga }}');
    </script>
    @endif

    @stack('head')
</head>
<body>
@include('partials.public-nav')

<main>
    @if(session('success'))<div class="container mt-3"><div class="alert alert-success alert-auto-dismiss">{{ session('success') }}</div></div>@endif
    @if(session('error'))<div class="container mt-3"><div class="alert alert-danger alert-auto-dismiss">{{ session('error') }}</div></div>@endif
    @if(session('info'))<div class="container mt-3"><div class="alert alert-info alert-auto-dismiss">{{ session('info') }}</div></div>@endif

    @yield('content')
</main>

@include('partials.public-footer')

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="{{ asset('js/app.js') }}"></script>
@stack('scripts')
</body>
</html>
