<section>
    <header>
        <h2 class="text-lg font-medium text-white">
            {{ app()->getLocale() == 'ar' ? 'معلومات الملف الشخصي' : 'Profile Information' }}
        </h2>

        <p class="mt-1 text-sm text-gray-400">
            {{ app()->getLocale() == 'ar' ? 'تحديث معلومات ملفك الشخصي وعنوان بريدك الإلكتروني.' : "Update your account's profile information and email address." }}
        </p>
    </header>

    <form id="send-verification" method="post" action="{{ route('verification.send') }}">
        @csrf
    </form>

    <form method="post" action="{{ route('profile.update') }}" class="mt-6 space-y-6">
        @csrf
        @method('patch')

        <div>
            <x-input-label for="name" :value="app()->getLocale() == 'ar' ? 'الاسم' : 'Name'" class="text-gray-400" />
            <x-text-input id="name" name="name" type="text" class="mt-1 block w-full bg-black border-gray-800 text-white focus:border-[#d4af37] focus:ring-[#d4af37]" :value="old('name', $user->name)" required autofocus autocomplete="name" />
            <x-input-error class="mt-2" :messages="$errors->get('name')" />
        </div>

        <div>
            <x-input-label for="email" :value="app()->getLocale() == 'ar' ? 'البريد الإلكتروني' : 'Email'" class="text-gray-400" />
            <x-text-input id="email" name="email" type="email" class="mt-1 block w-full bg-black border-gray-800 text-white focus:border-[#d4af37] focus:ring-[#d4af37]" :value="old('email', $user->email)" required autocomplete="username" />
            <x-input-error class="mt-2" :messages="$errors->get('email')" />

            @if ($user instanceof \Illuminate\Contracts\Auth\MustVerifyEmail && ! $user->hasVerifiedEmail())
                <div>
                    <p class="text-sm mt-2 text-white">
                        {{ app()->getLocale() == 'ar' ? 'عنوان بريدك الإلكتروني غير موثق.' : 'Your email address is unverified.' }}

                        <button form="send-verification" class="underline text-sm text-gray-400 hover:text-white rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-[#d4af37]">
                            {{ app()->getLocale() == 'ar' ? 'انقر هنا لإعادة إرسال بريد التحقق.' : 'Click here to re-send the verification email.' }}
                        </button>
                    </p>

                    @if (session('status') === 'verification-link-sent')
                        <p class="mt-2 font-medium text-sm text-green-600">
                            {{ app()->getLocale() == 'ar' ? 'تم إرسال رابط تحقق جديد إلى عنوان بريدك الإلكتروني.' : 'A new verification link has been sent to your email address.' }}
                        </p>
                    @endif
                </div>
            @endif
        </div>

        <div class="flex items-center gap-4">
            <button type="submit" class="bg-[#d4af37] text-black px-6 py-2 rounded font-bold hover:bg-[#b08d2a] transition-colors">
                {{ app()->getLocale() == 'ar' ? 'حفظ' : 'Save' }}
            </button>

            @if (session('status') === 'profile-updated')
                <p
                    x-data="{ show: true }"
                    x-show="show"
                    x-transition
                    x-init="setTimeout(() => show = false, 2000)"
                    class="text-sm text-gray-400"
                >{{ app()->getLocale() == 'ar' ? 'تم الحفظ.' : 'Saved.' }}</p>
            @endif
        </div>
    </form>
</section>
