<x-guest-layout>
    @php
        $loginError = $errors->first('email') ?: $errors->first('password');
    @endphp

    <div class="mb-7">
        <p class="text-xs font-bold uppercase tracking-[0.14em] text-brand-600">Acceso al workspace</p>
        <h2 class="mt-2 text-3xl font-bold text-ink-900 font-display">Bienvenido de nuevo</h2>
        <p class="mt-2 text-sm leading-6 text-ink-500">Ingresa para gestionar reservas, clientes, equipo y pagos desde un solo panel.</p>
    </div>

    <x-auth-session-status class="mt-6" :status="session('status')" />

    <form method="POST" action="{{ route('login') }}" class="space-y-5">
        @csrf

        <div>
            <label for="email" class="block text-sm font-semibold text-ink-800 mb-1.5">Correo electrónico</label>
            <input id="email" name="email" type="email" required autofocus autocomplete="username"
                   value="{{ old('email') }}"
                   class="input h-12 rounded-2xl"
                   placeholder="tu@empresa.com"
                   @if($loginError) aria-invalid="true" @endif>
        </div>

        <div>
            <div class="flex items-center justify-between mb-1">
                <label for="password" class="block text-sm font-semibold text-ink-800">Contraseña</label>
                @if (Route::has('password.request'))
                    <a class="text-xs font-semibold text-brand-600 hover:text-brand-700" href="{{ route('password.request') }}">¿Olvidaste tu contraseña?</a>
                @endif
            </div>
            <input id="password" name="password" type="password" required autocomplete="current-password" class="input h-12 rounded-2xl" @if($loginError) aria-invalid="true" @endif>
        </div>

        <label class="flex items-center gap-2 text-sm text-ink-600">
            <input type="checkbox" name="remember" class="rounded border-ink-300 text-brand-600 focus:ring-brand-500">
            <span>Recordarme en este dispositivo</span>
        </label>

        <button type="submit" class="btn btn-lg btn-primary w-full h-12">
            Ingresar
            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3"/></svg>
        </button>
    </form>

    <p class="mt-6 text-sm text-center text-ink-500">
        ¿No tienes cuenta?
        <a href="{{ route('pricing') }}" class="font-semibold text-brand-600 hover:text-brand-700">Elige un plan</a>
    </p>

    @if ($loginError)
        <script>
            window.addEventListener('load', () => {
                window.sileo?.error(@js($loginError), 'No pudimos iniciar sesión');
            });
        </script>
    @endif

</x-guest-layout>
