@php
    $benefits = [
        ['icon' => 'fe fe-trending-up', 'key' => 'growth'],
        ['icon' => 'fe fe-heart', 'key' => 'culture'],
        ['icon' => 'fe fe-award', 'key' => 'impact'],
        ['icon' => 'fe fe-shield', 'key' => 'stability'],
    ];
@endphp
<x-ui.layout.career-portal :title="$settings->portal_title ?: __('recruitment.career_portal.home_title')" :settings="$settings" :tenant="$tenant">
    <section class="cp-hero">
        <div class="container">
            <div class="cp-hero-inner">
                <p class="small text-uppercase mb-2 opacity-75 tracking-wide">{{ $tenant->name }}</p>
                <h1>{{ $settings->portal_title ?: __('recruitment.career_portal.home_title') }}</h1>
                <p class="mb-4">{{ $settings->portal_subtitle ?: __('recruitment.career_portal.defaults.subtitle') }}</p>
                <div class="d-flex flex-wrap gap-2">
                    <a class="cp-btn" href="{{ route('careers.jobs', ['tenant' => $tenant->slug]) }}">{{ __('recruitment.career_portal.actions.browse_jobs') }}</a>
                    <a class="cp-btn cp-btn-outline" href="#search-jobs">{{ __('recruitment.career_portal.actions.search_jobs') }}</a>
                </div>
            </div>
        </div>
    </section>

    @if ($settings->about_text)
        <section class="cp-section cp-section-alt">
            <div class="container">
                <h2 class="cp-section-title">{{ __('recruitment.career_portal.about') }}</h2>
                <p class="cp-section-lead mb-0">{{ $settings->about_text }}</p>
            </div>
        </section>
    @endif

    <section class="cp-section" id="search-jobs">
        <div class="container">
            <h2 class="cp-section-title">{{ __('recruitment.career_portal.search_title') }}</h2>
            <p class="cp-section-lead">{{ __('recruitment.career_portal.search_lead') }}</p>
            <form method="GET" action="{{ route('careers.jobs', ['tenant' => $tenant->slug]) }}" class="cp-search">
                <div class="row g-2 align-items-center">
                    <div class="col-md-8">
                        <input type="search" name="q" class="form-control" placeholder="{{ __('recruitment.career_portal.search_placeholder') }}">
                    </div>
                    <div class="col-md-4">
                        <button class="cp-btn w-100" type="submit">{{ __('recruitment.career_portal.actions.search_jobs') }}</button>
                    </div>
                </div>
            </form>
        </div>
    </section>

    @if ($featured->isNotEmpty())
        <section class="cp-section cp-section-alt">
            <div class="container">
                <h2 class="cp-section-title">{{ __('recruitment.career_portal.featured') }}</h2>
                <p class="cp-section-lead">{{ __('recruitment.career_portal.featured_lead') }}</p>
                <div class="row g-3">
                    @foreach ($featured as $job)
                        <div class="col-md-6 col-lg-4">
                            @include('pages.careers._job-card', ['job' => $job, 'tenant' => $tenant])
                        </div>
                    @endforeach
                </div>
            </div>
        </section>
    @endif

    <section class="cp-section">
        <div class="container">
            <div class="d-flex flex-wrap justify-content-between align-items-end gap-2 mb-3">
                <div>
                    <h2 class="cp-section-title mb-1">{{ __('recruitment.career_portal.latest') }}</h2>
                    <p class="cp-muted mb-0">{{ __('recruitment.career_portal.latest_lead') }}</p>
                </div>
                <a class="cp-link" href="{{ route('careers.jobs', ['tenant' => $tenant->slug]) }}">{{ __('recruitment.career_portal.actions.view_all') }}</a>
            </div>
            <div class="row g-3">
                @forelse ($jobs as $job)
                    <div class="col-md-6">
                        @include('pages.careers._job-card', ['job' => $job, 'tenant' => $tenant])
                    </div>
                @empty
                    <div class="col-12"><p class="cp-muted">{{ __('recruitment.career_portal.empty_jobs') }}</p></div>
                @endforelse
            </div>
        </div>
    </section>

    <section class="cp-section cp-section-alt">
        <div class="container">
            <h2 class="cp-section-title text-center">{{ __('recruitment.career_portal.benefits_title') }}</h2>
            <p class="cp-section-lead text-center mx-auto">{{ __('recruitment.career_portal.benefits_lead') }}</p>
            <div class="row g-3">
                @foreach ($benefits as $benefit)
                    <div class="col-6 col-md-3">
                        <div class="cp-card cp-benefit">
                            <div class="cp-benefit-icon"><i class="{{ $benefit['icon'] }}"></i></div>
                            <h3 class="h6 mb-1">{{ __('recruitment.career_portal.benefits.'.$benefit['key'].'.title') }}</h3>
                            <p class="small cp-muted mb-0">{{ __('recruitment.career_portal.benefits.'.$benefit['key'].'.body') }}</p>
                        </div>
                    </div>
                @endforeach
            </div>
        </div>
    </section>

    <section class="cp-section">
        <div class="container">
            <div class="cp-cta d-flex flex-wrap justify-content-between align-items-center gap-3">
                <div>
                    <h2 class="h4 mb-1 text-white">{{ __('recruitment.career_portal.cta_title') }}</h2>
                    <p class="mb-0 opacity-75">{{ __('recruitment.career_portal.cta_lead') }}</p>
                </div>
                <a class="cp-btn" href="{{ route('careers.jobs', ['tenant' => $tenant->slug]) }}">{{ __('recruitment.career_portal.actions.browse_jobs') }}</a>
            </div>
        </div>
    </section>
</x-ui.layout.career-portal>
