@props([
    'title' => 'RemoteMatch',
    'max' => 'max-w-6xl',
])

@php
    $frontendUser = auth('web')->user();
    $brandName = setting('general.application_name', config('app.name', 'RemoteMatch'));
    $ctaText = setting('branding.landing_page_cta_text', 'Get Matched');
    $faviconUrl = \App\Support\Branding::assetUrl(setting('branding.favicon'));
@endphp

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>{{ $title }}{{ $title !== $brandName ? ' - '.$brandName : '' }}</title>
    @if ($faviconUrl)
        <link rel="icon" href="{{ $faviconUrl }}">
    @endif
    @vite(['resources/css/app.css', 'resources/js/app.js'])
    @stack('head')
</head>
<body class="font-sans text-slate-950 antialiased">
    <div data-pjax-root>
        <main class="app-bg">
            <div class="mx-auto flex min-h-screen w-full {{ $max }} flex-col px-4 py-5 pb-24 sm:px-6 sm:pb-8 lg:px-8">
                <header class="mb-7 flex items-center justify-between gap-4">
                    <a href="{{ route('landing') }}" class="flex items-center gap-3" aria-label="{{ $brandName }} home">
                        <x-brand-logo />
                    </a>

                    @if ($frontendUser)
                        <div class="flex items-center gap-2">
                            @if ($frontendUser->canViewMatchedJobs())
                                <a class="nav-link hidden sm:inline-flex" href="{{ route('applicant.dashboard') }}">Dashboard</a>
                                <a class="nav-link hidden sm:inline-flex" href="{{ route('jobs.index') }}">Jobs</a>
                            @endif

                            <form method="POST" action="{{ route('logout') }}">
                                @csrf
                                <button class="btn-ghost" type="submit">Sign out</button>
                            </form>
                        </div>
                    @else
                        <div class="flex items-center gap-2">
                            <a href="{{ route('login') }}" class="nav-link hidden sm:inline-flex" data-auth-modal-open>
                                Login
                            </a>
                            <a href="{{ route('auth.google.redirect', ['popup' => 1]) }}" class="btn-primary min-h-11 px-4 text-sm" data-google-popup>
                                {{ $ctaText }}
                            </a>
                        </div>
                    @endif
                </header>

                {{ $slot }}
            </div>
        </main>

        @unless ($frontendUser)
            <x-auth-modal />
        @endunless
    </div>
</body>
</html>
