<!doctype html>
<html lang="es">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Recuperar credenciales personal</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">Recuperar credenciales</h1>
                        <p class="text-muted text-center small mb-4">Ingresá los datos con los que estás registrado en el sistema para recibir el enlace de recuperación.</p>

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

                        @if(session('recuperar_error'))
                            <div class="alert alert-danger" role="alert">
                                {{ session('recuperar_error') }}
                            </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="/personal/recuperar-credenciales" class="d-grid gap-3">
                            @csrf
                            <div>
                                <label class="form-label" for="dni">DNI</label>
                                <input class="form-control" id="dni" name="dni" type="text" value="{{ old('dni') }}" required autofocus>
                            </div>
                            <div>
                                <label class="form-label" for="matricula">Matrícula</label>
                                <input class="form-control" id="matricula" name="matricula" type="text" value="{{ old('matricula') }}" required>
                            </div>
                            <div>
                                <label class="form-label" for="profesion_id">Profesión</label>
                                <select class="form-select" id="profesion_id" name="profesion_id" required>
                                    <option value="">Seleccionar profesión</option>
                                    @foreach(($profesiones ?? []) as $profesion)
                                        <option value="{{ $profesion->id }}" @selected((string) old('profesion_id') === (string) $profesion->id)>{{ $profesion->titulo }}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div>
                                <label class="form-label" for="correo">Correo electrónico</label>
                                <input class="form-control" id="correo" name="correo" type="email" value="{{ old('correo') }}" 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">Enviar enlace</button>
                        </form>

                        <hr class="my-4">
                        <div class="d-grid">
                            <a href="/login/personal" class="btn btn-outline-secondary">Volver al login</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </main>
</body>
</html>
