@extends('layouts.site')

@section('title', optional($page)->meta_title ?: 'Careers — join our agency team')
@section('meta_description', optional($page)->meta_description ?? 'Career opportunities at Hillcrest Living.')

@section('content')
    @php
        $heroVisual = null;
        foreach ([
            'assets/images/how-it-works-hero.png',
            'assets/images/hillcrest-hero-ai-2.png',
            'assets/images/hillcrest-community-photo.png',
            'assets/hillcrest-hero-photo-2.png',
        ] as $candidate) {
            if (file_exists(public_path($candidate))) {
                $heroVisual = asset($candidate);
                break;
            }
        }
    @endphp
    <div class="section-gap section-contrast-sage">
        <div class="section-shell">
            <header class="relative overflow-hidden rounded-3xl border border-[var(--color-accent)]/25 bg-gradient-to-br from-white via-[var(--color-surface)] to-[var(--color-surface-alt)] p-6 shadow-sm md:p-8" data-aos="fade-up">
                <div class="pointer-events-none absolute -right-20 -top-20 h-52 w-52 rounded-full bg-[var(--color-accent)]/10 blur-3xl"></div>
                <div class="pointer-events-none absolute -bottom-20 left-20 h-52 w-52 rounded-full bg-[var(--color-primary)]/10 blur-3xl"></div>
                <div class="grid gap-6 lg:grid-cols-[1.1fr_0.9fr] lg:items-center">
                    <div>
                        <p class="inline-flex items-center gap-2 text-xs font-semibold uppercase tracking-[0.2em] text-[var(--color-accent)]">
                            <i data-lucide="briefcase-business" class="h-3.5 w-3.5"></i>
                            Careers & Recruitment
                        </p>
                        <h1 class="mt-3 max-w-4xl font-display text-4xl font-bold text-[var(--color-heading)] md:text-5xl" style="font-family: var(--font-heading);">
                            Join the agency arm powering high-quality care and support talent
                        </h1>
                        <p class="mt-4 max-w-3xl text-neutral-700">
                            Hillcrest Living is building a trusted workforce of skilled carers, support workers, and care professionals who are committed to dignity, safeguarding, and person-centred outcomes.
                            If you are values-led and ready to make a real impact, we want to hear from you.
                        </p>
                    </div>
                    @if($heroVisual)
                        <div class="relative overflow-hidden rounded-2xl border border-[var(--color-primary)]/20 bg-[var(--color-surface-alt)] shadow-sm">
                            <img src="{{ $heroVisual }}" alt="Hillcrest recruitment and care team" class="h-full min-h-[240px] w-full object-cover">
                            <div class="pointer-events-none absolute inset-0 bg-gradient-to-t from-[var(--color-primary)]/80 via-[var(--color-primary)]/35 to-transparent"></div>
                            <div class="absolute bottom-0 left-0 right-0 p-4">
                                <p class="inline-flex items-center gap-2 text-sm font-semibold text-white">
                                    <i data-lucide="shield-check" class="h-4 w-4"></i>
                                    Building a trusted workforce for person-centred care
                                </p>
                            </div>
                        </div>
                    @else
                        <div class="relative flex min-h-[240px] items-end overflow-hidden rounded-2xl border border-[var(--color-primary)]/20 bg-gradient-to-br from-[var(--color-primary)] to-[var(--color-heading)] p-4 shadow-sm">
                            <p class="inline-flex items-center gap-2 text-sm font-semibold text-white">
                                <i data-lucide="shield-check" class="h-4 w-4"></i>
                                Building a trusted workforce for person-centred care
                            </p>
                        </div>
                    @endif
                </div>
                <div class="mt-6 grid gap-3 sm:grid-cols-3">
                    <div class="rounded-xl border border-[var(--color-primary)]/15 bg-white px-4 py-3">
                        <p class="inline-flex items-center gap-1.5 text-xs uppercase tracking-wide text-neutral-500"><i data-lucide="clipboard-list" class="h-3.5 w-3.5 text-[var(--color-accent)]"></i>Open roles</p>
                        <p class="mt-1 text-xl font-semibold text-[var(--color-heading)]">{{ $jobs->count() }}</p>
                    </div>
                    <div class="rounded-xl border border-[var(--color-primary)]/15 bg-white px-4 py-3">
                        <p class="inline-flex items-center gap-1.5 text-xs uppercase tracking-wide text-neutral-500"><i data-lucide="users" class="h-3.5 w-3.5 text-[var(--color-accent)]"></i>Recruitment focus</p>
                        <p class="mt-1 text-sm font-semibold text-[var(--color-heading)]">Care, support & compliance</p>
                    </div>
                    <div class="rounded-xl border border-[var(--color-primary)]/15 bg-white px-4 py-3">
                        <p class="inline-flex items-center gap-1.5 text-xs uppercase tracking-wide text-neutral-500"><i data-lucide="send" class="h-3.5 w-3.5 text-[var(--color-accent)]"></i>Application route</p>
                        <p class="mt-1 text-sm font-semibold text-[var(--color-heading)]">Role-specific secure form</p>
                    </div>
                </div>
            </header>

            <section class="mt-8 grid gap-4 md:grid-cols-3" data-aos="fade-up">
                <article class="rounded-2xl border border-[var(--color-primary)]/15 bg-white p-5 shadow-sm">
                    <img src="{{ asset('assets/images/hillcrest-community-photo.png') }}" alt="Care professional supporting a resident" class="mb-3 h-28 w-full rounded-lg object-cover">
                    <h2 class="inline-flex items-center gap-2 font-display text-lg font-semibold text-[var(--color-heading)]" style="font-family: var(--font-heading);"><i data-lucide="heart-handshake" class="h-4 w-4 text-[var(--color-accent)]"></i>Why we need you</h2>
                    <p class="mt-2 text-sm leading-relaxed text-neutral-700">Demand for reliable care professionals is growing. We need people who can deliver consistent, respectful support and protect independence.</p>
                </article>
                <article class="rounded-2xl border border-[var(--color-primary)]/15 bg-white p-5 shadow-sm">
                    <img src="{{ asset('assets/images/faq-support-conversation.png') }}" alt="Professional support and communication in care setting" class="mb-3 h-28 w-full rounded-lg object-cover">
                    <h2 class="inline-flex items-center gap-2 font-display text-lg font-semibold text-[var(--color-heading)]" style="font-family: var(--font-heading);"><i data-lucide="badge-check" class="h-4 w-4 text-[var(--color-accent)]"></i>What you bring</h2>
                    <p class="mt-2 text-sm leading-relaxed text-neutral-700">Compassion, practical skill, safeguarding awareness, and a professional attitude that helps residents and families feel confident.</p>
                </article>
                <article class="rounded-2xl border border-[var(--color-primary)]/15 bg-white p-5 shadow-sm">
                    <img src="{{ asset('assets/images/hillcrest-about-story.png') }}" alt="Support team in a calm and professional environment" class="mb-3 h-28 w-full rounded-lg object-cover">
                    <h2 class="inline-flex items-center gap-2 font-display text-lg font-semibold text-[var(--color-heading)]" style="font-family: var(--font-heading);"><i data-lucide="sparkles" class="h-4 w-4 text-[var(--color-accent)]"></i>What we offer</h2>
                    <p class="mt-2 text-sm leading-relaxed text-neutral-700">Structured onboarding, supportive leadership, clear standards, and meaningful opportunities to grow within care recruitment and delivery.</p>
                </article>
            </section>

            <section class="mt-10" aria-label="Open roles" data-aos="fade-up">
                <div class="mb-4 flex items-center justify-between gap-3">
                    <h2 class="font-display text-2xl font-semibold text-[var(--color-heading)]" style="font-family: var(--font-heading);">Current opportunities</h2>
                    <span class="rounded-full bg-[var(--color-accent)]/15 px-3 py-1 text-xs font-semibold text-[var(--color-heading)]">{{ $jobs->count() }} live</span>
                </div>

                <div class="space-y-4">
                    @forelse($jobs as $job)
                        <article class="group rounded-2xl border border-[var(--color-primary)]/15 bg-white p-5 shadow-sm transition hover:-translate-y-0.5 hover:border-[var(--color-accent)]/60 hover:shadow-md md:p-6">
                            <div class="flex flex-col gap-4 md:flex-row md:items-center md:justify-between">
                                <div>
                                    <h3 class="font-display text-xl font-semibold text-[var(--color-heading)]" style="font-family: var(--font-heading);">{{ $job->title }}</h3>
                                    <p class="mt-2 text-sm text-neutral-600">
                                        @if($job->department)
                                            {{ $job->department }}
                                        @endif
                                        @if($job->location)
                                            @if($job->department)<span aria-hidden="true"> · </span>@endif {{ $job->location }}
                                        @endif
                                        <span aria-hidden="true"> · </span>{{ str_replace('_', ' ', ucfirst($job->employment_type)) }}
                                    </p>
                                    <div class="mt-3 flex flex-wrap gap-2 text-xs">
                                        <span class="inline-flex items-center gap-1 rounded-full bg-neutral-100 px-2.5 py-1 font-medium text-neutral-700"><i data-lucide="clock-3" class="h-3.5 w-3.5 text-[var(--color-accent)]"></i>{{ str_replace('_', ' ', ucfirst($job->employment_type)) }}</span>
                                        @if($job->closing_date)
                                            <span class="inline-flex items-center gap-1 rounded-full bg-neutral-100 px-2.5 py-1 font-medium text-neutral-700"><i data-lucide="calendar-days" class="h-3.5 w-3.5 text-[var(--color-accent)]"></i>Closing {{ $job->closing_date->format('j M Y') }}</span>
                                        @else
                                            <span class="inline-flex items-center gap-1 rounded-full bg-neutral-100 px-2.5 py-1 font-medium text-neutral-700"><i data-lucide="check-circle-2" class="h-3.5 w-3.5 text-emerald-600"></i>Applications open</span>
                                        @endif
                                    </div>
                                </div>
                                <div class="md:mt-0">
                                    <a class="inline-flex min-h-[44px] items-center gap-2 rounded-md bg-[var(--color-primary)] px-4 py-2 text-sm font-semibold text-white transition hover:opacity-90" href="{{ route('careers.show', $job) }}"><i data-lucide="arrow-right-circle" class="h-4 w-4"></i>View role & apply</a>
                                </div>
                            </div>
                        </article>
                    @empty
                        <p class="rounded-xl border border-neutral-200 bg-white p-5 text-neutral-700">There are no open vacancies at present. Please check back soon.</p>
                    @endforelse
                </div>
            </section>
        </div>
    </div>
@endsection
