@php
    $breadcrumbs = [
        ['label' => __('common.home'), 'url' => route('dashboard.index')],
        ['label' => __('me.profile_title')],
    ];
    $parts = preg_split('/\s+/', trim((string) $employee->full_name));
    $initials = collect($parts)
        ->filter()
        ->take(2)
        ->map(fn ($p) => strtoupper(mb_substr((string) $p, 0, 1)))
        ->implode('');
    if ($initials === '') {
        $initials = '?';
    }
@endphp

<x-ui.layout.page
    :title="__('me.profile_title')"
    :subtitle="__('me.profile_subtitle')"
    page-icon="fe fe-user"
    :breadcrumbs="$breadcrumbs"
>
    <div class="row g-4">
        <div class="col-lg-4">
            <div class="card border-0 shadow-sm h-100">
                <div class="card-body text-center">
                    <div
                        class="avatar avatar-xl rounded-circle d-inline-flex align-items-center justify-content-center mx-auto mb-3 fs-2 fw-semibold text-white"
                        style="width: 5rem; height: 5rem; background: {{ config('theme.gradients.primary') }};"
                        aria-label="{{ __('me.profile.initials_avatar') }}"
                    >
                        {{ $initials }}
                    </div>
                    <div class="text-muted small">{{ __('me.profile.no_photo') }}</div>
                    <h2 class="h5 mt-3 mb-0" style="color: {{ config('theme.colors.text') }};">{{ $employee->full_name }}</h2>
                </div>
            </div>
        </div>
        <div class="col-lg-8">
            <div class="card border-0 shadow-sm">
                <div class="card-body">
                    <dl class="row mb-0">
                        <dt class="col-sm-4 text-muted small">{{ __('employees.fields.department') }}</dt>
                        <dd class="col-sm-8">{{ $employee->department?->name ?? '—' }}</dd>

                        <dt class="col-sm-4 text-muted small">{{ __('employees.fields.position') }}</dt>
                        <dd class="col-sm-8">{{ $employee->position?->name ?? '—' }}</dd>

                        <dt class="col-sm-4 text-muted small">{{ __('employees.fields.phone_1') }}</dt>
                        <dd class="col-sm-8">{{ $employee->phone_1 ?? '—' }}</dd>

                        <dt class="col-sm-4 text-muted small">{{ __('employees.fields.phone_2') }}</dt>
                        <dd class="col-sm-8">{{ $employee->phone_2 ?? '—' }}</dd>

                        <dt class="col-sm-4 text-muted small">{{ __('employees.fields.email') }}</dt>
                        <dd class="col-sm-8">{{ $employee->email ?? '—' }}</dd>

                        <dt class="col-sm-4 text-muted small">{{ __('employees.fields.nationality') }}</dt>
                        <dd class="col-sm-8">{{ $employee->nationality ?? '—' }}</dd>

                        <dt class="col-sm-4 text-muted small">{{ __('employees.fields.hire_date') }}</dt>
                        <dd class="col-sm-8">{{ $employee->hire_date?->format('Y-m-d') ?? '—' }}</dd>

                        @if ($show_salary)
                            <dt class="col-sm-4 text-muted small">{{ __('me.profile.salary') }}</dt>
                            <dd class="col-sm-8">{{ number_format((float) $employee->salary, 2) }}</dd>
                        @endif
                    </dl>
                </div>
            </div>
        </div>
    </div>
</x-ui.layout.page>
