<section>
    <header>
        <h2 class="text-lg font-medium text-slate-900 dark:text-white">
            {{ __('Profile Information') }}
        </h2>

        <p class="mt-1 text-sm text-slate-600 dark:text-slate-300">
            {{ __("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="__('Name')" />
            <x-text-input id="name" name="name" type="text" class="mt-1 block w-full" :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="__('Email')" />
            <x-text-input id="email" name="email" type="email" class="mt-1 block w-full" :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-gray-800">
                        {{ __('Your email address is unverified.') }}

                        <button form="send-verification" class="underline text-sm text-gray-600 hover:text-gray-900 rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
                            {{ __('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">
                            {{ __('A new verification link has been sent to your email address.') }}
                        </p>
                    @endif
                </div>
            @endif
        </div>

        @if ($publicProfileSettings->public_profiles_enabled)
        <div class="rounded-lg border border-blue-100 bg-blue-50/60 p-4 dark:border-blue-900/50 dark:bg-blue-950/20">
            <h3 class="text-sm font-bold uppercase tracking-wide text-blue-700 dark:text-blue-300">Public Trader Profile</h3>
            <p class="mt-1 text-sm text-slate-600 dark:text-slate-300">Choose a public username if you want a shareable profile like yourdomain.com/yourname.</p>

            <div class="mt-4">
                <x-input-label for="public_username" value="Public Username" />
                <x-text-input id="public_username" name="public_username" type="text" class="mt-1 block w-full" :value="old('public_username', $user->public_username)" placeholder="nasirvisualfx" />
                <x-input-error class="mt-2" :messages="$errors->get('public_username')" />
            </div>

            <div class="mt-4 grid gap-3 sm:grid-cols-2">
                <label class="flex items-center gap-3 text-sm font-semibold text-slate-700 dark:text-slate-200">
                    <input type="checkbox" name="public_profile_enabled" value="1" @checked(old('public_profile_enabled', $user->public_profile_enabled)) class="rounded border-gray-300 text-blue-600 shadow-sm focus:ring-blue-500">
                    Enable public profile
                </label>
                @if ($publicProfileSettings->allow_profit_visibility)
                    <label class="flex items-center gap-3 text-sm font-semibold text-slate-700 dark:text-slate-200">
                        <input type="checkbox" name="show_public_profit" value="1" @checked(old('show_public_profit', $user->show_public_profit)) class="rounded border-gray-300 text-blue-600 shadow-sm focus:ring-blue-500">
                        Show profit on public profile
                    </label>
                @endif
            </div>

            @if ($user->public_username)
                <a href="{{ route('public-profile.show', $user->public_username) }}" class="mt-4 inline-flex text-sm font-bold text-blue-700 dark:text-blue-300">View public profile</a>
            @endif
        </div>
        @endif

        <div class="flex items-center gap-4">
            <x-primary-button>{{ __('Save') }}</x-primary-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-600"
                >{{ __('Saved.') }}</p>
            @endif
        </div>
    </form>
</section>
