{"success":true,"html":"<div class=\"modal-header\">\n    <h5 class=\"modal-title\">Careers Opportunities<\/h5>\n    <button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"modal\" aria-label=\"Close\"><\/button>\n<\/div>\n<div class=\"modal-body\">\n    <div class=\"careers-content\">\n        <p class=\"lead mb-4\">We're always looking for talented individuals to join our team. Submit your application below!<\/p>\n        \n        <div id=\"careersAlerts\"><\/div>\n        \n        <form id=\"careersForm\" enctype=\"multipart\/form-data\" method=\"POST\" action=\"javascript:void(0);\">\n            <input type=\"hidden\" name=\"_token\" value=\"KEAC4KCIaQAfk7YqpVSWReZbbfERTdosPcZQl19b\" autocomplete=\"off\">            <div class=\"mb-3\">\n                <label for=\"name\" class=\"form-label\">Full Name<\/label>\n                <input type=\"text\" class=\"form-control\" id=\"name\" name=\"name\" required>\n                <div class=\"invalid-feedback\" id=\"nameError\"><\/div>\n            <\/div>\n            \n            <div class=\"mb-3\">\n                <label for=\"email\" class=\"form-label\">Email Address<\/label>\n                <input type=\"email\" class=\"form-control\" id=\"email\" name=\"email\" required>\n                <div class=\"invalid-feedback\" id=\"emailError\"><\/div>\n            <\/div>\n            \n            <div class=\"mb-3\">\n                <label for=\"phone\" class=\"form-label\">Phone Number<\/label>\n                <input type=\"tel\" class=\"form-control\" id=\"phone\" name=\"phone\" required>\n                <div class=\"invalid-feedback\" id=\"phoneError\"><\/div>\n            <\/div>\n            \n            <div class=\"mb-3\">\n                <label for=\"position\" class=\"form-label\">Position You're Applying For<\/label>\n                <select class=\"form-select\" id=\"position\" name=\"position\" required>\n                    <option value=\"\" selected disabled>Select a position<\/option>\n                    <option value=\"Web Developer\">Web Developer<\/option>\n                    <option value=\"Mobile App Developer\">Mobile App Developer<\/option>\n                    <option value=\"UI\/UX Designer\">UI\/UX Designer<\/option>\n                    <option value=\"AI Engineer\">AI Engineer<\/option>\n                    <option value=\"Project Manager\">Project Manager<\/option>\n                    <option value=\"QA Engineer\">QA Engineer<\/option>\n                    <option value=\"DevOps Engineer\">DevOps Engineer<\/option>\n                    <option value=\"Other\">Other<\/option>\n                <\/select>\n                <div class=\"invalid-feedback\" id=\"positionError\"><\/div>\n            <\/div>\n            \n            <div class=\"mb-3\">\n                <label for=\"resume\" class=\"form-label\">Upload Resume (PDF, DOC, DOCX, max 5MB)<\/label>\n                <input type=\"file\" class=\"form-control\" id=\"resume\" name=\"resume\" accept=\".pdf,.doc,.docx\" required>\n                <div class=\"invalid-feedback\" id=\"resumeError\"><\/div>\n            <\/div>\n            \n            <div class=\"mb-3\">\n                <label for=\"message\" class=\"form-label\">Cover Letter \/ Additional Information<\/label>\n                <textarea class=\"form-control\" id=\"message\" name=\"message\" rows=\"3\"><\/textarea>\n                <div class=\"invalid-feedback\" id=\"messageError\"><\/div>\n            <\/div>\n            \n            <div class=\"d-grid\">\n                <button type=\"submit\" class=\"btn btn-primary\" id=\"submitCareersBtn\">Submit Application<\/button>\n            <\/div>\n        <\/form>\n    <\/div>\n<\/div>\n<div class=\"modal-footer\">\n    <button type=\"button\" class=\"btn btn-secondary\" data-bs-dismiss=\"modal\">Close<\/button>\n<\/div>\n\n<script>\n\/\/ Initialize form handling as soon as this content is loaded into the DOM\nconsole.log('Careers modal content loaded, initializing form handlers');\n\n\/\/ Function to initialize the form handlers\nfunction initCareersForm() {\n    \/\/ Get references to DOM elements\n    const careersForm = document.getElementById('careersForm');\n    const submitBtn = document.getElementById('submitCareersBtn');\n    const alertsContainer = document.getElementById('careersAlerts');\n    \n    \/\/ Debug element existence\n    console.log('Form elements found:', { \n        form: careersForm !== null, \n        button: submitBtn !== null, \n        alerts: alertsContainer !== null \n    });\n    \n    if (!careersForm || !submitBtn || !alertsContainer) {\n        console.error('Required elements not found for careers form');\n        return;\n    }\n    \n    \/\/ Add submit event listener\n    careersForm.addEventListener('submit', function(e) {\n        e.preventDefault();\n        console.log('Form submission initiated');\n        \n        \/\/ Clear previous alerts\n        alertsContainer.innerHTML = '';\n        \n        \/\/ Remove previous validation errors\n        document.querySelectorAll('.is-invalid').forEach(el => {\n            el.classList.remove('is-invalid');\n        });\n        document.querySelectorAll('.invalid-feedback').forEach(el => {\n            if (!el.id) { \/\/ Only remove dynamically added feedback elements\n                el.remove();\n            } else {\n                el.textContent = '';\n            }\n        });\n        \n        \/\/ Get form data\n        const formData = new FormData(careersForm);\n        \n        \/\/ Log form data for debugging (excluding file contents)\n        const formDataDebug = {};\n        formData.forEach((value, key) => {\n            if (key !== 'resume') {\n                formDataDebug[key] = value;\n            } else {\n                formDataDebug[key] = 'File selected: ' + (value.name || 'none');\n            }\n        });\n        console.log('Form data:', formDataDebug);\n        \n        \/\/ Disable submit button and show loading state\n        submitBtn.disabled = true;\n        submitBtn.innerHTML = '<span class=\"spinner-border spinner-border-sm\" role=\"status\" aria-hidden=\"true\"><\/span> Submitting...';\n        \n        \/\/ Get CSRF token - first try from meta tag, then from the form\n        let csrfToken = document.querySelector('meta[name=\"csrf-token\"]')?.getAttribute('content');\n        if (!csrfToken) {\n            \/\/ Fallback to the token in the form\n            const tokenInput = document.querySelector('input[name=\"_token\"]');\n            if (tokenInput) {\n                csrfToken = tokenInput.value;\n            }\n        }\n        console.log('CSRF token found:', csrfToken !== undefined);\n        \n        \/\/ Submit form via AJAX with absolute URL path\n        fetch('https:\/\/appzventure.com\/modals\/careers', {\n            method: 'POST',\n            body: formData,\n            headers: {\n                'X-CSRF-TOKEN': csrfToken || ''\n                \/\/ Do not set Content-Type when using FormData\n            }\n        })\n        .then(response => {\n            console.log('Response status:', response.status);\n            return response.json();\n        })\n        .then(data => {\n            console.log('Response data:', data);\n            \n            if (data.success) {\n                \/\/ Show success message\n                alertsContainer.innerHTML = `\n                    <div class=\"alert alert-success alert-dismissible fade show\" role=\"alert\">\n                        ${data.message}\n                        <button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"alert\" aria-label=\"Close\"><\/button>\n                    <\/div>\n                `;\n                \n                \/\/ Reset form\n                careersForm.reset();\n                \n                \/\/ Scroll to top of modal\n                const modalBody = document.querySelector('.modal-body');\n                if (modalBody) {\n                    modalBody.scrollTop = 0;\n                }\n            } else {\n                \/\/ Show error message\n                let errorMessage = data.message || 'An error occurred while submitting your application.';\n                \n                \/\/ If there are validation errors, display them\n                if (data.errors) {\n                    errorMessage += '<ul class=\"mt-2 mb-0\">';\n                    Object.keys(data.errors).forEach(field => {\n                        \/\/ Add error class to the field\n                        const inputField = document.getElementById(field);\n                        if (inputField) {\n                            inputField.classList.add('is-invalid');\n                            \n                            \/\/ Add error message to existing feedback div or create new one\n                            const existingFeedback = document.getElementById(field + 'Error');\n                            if (existingFeedback) {\n                                existingFeedback.textContent = data.errors[field][0];\n                            } else {\n                                const feedbackDiv = document.createElement('div');\n                                feedbackDiv.className = 'invalid-feedback';\n                                feedbackDiv.textContent = data.errors[field][0];\n                                inputField.parentNode.appendChild(feedbackDiv);\n                            }\n                        }\n                        \n                        \/\/ Add to error message list\n                        errorMessage += `<li>${data.errors[field][0]}<\/li>`;\n                    });\n                    errorMessage += '<\/ul>';\n                }\n                \n                alertsContainer.innerHTML = `\n                    <div class=\"alert alert-danger alert-dismissible fade show\" role=\"alert\">\n                        ${errorMessage}\n                        <button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"alert\" aria-label=\"Close\"><\/button>\n                    <\/div>\n                `;\n            }\n        })\n        .catch(error => {\n            console.error('Error:', error);\n            \n            \/\/ Show error message\n            alertsContainer.innerHTML = `\n                <div class=\"alert alert-danger alert-dismissible fade show\" role=\"alert\">\n                    An error occurred while submitting your application. Please try again later.\n                    <button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"alert\" aria-label=\"Close\"><\/button>\n                <\/div>\n            `;\n        })\n        .finally(() => {\n            \/\/ Re-enable submit button\n            submitBtn.disabled = false;\n            submitBtn.innerHTML = 'Submit Application';\n        });\n    });\n    \n    \/\/ Clear validation errors when input changes\n    careersForm.querySelectorAll('input, textarea, select').forEach(element => {\n        element.addEventListener('input', function() {\n            this.classList.remove('is-invalid');\n            const feedbackElement = this.parentNode.querySelector('.invalid-feedback:not([id])');\n            if (feedbackElement) {\n                feedbackElement.remove();\n            }\n            const staticFeedback = document.getElementById(this.id + 'Error');\n            if (staticFeedback) {\n                staticFeedback.textContent = '';\n            }\n        });\n    });\n    \n    \/\/ Log that initialization is complete\n    console.log('Careers form handlers initialized successfully');\n}\n\n\/\/ Initialize the form immediately\ninitCareersForm();\n\n\/\/ Also initialize when the modal content is fully loaded (for dynamically loaded content)\ndocument.addEventListener('modalContentLoaded', function(event) {\n    if (event.detail.modalId === 'careerModal') {\n        console.log('Career modal content loaded event received, initializing form');\n        initCareersForm();\n    }\n});\n<\/script>\n"}