<?php
session_start();
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Create Account - Ocean Bank Cooperation</title>
    
    <!-- CSS Dependencies -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/boxicons@2.0.7/css/boxicons.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.css" rel="stylesheet">

    <style>
        :root {
            --primary-color: #2563eb;
            --secondary-color: #1e40af;
            --success-color: #059669;
            --danger-color: #dc2626;
            --warning-color: #ea580c;
            --info-color: #0284c7;
            --background-color: #f0f2f5;
        }

        body {
            font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
            background: linear-gradient(135deg, #2563eb, #1e40af);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 1.5rem;
            color: #333;
        }

        .register-container {
            background: white;
            border-radius: 20px;
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
            overflow: hidden;
            width: 100%;
            max-width: 1000px;
            margin: 1rem;
        }

        .register-header {
            background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
            padding: 2rem;
            color: white;
            text-align: center;
            position: relative;
        }

        .register-header::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            height: 4px;
            background: linear-gradient(to right, rgba(255,255,255,0.2), transparent);
        }

        .register-body {
            padding: 2rem;
        }

        /* Progress Steps */
        .step-progress {
            display: flex;
            justify-content: space-between;
            margin: 0 auto 2rem;
            max-width: 600px;
            position: relative;
            padding: 0 20px;
        }

        .step-progress::before {
            content: '';
            position: absolute;
            top: 50%;
            left: 40px;
            right: 40px;
            height: 2px;
            background: #e2e8f0;
            transform: translateY(-50%);
            z-index: 1;
        }

        .step-item {
            position: relative;
            z-index: 2;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: white;
            border: 2px solid #e2e8f0;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 500;
            transition: all 0.3s ease;
        }

        .step-item.active {
            border-color: var(--primary-color);
            background: var(--primary-color);
            color: white;
        }

        .step-item.completed {
            border-color: var(--success-color);
            background: var(--success-color);
            color: white;
        }

        .step-label {
            position: absolute;
            top: 100%;
            left: 50%;
            transform: translateX(-50%);
            margin-top: 8px;
            font-size: 0.875rem;
            color: #64748b;
            white-space: nowrap;
        }

        /* Form Sections */
        .form-section {
            display: none;
            opacity: 0;
            transform: translateY(20px);
            transition: all 0.3s ease;
        }

        .form-section.active {
            display: block;
            opacity: 1;
            transform: translateY(0);
        }

        /* Form Controls */
        .form-control, .form-select {
            padding: 0.75rem 1rem;
            border-radius: 10px;
            border: 2px solid #e2e8f0;
            font-size: 0.95rem;
            transition: all 0.3s ease;
        }

        .form-control:focus, .form-select:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 0.25rem rgba(37, 99, 235, 0.1);
            transform: translateY(-1px);
        }

        .form-label {
            font-weight: 500;
            color: #4b5563;
            margin-bottom: 0.5rem;
        }

        /* Profile Upload */
        .profile-upload {
            display: flex;
            align-items: center;
            gap: 1.5rem;
            margin-bottom: 1.5rem;
        }

        .profile-preview {
            width: 100px;
            height: 100px;
            border-radius: 50%;
            overflow: hidden;
            border: 3px solid #e2e8f0;
            position: relative;
        }

        .profile-preview img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .upload-btn {
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            background: rgba(0,0,0,0.5);
            color: white;
            padding: 0.25rem;
            font-size: 0.75rem;
            text-align: center;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .upload-btn:hover {
            background: rgba(0,0,0,0.7);
        }

        /* Buttons */
        .btn {
            padding: 0.75rem 1.5rem;
            border-radius: 10px;
            font-weight: 500;
            transition: all 0.3s ease;
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
        }

        .btn-primary {
            background: var(--primary-color);
            border: none;
        }

        .btn-primary:hover {
            background: var(--secondary-color);
            transform: translateY(-2px);
        }

        .btn-outline-secondary {
            border-color: #e2e8f0;
            color: #64748b;
        }

        .btn-outline-secondary:hover {
            background: #f8fafc;
            border-color: #cbd5e1;
        }

        /* Animations */
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .fade-in {
            animation: fadeIn 0.5s ease forwards;
        }
    </style>
</head>
<body>

    <div class="register-body">
    <?php if (isset($_SESSION['error'])): ?>
        <div class="alert alert-danger alert-dismissible fade show" role="alert">
            <?php 
                echo htmlspecialchars($_SESSION['error']); 
                unset($_SESSION['error']); // Clear the error message
            ?>
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>
    <?php endif; ?>
    
    <!-- Rest of your form content -->


<div class="register-container">
<div class="register-container">
    <div class="register-header">
        <img src="assets/images/logo.png" alt="Bank Logo" height="40" class="mb-3">
        <h3>Create Your Account</h3>
        <p class="mb-0">Fill in your details to get started</p>
    </div>

    <div class="register-body">
        <!-- Step Progress -->
        <div class="step-progress">
            <div class="step-item active" data-step="1">
                1
                <span class="step-label">Personal Info</span>
            </div>
            <div class="step-item" data-step="2">
                2
                <span class="step-label">Profile</span>
            </div>
            <div class="step-item" data-step="3">
                3
                <span class="step-label">Account</span>
            </div>
            <div class="step-item" data-step="4">
                4
                <span class="step-label">Security</span>
            </div>
        </div>

        <!-- Registration Form -->
      <form id="registrationForm" action="process_registration.php" method="POST" enctype="multipart/form-data" onsubmit="return handleSubmit(event)">


            <!-- Step 1: Personal Information -->
            <div class="form-section active" id="step1">
                <h5 class="mb-4">Personal Information</h5>
                <div class="row g-3">
                    <div class="col-md-6">
                        <label class="form-label">First Name</label>
                        <input type="text" class="form-control" name="firstName" required>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">Last Name</label>
                        <input type="text" class="form-control" name="lastName" required>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">Email Address</label>
                        <input type="email" class="form-control" name="email" required>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">Phone Number</label>
                        <input type="tel" class="form-control" name="phone" required>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">Date of Birth</label>
                        <input type="date" class="form-control" name="dob" required>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">Gender</label>
                        <select class="form-select" name="gender" required>
                            <option value="">Select Gender</option>
                            <option value="male">Male</option>
                            <option value="female">Female</option>
                            <option value="other">Other</option>
                        </select>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">Country</label>
                        <select class="form-select" name="country" required>
                            <option value="">Select Country</option>
                            <option value="US">United States</option>
                            <option value="GB">United Kingdom</option>
                            <option value="CA">Canada</option>
                            <option value="AU">Australia</option>
                            <option value="DE">Germany</option>
                            <option value="FR">France</option>
                            <!-- Add more countries as needed -->
                        </select>
                    </div>
                    <div class="col-12">
                        <label class="form-label">Address</label>
                        <textarea class="form-control" name="address" rows="3" required></textarea>
                    </div>
                </div>

                <div class="d-flex justify-content-end mt-4">
                    <button type="button" class="btn btn-primary" onclick="nextStep(1)">
                        Continue <i class='bx bx-right-arrow-alt'></i>
                    </button>
                </div>
            </div>

            <!-- Step 2: Profile & Documents -->
            <div class="form-section" id="step2">
                <h5 class="mb-4">Profile Setup</h5>
                
                <!-- Profile Picture -->
                <div class="profile-upload mb-4">
                    <div class="profile-preview">
                        <img src="assets/images/default-avatar.png" id="profilePreview" alt="Profile Preview">
                        <div class="upload-btn" onclick="document.getElementById('profilePicture').click()">
                            <i class='bx bx-camera'></i> Change
                        </div>
                        <input type="file" id="profilePicture" name="profilePicture" hidden accept="image/*" onchange="previewImage(this)">
                    </div>
                    <div class="upload-info">
                        <h6 class="mb-2">Profile Picture</h6>
                        <p class="text-muted mb-0">Upload a clear photo of yourself</p>
                        <small class="text-muted">Max file size: 5MB (JPG or PNG)</small>
                    </div>
                </div>

                <!-- Next of Kin Information -->
                <h5 class="mb-4">Next of Kin Details</h5>
                <div class="row g-3">
                    <div class="col-md-6">
                        <label class="form-label">Full Name</label>
                        <input type="text" class="form-control" name="kinName" required>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">Relationship</label>
                        <select class="form-select" name="kinRelationship" required>
                            <option value="">Select Relationship</option>
                            <option value="spouse">Spouse</option>
                            <option value="parent">Parent</option>
                            <option value="child">Child</option>
                            <option value="sibling">Sibling</option>
                            <option value="other">Other</option>
                        </select>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">Email Address</label>
                        <input type="email" class="form-control" name="kinEmail" required>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">Phone Number</label>
                        <input type="tel" class="form-control" name="kinPhone" required>
                    </div>
                    <div class="col-12">
                        <label class="form-label">Address</label>
                        <textarea class="form-control" name="kinAddress" rows="3" required></textarea>
                    </div>
                </div>

                <div class="d-flex justify-content-between mt-4">
                    <button type="button" class="btn btn-outline-secondary" onclick="prevStep(2)">
                        <i class='bx bx-left-arrow-alt'></i> Back
                    </button>
                    <button type="button" class="btn btn-primary" onclick="nextStep(2)">
                        Continue <i class='bx bx-right-arrow-alt'></i>
                    </button>
                </div>
            </div>

            <!-- Step 3: Account Details -->
            <div class="form-section" id="step3">
                <h5 class="mb-4">Account Setup</h5>
                <div class="row g-3">
                    <div class="col-md-6">
                        <label class="form-label">Account Type</label>
                        <select class="form-select" name="accountType" required>
                            <option value="">Select Account Type</option>
                            <option value="savings">Savings Account</option>
                            <option value="checking">Checking Account</option>
                            <option value="business">Business Account</option>
                        </select>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">Currency</label>
                        <select class="form-select" name="currency" required>
                            <option value="">Select Currency</option>
                            <option value="USD">US Dollar (USD)</option>
                            <option value="EUR">Euro (EUR)</option>
                            <option value="GBP">British Pound (GBP)</option>
                            <option value="AUD">Australian Dollar (AUD)</option>
                        </select>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">Employment Status</label>
                        <select class="form-select" name="employmentStatus" required>
                            <option value="">Select Status</option>
                            <option value="employed">Employed</option>
                            <option value="self-employed">Self-Employed</option>
                            <option value="student">Student</option>
                            <option value="retired">Retired</option>
                            <option value="unemployed">Unemployed</option>
                        </select>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">Source of Income</label>
                        <select class="form-select" name="incomeSource" required>
                            <option value="">Select Source</option>
                            <option value="salary">Salary</option>
                            <option value="business">Business Income</option>
                            <option value="investments">Investments</option>
                            <option value="other">Other</option>
                        </select>
                    </div>
                </div>

                <div class="d-flex justify-content-between mt-4">
                    <button type="button" class="btn btn-outline-secondary" onclick="prevStep(3)">
                        <i class='bx bx-left-arrow-alt'></i> Back
                    </button>
                    <button type="button" class="btn btn-primary" onclick="nextStep(3)">
                        Continue <i class='bx bx-right-arrow-alt'></i>
                    </button>
                </div>
            </div>

            <!-- Step 4: Security -->
            <div class="form-section" id="step4">
                <h5 class="mb-4">Security Setup</h5>
                <div class="row g-3">
                    <div class="col-md-6">
                        <label class="form-label">Username</label>
                        <input type="text" class="form-control" name="username" required 
                               pattern="^[a-zA-Z0-9_]{4,20}$" 
                               title="4-20 characters, letters, numbers and underscore only">
                        <small class="text-muted">4-20 characters, letters, numbers and underscore only</small>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">Password</label>
                        <div class="input-group">
                            <input type="password" class="form-control" name="password" id="password" required
                                   pattern="^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$"
                                   title="Minimum 8 characters, at least one letter and one number">
                            <button class="btn btn-outline-secondary" type="button" onclick="togglePassword()">
                                <i class='bx bx-show'></i>
                            </button>
                        </div>
                        <small class="text-muted">Minimum 8 characters, at least one letter and one number</small>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">Confirm Password</label>
                        <input type="password" class="form-control" name="confirmPassword" required>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">PIN (4 digits)</label>
                        <input type="password" class="form-control" name="pin" required
                               pattern="\d{4}" maxlength="4"
                               title="4 digits only">
                        <small class="text-muted">4 digits only</small>
                    </div>
                </div>

                <div class="mt-4">
                    <div class="form-check mb-3">
                        <input class="form-check-input" type="checkbox" id="enableTwoFactor" name="enableTwoFactor">
                        <label class="form-check-label" for="enableTwoFactor">
                            Enable Two-Factor Authentication
                        </label>
                    </div>
                    <div class="form-check">
                        <input class="form-check-input" type="checkbox" id="termsAccept" required>
                        <label class="form-check-label" for="termsAccept">
                            I agree to the <a href="#" data-bs-toggle="modal" data-bs-target="#termsModal">Terms & Conditions</a>
                            and <a href="#" data-bs-toggle="modal" data-bs-target="#privacyModal">Privacy Policy</a>
                        </label>
                    </div>
                </div>

                <div class="d-flex justify-content-between mt-4">
                    <button type="button" class="btn btn-outline-secondary" onclick="prevStep(4)">
                        <i class='bx bx-left-arrow-alt'></i> Back
                    </button>
                    <button type="submit" class="btn btn-primary">
                        Create Account <i class='bx bx-check'></i>
                    </button>
                </div>
            </div>
        </form>
    </div>
</div>

<!-- Terms Modal -->
<div class="modal fade" id="termsModal" tabindex="-1">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Terms & Conditions</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>
            <div class="modal-body">
                <!-- Add your terms content here -->
                <h6>1. Account Terms</h6>
                <p>Terms content goes here...</p>
            </div>
        </div>
    </div>
</div>

<!-- Privacy Modal -->
<div class="modal fade" id="privacyModal" tabindex="-1">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Privacy Policy</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>
            <div class="modal-body">
                <!-- Add your privacy policy content here -->
                <h6>1. Data Collection</h6>
                <p>Privacy policy content goes here...</p>
            </div>
        </div>
    </div>
</div>
<!-- Scripts -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>

<script>
// Global variables
let currentStep = 1;
const totalSteps = 4;

// Initialize on page load
document.addEventListener('DOMContentLoaded', function() {
    updateProgressBar();
    initializeValidation();
    setupImagePreview();
    document.getElementById('registrationForm').addEventListener('submit', handleSubmit);
});

// Progress bar and step management
function updateProgressBar() {
    document.querySelectorAll('.step-item').forEach((step, index) => {
        if (index + 1 < currentStep) {
            step.classList.add('completed');
            step.classList.remove('active');
        } else if (index + 1 === currentStep) {
            step.classList.add('active');
            step.classList.remove('completed');
        } else {
            step.classList.remove('active', 'completed');
        }
    });
}

function nextStep(step) {
    if (!validateStep(step)) return;

    document.querySelector(`#step${step}`).classList.remove('active');
    document.querySelector(`#step${step + 1}`).classList.add('active');
    currentStep = step + 1;
    updateProgressBar();
    window.scrollTo({ top: 0, behavior: 'smooth' });
}

function prevStep(step) {
    document.querySelector(`#step${step}`).classList.remove('active');
    document.querySelector(`#step${step - 1}`).classList.add('active');
    currentStep = step - 1;
    updateProgressBar();
    window.scrollTo({ top: 0, behavior: 'smooth' });
}

// Form validation
function initializeValidation() {
    // Password strength validation
    const password = document.querySelector('input[name="password"]');
    const confirmPassword = document.querySelector('input[name="confirmPassword"]');
    
    password?.addEventListener('input', function() {
        validatePassword(this);
    });

    confirmPassword?.addEventListener('input', function() {
        validatePasswordMatch(password, this);
    });

    // Username validation
    const username = document.querySelector('input[name="username"]');
    username?.addEventListener('input', function() {
        validateUsername(this);
    });

    // PIN validation
    const pin = document.querySelector('input[name="pin"]');
    pin?.addEventListener('input', function() {
        this.value = this.value.replace(/[^0-9]/g, '').slice(0, 4);
    });

    // Phone number formatting
    const phoneInputs = document.querySelectorAll('input[type="tel"]');
    phoneInputs.forEach(input => {
        input.addEventListener('input', function() {
            formatPhoneNumber(this);
        });
    });
}

function validateStep(step) {
    const currentSection = document.querySelector(`#step${step}`);
    const requiredFields = currentSection.querySelectorAll('[required]');
    let isValid = true;

    requiredFields.forEach(field => {
        if (!field.value) {
            isValid = false;
            highlightError(field);
        } else {
            removeError(field);
        }
    });

    if (!isValid) {
        showError('Please fill in all required fields');
        return false;
    }

    // Additional validation based on step
    switch(step) {
        case 1:
            return validatePersonalInfo();
        case 2:
            return validateDocuments();
        case 3:
            return validateAccountInfo();
        case 4:
            return validateSecurityInfo();
    }

    return true;
}

// Specific validation functions
function validatePersonalInfo() {
    const email = document.querySelector('input[name="email"]');
    const phone = document.querySelector('input[name="phone"]');
    const dob = document.querySelector('input[name="dob"]');

    if (!isValidEmail(email.value)) {
        showError('Please enter a valid email address');
        highlightError(email);
        return false;
    }

    if (!isValidPhone(phone.value)) {
        showError('Please enter a valid phone number');
        highlightError(phone);
        return false;
    }

    if (!isValidAge(dob.value)) {
        showError('You must be 18 or older to register');
        highlightError(dob);
        return false;
    }

    return true;
}

function validateDocuments() {
    const profilePicture = document.getElementById('profilePicture');
    
    if (profilePicture.files.length === 0) {
        showError('Please upload a profile picture');
        return false;
    }

    return true;
}

function validateAccountInfo() {
    return true; // Add specific validation if needed
}

function validateSecurityInfo() {
    const password = document.querySelector('input[name="password"]');
    const confirmPassword = document.querySelector('input[name="confirmPassword"]');
    const pin = document.querySelector('input[name="pin"]');

    if (!isValidPassword(password.value)) {
        showError('Password must be at least 8 characters with letters and numbers');
        highlightError(password);
        return false;
    }

    if (password.value !== confirmPassword.value) {
        showError('Passwords do not match');
        highlightError(confirmPassword);
        return false;
    }

    if (!isValidPin(pin.value)) {
        showError('PIN must be exactly 4 digits');
        highlightError(pin);
        return false;
    }

    return true;
}

// Helper validation functions
function isValidEmail(email) {
    return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
}

function isValidPhone(phone) {
    const cleaned = phone.replace(/\D/g, '');
    return cleaned.length >= 10;
}

function isValidAge(dob) {
    const age = new Date(new Date() - new Date(dob)).getFullYear() - 1970;
    return age >= 18;
}

function isValidPassword(password) {
    return /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/.test(password);
}

function isValidPin(pin) {
    return /^\d{4}$/.test(pin);
}

// UI feedback functions
function showError(message) {
    Swal.fire({
        icon: 'error',
        title: 'Validation Error',
        text: message,
        toast: true,
        position: 'top-end',
        showConfirmButton: false,
        timer: 3000,
        timerProgressBar: true
    });
}

function highlightError(element) {
    element.classList.add('is-invalid');
    element.addEventListener('input', function() {
        this.classList.remove('is-invalid');
    }, { once: true });
}

function removeError(element) {
    element.classList.remove('is-invalid');
}

// Image preview handling
function setupImagePreview() {
    const profilePicture = document.getElementById('profilePicture');
    const preview = document.getElementById('profilePreview');

    if (profilePicture && preview) {
        profilePicture.addEventListener('change', function(e) {
            const file = e.target.files[0];
            if (file) {
                if (file.size > 5 * 1024 * 1024) {
                    showError('Profile picture must be less than 5MB');
                    this.value = '';
                    return;
                }

                if (!file.type.startsWith('image/')) {
                    showError('Please select an image file');
                    this.value = '';
                    return;
                }

                const reader = new FileReader();
                reader.onload = function(e) {
                    preview.src = e.target.result;
                    preview.classList.add('fade-in');
                }
                reader.readAsDataURL(file);
            }
        });
    }
}

// Password visibility toggle
function togglePassword() {
    const passwordInput = document.getElementById('password');
    const icon = document.querySelector('.bx-show, .bx-hide');
    
    if (passwordInput.type === 'password') {
        passwordInput.type = 'text';
        icon.classList.replace('bx-show', 'bx-hide');
    } else {
        passwordInput.type = 'password';
        icon.classList.replace('bx-hide', 'bx-show');
    }
}

// Phone number formatting
function formatPhoneNumber(input) {
    let cleaned = input.value.replace(/\D/g, '');
    let formatted = cleaned;
    
    if (cleaned.length > 0) {
        if (cleaned.length <= 3) {
            formatted = cleaned;
        } else if (cleaned.length <= 6) {
            formatted = `(${cleaned.slice(0,3)}) ${cleaned.slice(3)}`;
        } else {
            formatted = `(${cleaned.slice(0,3)}) ${cleaned.slice(3,6)}-${cleaned.slice(6,10)}`;
        }
    }
    
    input.value = formatted;
}


// Form submission
// Replace your existing handleSubmit function with this:
function handleSubmit(event) {
    if (!validateStep(currentStep)) {
        event.preventDefault();
        return false;
    }

    if (!document.getElementById('termsAccept').checked) {
        event.preventDefault();
        Swal.fire({
            icon: 'error',
            title: 'Terms & Conditions',
            text: 'Please accept the terms and conditions to continue'
        });
        return false;
    }

    // Show loading state
    Swal.fire({
        title: 'Creating Your Account',
        html: 'Please wait while we process your registration...',
        allowOutsideClick: false,
        didOpen: () => {
            Swal.showLoading();
        }
    });


   // Let the form submit normally
    return true;
}


</script>

</body>
</html>
