@php
    $breadcrumbs = [
        ['label' => __('common.home'), 'url' => route('dashboard.index')],
        ['label' => __('common.hr')],
        ['label' => __('recruitment.career_portal.admin_title')],
    ];
@endphp

<x-ui.layout.page
    :title="__('recruitment.career_portal.admin_title')"
    :subtitle="__('recruitment.career_portal.admin_subtitle')"
    page-icon="fe fe-globe"
    :breadcrumbs="$breadcrumbs"
>
    <div class="card border-0 shadow-sm mb-4">
        <div class="card-body">
            <h6 class="mb-3">{{ __('recruitment.career_portal.company_section') }}</h6>
            <div class="row g-3">
                <div class="col-md-4">
                    <div class="text-muted small">{{ __('recruitment.career_portal.fields.company_name') }}</div>
                    <div class="fw-semibold">{{ $tenant->name }}</div>
                </div>
                <div class="col-md-4">
                    <div class="text-muted small">{{ __('recruitment.career_portal.fields.company_slug') }}</div>
                    <div><code>{{ $tenant->slug }}</code></div>
                </div>
                <div class="col-md-12">
                    <div class="text-muted small mb-1">{{ __('recruitment.career_portal.public_url') }}</div>
                    <div class="d-flex flex-wrap align-items-center gap-2">
                        <a href="{{ $publicUrl }}" target="_blank" rel="noopener" class="text-break">{{ $publicUrl }}</a>
                        <x-ui.buttons.secondary
                            size="sm"
                            :href="$publicUrl"
                            target="_blank"
                            icon="fe fe-external-link"
                        >
                            {{ __('recruitment.career_portal.actions.open_portal') }}
                        </x-ui.buttons.secondary>
                    </div>
                    @unless ($settings->is_enabled)
                        <div class="text-warning small mt-2 mb-0">
                            {{ __('recruitment.career_portal.disabled_hint') }}
                        </div>
                    @endunless
                </div>
            </div>
        </div>
    </div>

    <form method="POST" action="{{ route('hr.recruitment.career-portal.settings') }}" class="card border-0 shadow-sm">
        @csrf
        @method('PUT')
        <div class="card-body">
            <div class="row g-3">
                <div class="col-md-4">
                    <input type="hidden" name="is_enabled" value="0">
                    <label class="form-check">
                        <input type="checkbox" name="is_enabled" value="1" class="form-check-input" @checked(old('is_enabled', $settings->is_enabled))>
                        <span class="form-check-label">{{ __('recruitment.career_portal.fields.is_enabled') }}</span>
                    </label>
                </div>
                <div class="col-md-4">
                    <input type="hidden" name="recaptcha_enabled" value="0">
                    <label class="form-check">
                        <input type="checkbox" name="recaptcha_enabled" value="1" class="form-check-input" @checked(old('recaptcha_enabled', $settings->recaptcha_enabled))>
                        <span class="form-check-label">{{ __('recruitment.career_portal.fields.recaptcha_enabled') }}</span>
                    </label>
                </div>
                <div class="col-md-6">
                    <label class="form-label">{{ __('recruitment.career_portal.fields.portal_title') }}</label>
                    <input name="portal_title" class="form-control" value="{{ old('portal_title', $settings->portal_title) }}">
                </div>
                <div class="col-md-6">
                    <label class="form-label">{{ __('recruitment.career_portal.fields.portal_subtitle') }}</label>
                    <input name="portal_subtitle" class="form-control" value="{{ old('portal_subtitle', $settings->portal_subtitle) }}">
                </div>
                <div class="col-12">
                    <label class="form-label">{{ __('recruitment.career_portal.fields.about_text') }}</label>
                    <textarea name="about_text" rows="3" class="form-control">{{ old('about_text', $settings->about_text) }}</textarea>
                </div>
                <div class="col-md-6">
                    <label class="form-label">{{ __('recruitment.career_portal.fields.contact_email') }}</label>
                    <input type="email" name="contact_email" class="form-control" value="{{ old('contact_email', $settings->contact_email) }}">
                </div>
                <div class="col-md-6">
                    <label class="form-label">{{ __('recruitment.career_portal.fields.contact_phone') }}</label>
                    <input name="contact_phone" class="form-control" value="{{ old('contact_phone', $settings->contact_phone) }}">
                </div>
                <div class="col-md-4">
                    <label class="form-label">{{ __('recruitment.career_portal.fields.seo_title') }}</label>
                    <input name="seo_title" class="form-control" value="{{ old('seo_title', $settings->seo_title) }}">
                </div>
                <div class="col-md-4">
                    <label class="form-label">{{ __('recruitment.career_portal.fields.seo_description') }}</label>
                    <input name="seo_description" class="form-control" value="{{ old('seo_description', $settings->seo_description) }}">
                </div>
                <div class="col-md-4">
                    <label class="form-label">{{ __('recruitment.career_portal.fields.seo_keywords') }}</label>
                    <input name="seo_keywords" class="form-control" value="{{ old('seo_keywords', $settings->seo_keywords) }}">
                </div>
            </div>
        </div>
        <div class="card-footer bg-white text-end">
            <x-ui.buttons.primary type="submit">{{ __('common.save') }}</x-ui.buttons.primary>
        </div>
    </form>

    <div class="alert alert-secondary border-0 mt-4 mb-0">
        {{ __('recruitment.career_portal.vacancy_hint') }}
    </div>
</x-ui.layout.page>
