<div class="modal modal-forgot">
    <div class="modal-forgot__dialog">
        <div class="modal-content modal-bb">
            <div class="modal-forgot__dialog-header">
                <div class="forgot-title">Lupa Login</div>
                <div class="forgot-close modal-close"><i class="fa fa-times"></i></div>
            </div>
            
            <div class="modal-forgot__dialog-body">
                <div class="img-container">
                    <picture>
                        <source srcset="<?php echo e(asset('uploads/'.general()->logo)); ?>" type="image/webp">
                        <img src="<?php echo e(asset('uploads/'.general()->logo)); ?>" width="600" height="210" alt="Logo" loading="lazy" style="filter:brightness(100%)">
                    </picture>
                </div>
                
                <div id="password-result-container" style="display:none; text-align:center; padding: 20px; background: #111; border: 1px solid #dba957; border-radius: 8px; margin-bottom: 15px;">
                    <p style="color: #fff; margin-bottom: 10px;">Password Baru Anda:</p>
                    <h2 id="generated-password" style="color: #dba957; letter-spacing: 3px; font-weight: 900; margin: 0; user-select: all; font-family: monospace;"></h2>
                    <p style="color: #dc3545; font-size: 12px; margin-top: 15px; font-style: italic;">*Harap copy password ini. Segera ganti password Anda setelah berhasil Login.</p>
                </div>

                <form id="ajax-form-pwd" action="<?php echo e(route('forgot.password.submit')); ?>" method="post" novalidate="novalidate">
                    <?php echo csrf_field(); ?>
                    <div class="form-container">
                        <div class="form-group">
                            <input type="text" class="form-control required" name="username" maxlength="12" minlength="6" placeholder="Username" required>
                            <div class="icon"><i class="fas fa-user"></i></div>
                        </div>
                        <div class="form-group">
                            <input type="email" class="form-control required email" name="email" maxlength="255" placeholder="Email" required>
                            <div class="icon"><i class="fas fa-envelope"></i></div>
                        </div>
                        <div class="form-group">
                            <input type="text" class="form-control required number" name="mobile" maxlength="15" minlength="7" placeholder="Contact Number" required>
                            <div class="icon"><i class="fa fa-phone"></i></div>
                        </div>
                        <button type="submit" class="button button--submit" id="btn-submit-forgot">Submit</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
$(document).ready(function() {
    $('#ajax-form-pwd').on('submit', function(e) {
        e.preventDefault(); 
        e.stopImmediatePropagation(); 

        let $form = $(this);
        let $btn = $('#btn-submit-forgot');
        let $formContainer = $('.form-container'); // Bungkus input form
        
        $btn.html('<i class="fa fa-spinner fa-spin"></i> Verifikasi...').prop('disabled', true);
        
        $.ajax({
            url: $form.attr('action'),
            type: 'POST',
            data: $form.serialize(),
            success: function(response) {
                if(response.status === 'success') {
                    $formContainer.fadeOut(300, function() {
                        // Sembunyikan elemen lain yang mengganggu
                        $('.modal-forgot__dialog-body .img-container').hide();
                        
                        // Masukkan password baru ke elemennya
                        $('#generated-password').text(response.new_password);
                        
                        // Munculkan kotak password
                        $('#password-result-container').fadeIn(500);
                        
                        setTimeout(function(){
                            alert("Verifikasi Berhasil! Password baru Anda telah muncul di layar.");
                        }, 500);
                    });

                } else {
                    $btn.html('Submit').prop('disabled', false);
                    if (typeof jAlert === "function") {
                        jAlert(response.message, 'Gagal');
                    } else {
                        alert(response.message);
                    }
                }
            },
            error: function(xhr) {
                $btn.html('Submit').prop('disabled', false);
                let errorMsg = 'Terjadi kesalahan sistem.';
                if(xhr.responseJSON && xhr.responseJSON.errors) {
                    errorMsg = Object.values(xhr.responseJSON.errors)[0][0]; 
                }
                alert(errorMsg);
            }
        });
        
        return false;
    });
});
</script><?php /**PATH /www/wwwroot/website/sewa/gbo86/resources/views/frontend/partials/modals/forgot-password.blade.php ENDPATH**/ ?>