@props([
    'title',
    'settings' => null,
    'tenant' => null,
])

@php
    $rtl = app()->getLocale() === 'ar';
    $primary = config('theme.colors.primary');
    $accent = config('theme.colors.accent');
    $text = config('theme.colors.text');
    $muted = config('theme.colors.muted');
    $seoTitle = $settings?->seo_title ?: ($title.' — '.($tenant?->name ?? ''));
    $seoDesc = $settings?->seo_description;
@endphp

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}" dir="{{ $rtl ? 'rtl' : 'ltr' }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>{{ $seoTitle }}</title>
    @if ($seoDesc)<meta name="description" content="{{ $seoDesc }}">@endif
    @if ($settings?->seo_keywords)<meta name="keywords" content="{{ $settings->seo_keywords }}">@endif
    <link href="{{ asset('assets/admin/css/bootstrap.min.css') }}" rel="stylesheet">
    <link href="{{ asset('assets/admin/icon-fonts/feather/feather.css') }}" rel="stylesheet">
    <link href="{{ asset('assets/admin/css/career-portal.css') }}" rel="stylesheet">
    <style>
        :root {
            --cp-primary: {{ $primary }};
            --cp-primary-dark: {{ config('theme.colors.primary_dark') }};
            --cp-accent: {{ $accent }};
            --cp-accent-dark: {{ config('theme.colors.accent_dark') }};
            --cp-text: {{ $text }};
            --cp-muted: {{ $muted }};
            --cp-gradient: {{ config('theme.gradients.primary') }};
            --cp-gradient-accent: {{ config('theme.gradients.success') }};
        }
    </style>
</head>
<body class="cp-body">
    <nav class="cp-nav">
        <div class="container d-flex flex-wrap align-items-center justify-content-between gap-3 py-3">
            <a class="cp-brand" href="{{ route('careers.home', ['tenant' => $tenant->slug]) }}">
                <span class="cp-brand-name">{{ $tenant->name }}</span>
                @if ($settings?->portal_title && $settings->portal_title !== $tenant->name)
                    <span class="cp-brand-sub">{{ $settings->portal_title }}</span>
                @endif
            </a>
            <div class="d-flex align-items-center gap-3">
                <a class="cp-nav-link" href="{{ route('careers.jobs', ['tenant' => $tenant->slug]) }}">{{ __('recruitment.career_portal.nav.jobs') }}</a>
                <a class="cp-nav-link" href="{{ route('careers.track', ['tenant' => $tenant->slug]) }}">{{ __('recruitment.career_portal.nav.track') }}</a>
                <a class="cp-btn cp-btn-sm" href="{{ route('careers.jobs', ['tenant' => $tenant->slug]) }}">{{ __('recruitment.career_portal.actions.browse_jobs') }}</a>
            </div>
        </div>
    </nav>
    {{ $slot }}
    <footer class="cp-footer">
        <div class="container d-flex flex-wrap justify-content-between gap-2 py-4">
            <div>
                <div class="fw-semibold" style="color: var(--cp-text);">{{ $tenant->name }}</div>
                <div class="small cp-muted">{{ $settings?->portal_subtitle }}</div>
            </div>
            <div class="small cp-muted text-end">
                @if ($settings?->contact_email)<div>{{ $settings->contact_email }}</div>@endif
                @if ($settings?->contact_phone)<div>{{ $settings->contact_phone }}</div>@endif
            </div>
        </div>
    </footer>
</body>
</html>
