<!-- Path: app/Views/auth/forgot-password.view.php -->
<div class="bg-slate-50 min-h-[calc(100vh-64px)] flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
    <div class="max-w-md w-full bg-white rounded-xl shadow-lg border border-slate-200 overflow-hidden p-8">
        
        <div class="text-center mb-8">
            <h2 class="text-2xl font-bold text-navy-900">Reset Password</h2>
            <p class="text-slate-500 text-sm mt-2">Enter your email address and we'll send you a link to reset your password.</p>
        </div>

        <form id="forgotPasswordForm" class="space-y-6">
            <div>
                <label for="email" class="block text-sm font-medium text-slate-700 mb-1">Email Address</label>
                <div class="relative">
                    <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                        <i class="fas fa-envelope text-slate-400"></i>
                    </div>
                    <input type="email" name="email" id="email" required class="block w-full pl-10 pr-3 py-3 border border-slate-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-brandBlue-500 focus:border-brandBlue-500 transition-colors" placeholder="you@example.com">
                </div>
            </div>

            <button type="submit" id="submitBtn" class="w-full flex justify-center py-3 px-4 border border-transparent rounded-md shadow-sm text-sm font-bold text-white bg-navy-900 hover:bg-navy-800 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-navy-900 transition-colors">
                Send Reset Link
            </button>
        </form>

        <div class="mt-6 text-center text-sm text-slate-600">
            Remember your password? 
            <a href="{{APP_URL}}/login" class="font-medium text-brandBlue-600 hover:text-brandBlue-500">Back to login</a>
        </div>
    </div>
</div>

@addScript
<script>
$(document).ready(function() {
    $('#forgotPasswordForm').on('submit', function(e) {
        e.preventDefault();
        
        let $btn = $('#submitBtn');
        let originalText = $btn.html();
        
        $btn.html('<i class="fas fa-spinner fa-spin"></i> Sending...').prop('disabled', true);
        
        $.ajax({
            url: '{{APP_URL}}/forgot-password',
            type: 'POST',
            data: $(this).serialize(),
            success: function(response) {
                if(response.status === 'success') {
                    $('#forgotPasswordForm')[0].reset();
                    showNotification('success', 'Email Sent', response.message);
                }
            },
            error: function(xhr) {
                let msg = 'Failed to send reset link.';
                if(xhr.responseJSON && xhr.responseJSON.errors) {
                    msg = Object.values(xhr.responseJSON.errors)[0][0]; 
                }
                showNotification('error', 'Error', msg);
            },
            complete: function() {
                $btn.html(originalText).prop('disabled', false);
            }
        });
    });
});
</script>
@endAddScript