@php
    /** @var \App\Models\Dealer $dealer */
    $loginAccent = $dealer->loginEffectiveAccentColor();
@endphp

<x-guest-layout :dealer="$dealer">
    <div class="mb-6 flex justify-center">
        <img
            src="{{ $dealer->loginLogoUrl() }}"
            alt="{{ $dealer->name }}"
            class="h-20 w-auto object-contain"
        />
    </div>

    <!-- Session Status -->
    <x-auth-session-status class="mb-4 text-sm text-gray-700" :status="session('status')" />

    <form method="POST" action="{{ route('dealer.login.store', $dealer->code) }}" class="space-y-4">
        @csrf

        <!-- Email Address -->
        <div>
            <x-input-label for="email" :value="__('Email')" class="text-gray-700" />
            <x-text-input
                id="email"
                class="block mt-1 w-full rounded-md focus:ring-[var(--dealer-accent-color)] focus:border-[var(--dealer-accent-color)]"
                type="email"
                name="email"
                :value="old('email')"
                required
                autofocus
                autocomplete="username"
            />
            <x-input-error :messages="$errors->get('email')" class="mt-2" />
        </div>

        <!-- Password -->
        <div>
            <x-input-label for="password" :value="__('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
                autocomplete="current-password"
            />

            <x-input-error :messages="$errors->get('password')" class="mt-2" />
        </div>

        <!-- Remember Me -->
        <div class="block">
            <label for="remember_me" class="inline-flex items-center">
                <input id="remember_me" type="checkbox" class="rounded border-gray-300 text-[var(--dealer-accent-color)] shadow-sm focus:ring-[var(--dealer-accent-color)]" name="remember">
                <span class="ms-2 text-sm text-gray-600">{{ __('Remember me') }}</span>
            </label>
        </div>

        <div class="flex items-center justify-between pt-2">
            @if (Route::has('dealer.password.request'))
                <a 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-[var(--dealer-accent-color)]" href="{{ route('dealer.password.request', ['code' => $dealer->code]) }}">
                    {{ __('Forgot your password?') }}
                </a>
            @endif

            <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 }};
                "
            >
                {{ __('Log in') }}
            </button>
        </div>
    </form>
</x-guest-layout>

