@extends('layouts.login')

@section('content')
<div class="container py-5">
    <div class="row justify-content-center">
        <div class="col-12 col-md-6">
            <img src="{{ asset('img/logo.png') }}" alt="Unioil Logo" class="img-fluid d-block mx-auto" style="max-width: 150px;">

            <div class="mb-3 text-center">
                <h4 class="mb-1 fw-bold">Welcome</h4>
                <span style="font-size: 14px;" class="text-muted">Sign in to continue</span>
            </div>

            <!-- Error/Success Messages -->
            @if ($errors->any())
                <div class="alert alert-danger">
                    @foreach ($errors->all() as $error)
                        {{ $error }}<br>
                    @endforeach
                </div>
            @endif
            @if (session('success'))
                <div class="alert alert-success">
                    {{ session('success') }}
                </div>
            @endif
            @if (session('error'))
                <div class="alert alert-danger">
                    {{ session('error') }}
                </div>
            @endif
            @if (session('prompt_password'))
                <div class="alert alert-warning">
                    You must change your password. <a href="{{ route('change.password.form') }}">Change Password</a>
                </div>
            @endif

            <form method="POST" action="{{ route('login') }}">
                @csrf
                <div class="mb-3">
                    <label for="username" class="form-label fw-semibold" style="font-size: 13px; color: #003366;">Enter Username</label>
                    <input type="text" class="form-control" id="username" name="username" placeholder="superadmin" value="{{ old('username') }}" required>
                    @error('username')
                        <div style="color: red; font-size: 0.875em;">{{ $message }}</div>
                    @enderror
                </div>
                <div class="mb-3">
                    <label for="password" class="form-label fw-semibold" style="font-size: 13px; color: #003366;">Enter Password</label>
                    <input type="password" class="form-control" id="password" name="password" placeholder="••••••••" required>
                    @error('password')
                        <div style="color: red; font-size: 0.875em;">{{ $message }}</div>
                    @enderror
                </div>
                <div class="row mt-4">
                    <div class="col-6">
                        <a href="#" class="text-decoration-none text-primary" data-bs-toggle="modal" data-bs-target="#forgotPasswordModal">Forgot Username</a>
                    </div>
                    <div class="col-6 text-end">
                        <button type="submit" class="btn btn-primary w-100" style="background-color: #E74610; border-color: #E74610;">Login</button>
                    </div>
                </div>
            </form>

            <!-- Forgot Password Modal -->
            <div class="modal fade" id="forgotPasswordModal" tabindex="-1" aria-labelledby="forgotPasswordModalLabel" aria-hidden="true">
                <div class="modal-dialog modal-dialog-centered" style="max-width: 337px;">
                    <div class="modal-content">
                        <div class="modal-body">
                            <h4>Forgot Password</h4>
                            <p>
                                To have your password reset, please contact <br>
                                Unioil's admin at <a href="mailto:admin@unioil.com" class="text-primary">admin@unioil.com</a>
                            </p>
                        </div>
                        <div class="modal-footer justify-content-end">
                            <button class="btn btn-primary" data-bs-dismiss="modal" style="background-color: #E74610; border-color: #E74610; width: 64px;">Ok</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- Include Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
@endsection