<div class="modal fade" id="loginModal" tabindex="-1" role="dialog" aria-labelledby="loginModalTitle" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="loginModalLongTitle"><?php echo app('translator')->get('Login'); ?></h5>
                <span type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
                    <i class="las la-times"></i>
                </span>
            </div>
            <div class="modal-body">
                <?php
                    $credentials = gs('socialite_credentials');
                    $socialLoginActive =
                        @$credentials->google->status == Status::ENABLE ||
                        @$credentials->facebook->status == Status::ENABLE ||
                        @$credentials->linkedin->status == Status::ENABLE;
                ?>

                <?php if($socialLoginActive): ?>
                    <?php echo $__env->make('Template::partials.social_login', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                    <div class="account-card__divider my-3">
                        <span><?php echo app('translator')->get('OR'); ?></span>
                    </div>
                <?php endif; ?>

                <form id="ajaxLoginForm" method="POST">
                    <?php echo csrf_field(); ?>
                    <div class="mb-3">
                        <label for="username" class="form-label"><?php echo app('translator')->get('Email or Username'); ?></label>
                        <input type="text" class="form-control form--control" id="username" name="username" required>
                    </div>
                    <div class="mb-3">
                        <label for="password" class="form-label"><?php echo app('translator')->get('Password'); ?></label>
                        <div class="input-group input--group input--group-password">
                            <input class="form-control form--control" name="password" type="password"
                                placeholder="<?php echo app('translator')->get('Password'); ?>" id="password" required>
                            <button class="input-group-text input-group-btn toggle-password" type="button">
                                <i class="far fa-eye-slash"></i>
                            </button>
                        </div>
                    </div>

                    <!-- CAPTCHA -->
                    <div class="mb-3" id="captcha-container">
                        <?php echo $__env->make('Template::partials.captcha', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                    </div>

                    <div class="d-flex align-items-center justify-content-between gap-2 flex-wrap">
                        <div class="mb-3 form-check">
                            <input type="checkbox" class="form-check-input" id="rememberMe" name="remember">
                            <label class="form-check-label" for="rememberMe"><?php echo app('translator')->get('Remember Me'); ?></label>
                        </div>
                        <a class="fs-15 mb-3" href="<?php echo e(route('user.password.request')); ?>"><?php echo app('translator')->get('Forgot Password?'); ?></a>
                    </div>

                    <button type="submit" class="btn btn--base w-100 h-45"><?php echo app('translator')->get('Sign In'); ?></button>

                    <?php if(gs('registration')): ?>
                        <p class="text-center mt-3">
                            <?php echo app('translator')->get("Don't have an account?"); ?> <a href="<?php echo e(route('user.register')); ?>"><?php echo app('translator')->get('Register'); ?></a>
                        </p>
                    <?php endif; ?>
                </form>
            </div>
        </div>
    </div>
</div>

<?php $__env->startPush('script'); ?>
    <script>
        (function($) {
            "use strict";

            // AJAX Login
            $("#ajaxLoginForm").on("submit", function(e) {
                e.preventDefault();

                let formData = $(this).serialize();

                $.ajax({
                    url: "<?php echo e(route('user.login.ajax')); ?>",
                    type: "POST",
                    data: formData,
                    success: function(response) {
                        if (response.success) {
                            location.reload(); // Refresh page on successful login
                        } else {
                            notify("error", response
                                .error); // Use notify instead of inline error message
                        }
                    },
                    error: function(xhr) {
                        let errorMsg = xhr.responseJSON ? xhr.responseJSON.error :
                            "<?php echo app('translator')->get('Something went wrong!'); ?>";
                        notify("error", errorMsg);

                        // Update CAPTCHA
                        if (xhr.responseJSON && xhr.responseJSON.captcha) {
                            $("#captcha-container").html(xhr.responseJSON.captcha);
                        }
                    }
                });
            });

        })(jQuery);
    </script>
<?php $__env->stopPush(); ?>
<?php /**PATH /home/mojibor/work.mojibor.com/core/resources/views/templates/basic/partials/login_modal.blade.php ENDPATH**/ ?>