@php
    /** @var \App\Models\Dealer|null $dealer */
    $loginAccent = isset($dealer) ? $dealer->loginEffectiveAccentColor() : 'var(--dealer-accent-color)';
@endphp

<x-guest-layout :dealer="$dealer">
    <div class="mb-6 flex justify-center">
        <img
            src="{{ isset($dealer) ? $dealer->loginLogoUrl() : asset('images/mega-theron-logo.png') }}"
            alt="{{ isset($dealer) ? ($dealer->name ?? 'Dealer') : 'Mega Theron Group' }}"
            class="h-20 w-auto object-contain"
        />
    </div>

    <h2 class="mb-2 text-center text-lg font-semibold text-gray-800">Set Your New Password</h2>
    <p class="mb-6 text-center text-sm text-gray-600">You must set a new password before you can sign in.</p>

    <x-auth-session-status class="mb-4 text-sm text-gray-700" :status="session('status')" />
    <x-input-error :messages="$errors->get('password')" class="mb-4" />

    <form method="POST" action="{{ route('first-login.password.update', $token) }}" class="space-y-4">
        @csrf

        <div>
            <x-input-label for="password" :value="__('New password')" class="text-gray-700" />
            <x-text-input
                id="password"
                class="block mt-1 w-full rounded-md focus:ring-[var(--dealer-accent-color)] focus:border-[var(--dealer-accent-color)]"
                type="password"
                name="password"
                required
                autofocus
                autocomplete="new-password"
            />
            @if(!empty($passwordHint))
                <p class="mt-1 text-xs text-gray-500">{{ $passwordHint }}</p>
            @endif
        </div>

        <div>
            <x-input-label for="password_confirmation" :value="__('Confirm password')" class="text-gray-700" />
            <x-text-input
                id="password_confirmation"
                class="block mt-1 w-full rounded-md focus:ring-[var(--dealer-accent-color)] focus:border-[var(--dealer-accent-color)]"
                type="password"
                name="password_confirmation"
                required
                autocomplete="new-password"
            />
        </div>

        <div class="flex items-center justify-between pt-2">
            <a
                href="{{ $loginUrl ?? route('login') }}"
                class="text-sm text-gray-600 hover:text-gray-900 rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-[var(--dealer-accent-color)]"
            >
                Back to login
            </a>
            <button
                type="submit"
                class="inline-flex items-center px-4 py-2 rounded-md text-sm font-semibold text-white shadow-sm focus:outline-none focus:ring-2 focus:ring-offset-2"
                style="
                    background-color: {{ $loginAccent }};
                    border-color: {{ $loginAccent }};
                    --tw-ring-color: {{ $loginAccent }};
                "
            >
                {{ __('Save Password') }}
            </button>
        </div>
    </form>
</x-guest-layout>
