<!doctype html>
<html lang="es">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Login Cliente</title>
    @vite(['resources/css/app.css', 'resources/js/app.js'])
</head>
<body class="bg-light">
    <main class="container py-5">
        <div class="row justify-content-center">
            <div class="col-12 col-sm-10 col-md-8 col-lg-5">
                <div class="card shadow-sm border-0">
                    <div class="card-body p-4 p-md-5">
                        <h1 class="h4 mb-1 text-center">Login de Cliente</h1>

                        <div class="alert alert-info" role="alert">
                            Para iniciar sesión, primero debes ser cliente del estudio jurídico.
                        </div>

                        @if (session('login_error'))
                            <div class="alert alert-danger" role="alert">
                                {{ session('login_error') }}
                            </div>
                        @endif

                        @if (session('login_success'))
                            <div class="alert alert-success" role="alert">
                                {{ session('login_success') }}
                            </div>
                        @endif

                        @if($errors->any())
                            <div class="alert alert-danger" role="alert">
                                <ul class="mb-0 ps-3">
                                    @foreach($errors->all() as $error)
                                        <li>{{ $error }}</li>
                                    @endforeach
                                </ul>
                            </div>
                        @endif

                        <div class="alert alert-warning py-2" role="alert">
                            <strong>Intentos restantes:</strong> {{ $intentosRestantes ?? 5 }} de {{ $intentosMaximos ?? 5 }}
                        </div>

                        <form method="POST" action="/login/cliente" class="d-grid gap-3">
                            @csrf
                            <div>
                                <label class="form-label" for="correo">Correo</label>
                                <input class="form-control" id="correo" name="correo" type="email" value="{{ old('correo') }}" required>
                            </div>

                            <div>
                                <label class="form-label" for="contra">Contraseña</label>
                                <input class="form-control" id="contra" name="contra" type="password" required>
                            </div>

                            <div style="position:absolute; left:-9999px; width:1px; height:1px; overflow:hidden;" aria-hidden="true">
                                <label class="form-label" for="website">No completar este campo</label>
                                <input class="form-control" id="website" name="website" type="text" value="{{ old('website') }}" tabindex="-1" autocomplete="off">
                            </div>

                            <button class="btn btn-primary" type="submit">Ingresar</button>
                        </form>

                        <div class="text-center mt-3">
                            <a href="/cliente/recuperar-credenciales" class="small text-muted">¿Olvidó sus credenciales?</a>
                        </div>

                        <hr class="my-4">
                        <div class="d-grid">
                            <a href="/" class="btn btn-outline-secondary">Volver al inicio</a>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </main>
    @include('partials.reportar-falla-boton')
</body>
</html>
