@extends('layouts.app') {{-- Asume que tu layout principal es layouts.app --}}

@section('title', 'Iniciar Sesión')

@section('content')
<div class="container py-4">
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card bg-dark text-white shadow-lg border-0">
                <div class="card-header bg-secondary text-center rounded-top">
                    <h3 class="mb-0 text-white"><i class="bi bi-person-circle me-2"></i> Inicio de Sesión</h3>
                </div>
                <div class="card-body p-4">
                    <form method="POST" action="{{ route('custom.login') }}">
                        @csrf

                        {{-- Mensajes de éxito o error globales --}}
                        @if (session('status'))
                            <div class="alert alert-success alert-dismissible fade show" role="alert">
                                {{ session('status') }}
                                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                            </div>
                        @endif

                        @if (session('error'))
                            <div class="alert alert-danger alert-dismissible fade show" role="alert">
                                {{ session('error') }}
                                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                            </div>
                        @endif

                        <div class="mb-3">
                            <label for="alias_or_email" class="form-label text-white">Alias o Correo Electrónico</label>
                            <div class="input-group">
                                <span class="input-group-text bg-secondary border-secondary text-white"><i class="bi bi-person"></i></span>
                                <input type="text" class="form-control bg-secondary border-secondary text-white @error('alias_or_email') is-invalid @enderror" 
                                       id="alias_or_email" name="alias_or_email" value="{{ old('alias_or_email') }}" required autofocus>
                                @error('alias_or_email')
                                    <div class="invalid-feedback">
                                        {{ $message }}
                                    </div>
                                @enderror
                            </div>
                        </div>

                        <div class="mb-4">
                            <label for="password" class="form-label text-white">Contraseña</label>
                            <div class="input-group">
                                <span class="input-group-text bg-secondary border-secondary text-white"><i class="bi bi-key"></i></span>
                                <input type="password" class="form-control bg-secondary border-secondary text-white @error('password') is-invalid @enderror" 
                                       id="password" name="password" required>
                                @error('password')
                                    <div class="invalid-feedback">
                                        {{ $message }}
                                    </div>
                                @enderror
                            </div>
                        </div>

                        <div class="d-grid gap-2">
                            <button type="submit" class="btn btn-primary btn-lg rounded-pill">
                                <i class="bi bi-box-arrow-in-right me-2"></i> Ingresar
                            </button>
                            {{-- Si quieres un enlace a registro o "olvidé mi contraseña" --}}
                            {{-- <a href="#" class="btn btn-link text-white-50">¿Olvidaste tu contraseña?</a> --}}
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection
