<?php
$pageName  = "Open an Account";
include $_SERVER['DOCUMENT_ROOT'] . "/auth/header2.php";

if (@$_SESSION['acct_no']) {
    header("Location:./user/dashboard.php");
}

if (isset($_POST['regSubmit'])) {
    $acct_no = "1202" . (substr(number_format(time() * rand(), 0, '', ''), 0, 6));
    $firstname = $_POST['firstname'];
    $lastname = $_POST['lastname'];
    $acct_status = "hold";
    $acct_address = $_POST['address'];
    $acct_type = $_POST['acct_type'];
    $acct_gender = $_POST['acct_gender'];
    $state = $_POST['state'];
    $zipcode = $_POST['zipcode'];
    $country = $_POST['country'];
    $acct_currency = $_POST['acct_currency'];
    $acct_email = $_POST['acct_email'];
    $acct_phone = $_POST['phoneNumber'];
    $acct_password = $_POST['acct_password'];
    $confirmPassword = $_POST['confirmPassword'];
    $acct_pin = inputValidation($_POST['acct_pin']);
    $acct_dob = $_POST['acct_dob'];

    if ($acct_password !== $confirmPassword) {
        toast_alert('error', 'Password not matched');
    } else {
        $usersVerified = "SELECT * FROM users WHERE acct_email=:acct_email or acct_phone=:acct_phone";
        $stmt = $conn->prepare($usersVerified);
        $stmt->execute([
            'acct_email' => $acct_email,
            'acct_phone' => $acct_phone
        ]);

        if ($stmt->rowCount() > 0) {
            toast_alert('error', 'Email or Phone Number Already Exit');
        } else {
            $registered = "INSERT INTO users (firstname,lastname,acct_email,acct_password,acct_no,acct_status,acct_phone,acct_type,acct_currency,acct_gender,state,acct_address,country,zipcode,acct_dob,acct_pin) VALUES(:firstname,:lastname,:acct_email,:acct_password,:acct_no,:acct_status,:acct_phone,:acct_type,:acct_currency,:acct_gender,:state,:acct_address,:country,:zipcode,:acct_dob,:acct_pin)";
            $reg = $conn->prepare($registered);
            $reg->execute([
                'firstname' => $firstname,
                'lastname' => $lastname,
                'acct_email' => $acct_email,
                'acct_password' => password_hash((string)$acct_password, PASSWORD_BCRYPT),
                'acct_no' => $acct_no,
                'acct_status' => $acct_status,
                'acct_phone' => $acct_phone,
                'acct_type' => $acct_type,
                'acct_currency' => $acct_currency,
                'acct_gender' => $acct_gender,
                'state' => $state,
                'acct_address' => $acct_address,
                'country' => $country,
                'zipcode' => $zipcode,
                'acct_dob' => $acct_dob,
                'acct_pin' => $acct_pin
            ]);

            $number = $acct_phone;
            $full_name = $firstname . " " . $lastname;

            if($page['twillio_status'] == '1'){
                $messageText = "Dear ".$full_name.", Thank you for registering at ".$APP_NAME.". Kindly wait while your account is activated, Thanks ";
                $sendSms->sendSmsCode($number,$messageText);
            }

            if (true) {
                $full_name = $firstname . " " . $lastname;
                $APP_NAME = WEB_TITLE;
                $APP_URL = WEB_URL;
                $SITE_ADDRESS = $page['url_address'];
                $message = $sendMail->RegisterMsg($full_name, $acct_no, $acct_status, $APP_NAME, $APP_URL, $SITE_ADDRESS);
                $subject = "Welcome to " . "-" . $APP_NAME;
                $email_message->send_mail($acct_email, $message, $subject);

                $msg1 = "
                <div class='rounded-xl border border-primary-200 bg-primary-50 p-6 text-center space-y-4'>
                <script type='text/javascript'>
                    function Redirect() {
                        window.location='./login.php';
                    }
                    setTimeout(Redirect, 6000);
                </script>
                <div class='flex justify-center'>
                    <svg class='w-12 h-12 text-primary-500 animate-spin' xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24'>
                        <circle class='opacity-25' cx='12' cy='12' r='10' stroke='currentColor' stroke-width='4'></circle>
                        <path class='opacity-75' fill='currentColor' d='M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z'></path>
                    </svg>
                </div>
                <p class='text-base font-semibold text-primary-700'>Registration Successful!</p>
                <p class='text-sm text-primary-600'>Your account has been created. Redirecting to login page...</p>
                </div>
                ";
            } else {
                toast_alert("error", "Invalid details");
            }
        }
    }
}
?>
<!doctype html>
<html lang="en">

<head>
    <title>Create an Account - <?= $pageTitle ?></title>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="robots" content="index, follow">
    <meta name="apple-mobile-web-app-title" content="<?= $pageTitle ?>" />
    <meta name="application-name" content="<?= $pageTitle ?>" />
    <meta name="description" content="Swift and Secure Money Transfer to any bank account will become a breeze with <?= $pageTitle ?>." />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <meta name="theme-color" content="#49786B">
    <link rel="shortcut icon" href="https://fintech.swizzfx.pro/storage/app/public/photos/WYFJqSOFyCRakQVubpxZBLmg4xodYDtx2MhIRcxv.png" />
    
    <script src="https://cdn.tailwindcss.com"></script>
    <script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
    <script src="https://unpkg.com/lucide@latest"></script>
    
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" />
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@19.5.6/build/css/intlTelInput.css">
    
    <script>
    tailwind.config = {
        theme: {
            extend: {
                colors: {
                    primary: {
                        50:  '#f0f7f4',
                        100: '#d9ede3',
                        200: '#b3dbc7',
                        300: '#7fc29f',
                        400: '#4da576',
                        500: '#2d8659',
                        600: '#1f6b45',
                        700: '#195539',
                        800: '#15442e',
                        900: '#0d2a1c',
                    },
                    surface: {
                        100: '#FFFFFF',
                        200: '#F9F9F9',
                        300: '#DFE5E5',
                        400: '#BFC9C9',
                    },
                },
                fontFamily: {
                    sans: ['Inter', 'system-ui', 'sans-serif'],
                },
                boxShadow: {
                    'elegant': '0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08)',
                },
                animation: {
                    'fade-in': 'fadeIn .4s ease-out',
                },
                keyframes: {
                    fadeIn: {
                        '0%': { opacity: '0' },
                        '100%': { opacity: '1' }
                    },
                },
            }
        }
    }
    </script>
    
    <style>
    [x-cloak] { display: none !important; }

    :root {
        --color-bg-base: #FFFFFF;
        --color-bg-surface: #F9F9F9;
        --color-bg-muted: #DFE5E5;
        --color-primary: #2d8659;
        --color-primary-dark: #1f6b45;
        --color-primary-light: #4da576;
        --color-text-primary: #0D1B23;
        --color-text-secondary: #4A4A4A;
        --color-text-muted: #7A7A7A;
        --color-text-inverse: #FFFFFF;
        --color-border: #E0E5E5;
        --color-border-dark: #C8D1D1;
        --color-border-muted: #A0ACAC;
        --color-status-success: #28A745;
        --color-status-warning: #EBBC46;
        --color-status-error: #D55672;
        --color-status-info: #2d8659;
    }

    * {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    body {
        font-family: 'Inter', system-ui, sans-serif;
        background: #F9F9F9;
        min-height: 100vh;
        letter-spacing: -0.011em;
    }

    .auth-card {
        background: #FFFFFF;
        border: 1px solid var(--color-border);
        box-shadow: 0 8px 32px rgba(13, 27, 35, 0.06), 0 2px 8px rgba(13, 27, 35, 0.04);
    }

    .auth-input {
        background: #FFFFFF;
        border: 1px solid var(--color-border-dark);
        color: var(--color-text-primary);
        transition: border-color 0.2s ease;
    }

    .auth-input:focus {
        background: #FFFFFF;
        border-color: var(--color-primary);
        box-shadow: 0 0 0 2px rgba(73, 120, 107, 0.12);
        outline: none;
    }

    .auth-input::placeholder {
        color: var(--color-text-muted);
    }

    .auth-button {
        background: var(--color-primary);
        transition: background 0.2s ease;
    }

    .auth-button:hover {
        background: var(--color-primary-dark);
    }

    ::-webkit-scrollbar { width: 8px; height: 8px; }
    ::-webkit-scrollbar-track { background: #F9F9F9; }
    ::-webkit-scrollbar-thumb { background: var(--color-border-dark); border-radius: 4px; }
    ::-webkit-scrollbar-thumb:hover { background: #A0ACAC; }

    .auth-link {
        color: var(--color-primary);
        text-decoration: none;
        transition: color 0.2s ease;
    }
    .auth-link:hover { color: var(--color-primary-light); }
    </style>
</head>

<body class="antialiased overflow-x-hidden" x-data="{ showPassword: false, loading: false }">

    <div class="min-h-screen flex items-center justify-center p-4 relative z-10">

        <div class="w-full max-w-7xl mx-auto">
            <div class="grid lg:grid-cols-5 gap-8 items-start">

                <!-- Left Side - Branding -->
                <div class="hidden lg:block lg:col-span-2 space-y-8 sticky top-8">
                    <div>
                        <img src="<?= $web_url ?>/admin/assets/images/logo/<?= htmlspecialchars($page['image']) ?>"
                             alt="<?= $pageTitle ?>"
                             class="h-12 w-auto mb-8">
                    </div>
                    <div class="space-y-6">
                        <h1 class="text-3xl font-semibold text-[#0D1B23] leading-tight">
                            Start Your
                            <span class="text-primary-500">Banking Journey</span>
                        </h1>
                        <p class="text-base text-[#4A4A4A] leading-relaxed">
                            Join thousands of satisfied customers who trust <?= $pageTitle ?> for secure, swift money transfers worldwide.
                        </p>
                    </div>
                    <div class="space-y-4">
                        <div class="flex items-start space-x-3">
                            <div class="flex-shrink-0 w-8 h-8 rounded-lg bg-white flex items-center justify-center mt-0.5">
                                <i data-lucide="check" class="w-4 h-4 text-primary-500"></i>
                            </div>
                            <div>
                                <p class="text-sm font-semibold text-[#0D1B23]">Bank-Level Security</p>
                                <p class="text-xs text-[#7A7A7A]">256-bit encryption protects your data</p>
                            </div>
                        </div>
                        <div class="flex items-start space-x-3">
                            <div class="flex-shrink-0 w-8 h-8 rounded-lg bg-white flex items-center justify-center mt-0.5">
                                <i data-lucide="zap" class="w-4 h-4 text-[#7A7A7A]"></i>
                            </div>
                            <div>
                                <p class="text-sm font-semibold text-[#0D1B23]">Instant Transfers</p>
                                <p class="text-xs text-[#7A7A7A]">Send money in seconds, not days</p>
                            </div>
                        </div>
                        <div class="flex items-start space-x-3">
                            <div class="flex-shrink-0 w-8 h-8 rounded-lg bg-white flex items-center justify-center mt-0.5">
                                <i data-lucide="shield-check" class="w-4 h-4 text-primary-500"></i>
                            </div>
                            <div>
                                <p class="text-sm font-semibold text-[#0D1B23]">Fraud Protection</p>
                                <p class="text-xs text-[#7A7A7A]">24/7 monitoring keeps you safe</p>
                            </div>
                        </div>
                        <div class="flex items-start space-x-3">
                            <div class="flex-shrink-0 w-8 h-8 rounded-lg bg-white flex items-center justify-center mt-0.5">
                                <i data-lucide="headphones" class="w-4 h-4 text-[#7A7A7A]"></i>
                            </div>
                            <div>
                                <p class="text-sm font-semibold text-[#0D1B23]">Expert Support</p>
                                <p class="text-xs text-[#7A7A7A]">Get help whenever you need it</p>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Right Side - Registration Form -->
                <div class="w-full lg:col-span-3" x-data="{ showPassword: false, showPasswordConfirm: false }">
                    <!-- Mobile Logo -->
                    <div class="lg:hidden text-center mb-8">
                        <img src="<?= $web_url ?>/admin/assets/images/logo/<?= htmlspecialchars($page['image']) ?>"
                             alt="<?= $pageTitle ?>"
                             class="h-10 w-auto mx-auto">
                    </div>

                    <div class="auth-card rounded-xl p-6 md:p-8 space-y-6">

                        <div class="space-y-2">
                            <h2 class="text-2xl font-semibold text-[#0D1B23]">Create Account</h2>
                            <p class="text-sm text-[#7A7A7A]">Please enter your information to build your account.</p>
                        </div>

                        <?php if (isset($msg1)) echo $msg1; ?>

                        <!-- FIXED: removed action attribute so form posts to itself -->
                        <form method="post" class="space-y-5">

                            <!-- First Name & Last Name -->
                            <div class="grid md:grid-cols-2 gap-4">
                                <div class="space-y-2">
                                    <label for="firstname" class="block text-xs font-semibold text-[#4A4A4A]">
                                        First Name <span class="text-[#D55672]">*</span>
                                    </label>
                                    <input
                                        id="firstname"
                                        type="text"
                                        name="firstname"
                                        required
                                        placeholder="John"
                                        class="auth-input w-full px-4 py-3 rounded-xl text-sm font-medium focus:ring-0 transition-all"
                                    />
                                </div>
                                <div class="space-y-2">
                                    <label for="lastname" class="block text-xs font-semibold text-[#4A4A4A]">
                                        Last Name <span class="text-[#D55672]">*</span>
                                    </label>
                                    <input
                                        id="lastname"
                                        type="text"
                                        name="lastname"
                                        required
                                        placeholder="Doe"
                                        class="auth-input w-full px-4 py-3 rounded-xl text-sm font-medium focus:ring-0 transition-all"
                                    />
                                </div>
                            </div>

                            <!-- Email -->
                            <div class="space-y-2">
                                <label for="email" class="block text-xs font-semibold text-[#4A4A4A]">
                                    Email Address <span class="text-[#D55672]">*</span>
                                </label>
                                <div class="relative">
                                    <div class="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none">
                                        <i data-lucide="mail" class="w-5 h-5 text-[#7A7A7A]"></i>
                                    </div>
                                    <input
                                        id="email"
                                        type="email"
                                        name="acct_email"
                                        required
                                        placeholder="john.doe@email.com"
                                        class="auth-input w-full pl-12 pr-4 py-3 rounded-xl text-sm font-medium focus:ring-0 transition-all"
                                    />
                                </div>
                            </div>

                            <!-- Phone -->
                            <div class="space-y-2">
                                <label for="phone" class="block text-xs font-semibold text-[#4A4A4A]">
                                    Phone Number <span class="text-[#D55672]">*</span>
                                </label>
                                <div class="relative">
                                    <input
                                        id="phone"
                                        type="tel"
                                        name="phoneNumber"
                                        required
                                        placeholder="+1 234 567 8900"
                                        class="auth-input w-full px-4 py-3 rounded-xl text-sm font-medium focus:ring-0 transition-all"
                                    />
                                </div>
                                <p id="phone-error" class="text-xs text-[#D55672] mt-1 hidden"></p>
                                <p class="text-xs text-[#7A7A7A]">Enter your phone number with country code</p>
                            </div>

                            <!-- Date of Birth & Gender -->
                            <div class="grid md:grid-cols-2 gap-4">
                                <div class="space-y-2">
                                    <label for="acct_dob" class="block text-xs font-semibold text-[#4A4A4A]">
                                        Date of Birth <span class="text-[#D55672]">*</span>
                                    </label>
                                    <div class="relative">
                                        <div class="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none">
                                            <i data-lucide="calendar" class="w-5 h-5 text-[#7A7A7A]"></i>
                                        </div>
                                        <input
                                            id="acct_dob"
                                            type="date"
                                            name="acct_dob"
                                            required
                                            class="auth-input w-full pl-12 pr-4 py-3 rounded-xl text-sm font-medium focus:ring-0 transition-all"
                                        />
                                    </div>
                                </div>
                                <div class="space-y-2">
                                    <label for="acct_gender" class="block text-xs font-semibold text-[#4A4A4A]">
                                        Gender <span class="text-[#D55672]">*</span>
                                    </label>
                                    <div class="relative">
                                        <select
                                            id="acct_gender"
                                            name="acct_gender"
                                            required
                                            class="auth-input w-full px-4 py-3 rounded-xl text-sm font-medium focus:ring-0 transition-all appearance-none cursor-pointer"
                                        >
                                            <option value="" disabled selected>Select Gender</option>
                                            <option value="Male">Male</option>
                                            <option value="Female">Female</option>
                                        </select>
                                        <div class="absolute inset-y-0 right-0 pr-4 flex items-center pointer-events-none">
                                            <i data-lucide="chevron-down" class="w-5 h-5 text-[#7A7A7A]"></i>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <!-- Home Address -->
                            <div class="space-y-2">
                                <label for="address" class="block text-xs font-semibold text-[#4A4A4A]">
                                    Home Address <span class="text-[#D55672]">*</span>
                                </label>
                                <div class="relative">
                                    <div class="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none">
                                        <i data-lucide="home" class="w-5 h-5 text-[#7A7A7A]"></i>
                                    </div>
                                    <input
                                        id="address"
                                        type="text"
                                        name="address"
                                        required
                                        placeholder="123 Main Street"
                                        class="auth-input w-full pl-12 pr-4 py-3 rounded-xl text-sm font-medium focus:ring-0 transition-all"
                                    />
                                </div>
                            </div>

                            <!-- State & Zipcode -->
                            <div class="grid md:grid-cols-2 gap-4">
                                <div class="space-y-2">
                                    <label for="state" class="block text-xs font-semibold text-[#4A4A4A]">
                                        State <span class="text-[#D55672]">*</span>
                                    </label>
                                    <input
                                        id="state"
                                        type="text"
                                        name="state"
                                        required
                                        placeholder="California"
                                        class="auth-input w-full px-4 py-3 rounded-xl text-sm font-medium focus:ring-0 transition-all"
                                    />
                                </div>
                                <div class="space-y-2">
                                    <label for="zipcode" class="block text-xs font-semibold text-[#4A4A4A]">
                                        Zipcode / Postal Code <span class="text-[#D55672]">*</span>
                                    </label>
                                    <input
                                        id="zipcode"
                                        type="text"
                                        inputmode="numeric"
                                        name="zipcode"
                                        required
                                        pattern="[0-9]+"
                                        minlength="4"
                                        maxlength="6"
                                        autocomplete="off"
                                        placeholder="100001"
                                        class="auth-input w-full px-4 py-3 rounded-xl text-sm font-medium focus:ring-0 transition-all"
                                    />
                                </div>
                            </div>

                            <!-- Country -->
                            <div class="space-y-2">
                                <label for="country" class="block text-xs font-semibold text-[#4A4A4A]">
                                    Country <span class="text-[#D55672]">*</span>
                                </label>
                                <div class="relative">
                                    <div class="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none z-10">
                                        <i data-lucide="map-pin" class="w-5 h-5 text-[#7A7A7A]"></i>
                                    </div>
                                    <select
                                        id="country"
                                        name="country"
                                        required
                                        class="auth-input w-full pl-12 pr-4 py-3 rounded-xl text-sm font-medium focus:ring-0 transition-all appearance-none cursor-pointer"
                                    >
                                        <option value="" selected disabled>Choose Country</option>
                                        <option value="Afghanistan">Afghanistan</option>
                                        <option value="Albania">Albania</option>
                                        <option value="Algeria">Algeria</option>
                                        <option value="American Samoa">American Samoa</option>
                                        <option value="Andorra">Andorra</option>
                                        <option value="Angola">Angola</option>
                                        <option value="Anguilla">Anguilla</option>
                                        <option value="Antigua & Barbuda">Antigua &amp; Barbuda</option>
                                        <option value="Argentina">Argentina</option>
                                        <option value="Armenia">Armenia</option>
                                        <option value="Aruba">Aruba</option>
                                        <option value="Australia">Australia</option>
                                        <option value="Austria">Austria</option>
                                        <option value="Azerbaijan">Azerbaijan</option>
                                        <option value="Bahamas">Bahamas</option>
                                        <option value="Bahrain">Bahrain</option>
                                        <option value="Bangladesh">Bangladesh</option>
                                        <option value="Barbados">Barbados</option>
                                        <option value="Belarus">Belarus</option>
                                        <option value="Belgium">Belgium</option>
                                        <option value="Belize">Belize</option>
                                        <option value="Benin">Benin</option>
                                        <option value="Bermuda">Bermuda</option>
                                        <option value="Bhutan">Bhutan</option>
                                        <option value="Bolivia">Bolivia</option>
                                        <option value="Bosnia & Herzegovina">Bosnia &amp; Herzegovina</option>
                                        <option value="Botswana">Botswana</option>
                                        <option value="Brazil">Brazil</option>
                                        <option value="Brunei">Brunei</option>
                                        <option value="Bulgaria">Bulgaria</option>
                                        <option value="Burkina Faso">Burkina Faso</option>
                                        <option value="Burundi">Burundi</option>
                                        <option value="Cambodia">Cambodia</option>
                                        <option value="Cameroon">Cameroon</option>
                                        <option value="Canada">Canada</option>
                                        <option value="Cape Verde">Cape Verde</option>
                                        <option value="Cayman Islands">Cayman Islands</option>
                                        <option value="Central African Republic">Central African Republic</option>
                                        <option value="Chad">Chad</option>
                                        <option value="Chile">Chile</option>
                                        <option value="China">China</option>
                                        <option value="Colombia">Colombia</option>
                                        <option value="Comoros">Comoros</option>
                                        <option value="Congo">Congo</option>
                                        <option value="Costa Rica">Costa Rica</option>
                                        <option value="Cote D'Ivoire">Cote D'Ivoire</option>
                                        <option value="Croatia">Croatia</option>
                                        <option value="Cuba">Cuba</option>
                                        <option value="Curacao">Curacao</option>
                                        <option value="Cyprus">Cyprus</option>
                                        <option value="Czech Republic">Czech Republic</option>
                                        <option value="Denmark">Denmark</option>
                                        <option value="Djibouti">Djibouti</option>
                                        <option value="Dominica">Dominica</option>
                                        <option value="Dominican Republic">Dominican Republic</option>
                                        <option value="Ecuador">Ecuador</option>
                                        <option value="Egypt">Egypt</option>
                                        <option value="El Salvador">El Salvador</option>
                                        <option value="Equatorial Guinea">Equatorial Guinea</option>
                                        <option value="Eritrea">Eritrea</option>
                                        <option value="Estonia">Estonia</option>
                                        <option value="Ethiopia">Ethiopia</option>
                                        <option value="Fiji">Fiji</option>
                                        <option value="Finland">Finland</option>
                                        <option value="France">France</option>
                                        <option value="Gabon">Gabon</option>
                                        <option value="Gambia">Gambia</option>
                                        <option value="Georgia">Georgia</option>
                                        <option value="Germany">Germany</option>
                                        <option value="Ghana">Ghana</option>
                                        <option value="Greece">Greece</option>
                                        <option value="Grenada">Grenada</option>
                                        <option value="Guatemala">Guatemala</option>
                                        <option value="Guinea">Guinea</option>
                                        <option value="Guyana">Guyana</option>
                                        <option value="Haiti">Haiti</option>
                                        <option value="Honduras">Honduras</option>
                                        <option value="Hong Kong">Hong Kong</option>
                                        <option value="Hungary">Hungary</option>
                                        <option value="Iceland">Iceland</option>
                                        <option value="India">India</option>
                                        <option value="Indonesia">Indonesia</option>
                                        <option value="Iran">Iran</option>
                                        <option value="Iraq">Iraq</option>
                                        <option value="Ireland">Ireland</option>
                                        <option value="Israel">Israel</option>
                                        <option value="Italy">Italy</option>
                                        <option value="Jamaica">Jamaica</option>
                                        <option value="Japan">Japan</option>
                                        <option value="Jordan">Jordan</option>
                                        <option value="Kazakhstan">Kazakhstan</option>
                                        <option value="Kenya">Kenya</option>
                                        <option value="Kuwait">Kuwait</option>
                                        <option value="Kyrgyzstan">Kyrgyzstan</option>
                                        <option value="Laos">Laos</option>
                                        <option value="Latvia">Latvia</option>
                                        <option value="Lebanon">Lebanon</option>
                                        <option value="Lesotho">Lesotho</option>
                                        <option value="Liberia">Liberia</option>
                                        <option value="Libya">Libya</option>
                                        <option value="Liechtenstein">Liechtenstein</option>
                                        <option value="Lithuania">Lithuania</option>
                                        <option value="Luxembourg">Luxembourg</option>
                                        <option value="Madagascar">Madagascar</option>
                                        <option value="Malawi">Malawi</option>
                                        <option value="Malaysia">Malaysia</option>
                                        <option value="Maldives">Maldives</option>
                                        <option value="Mali">Mali</option>
                                        <option value="Malta">Malta</option>
                                        <option value="Mauritania">Mauritania</option>
                                        <option value="Mauritius">Mauritius</option>
                                        <option value="Mexico">Mexico</option>
                                        <option value="Moldova">Moldova</option>
                                        <option value="Monaco">Monaco</option>
                                        <option value="Mongolia">Mongolia</option>
                                        <option value="Montenegro">Montenegro</option>
                                        <option value="Morocco">Morocco</option>
                                        <option value="Mozambique">Mozambique</option>
                                        <option value="Myanmar">Myanmar</option>
                                        <option value="Namibia">Namibia</option>
                                        <option value="Nepal">Nepal</option>
                                        <option value="Netherlands">Netherlands</option>
                                        <option value="New Zealand">New Zealand</option>
                                        <option value="Nicaragua">Nicaragua</option>
                                        <option value="Niger">Niger</option>
                                        <option value="Nigeria">Nigeria</option>
                                        <option value="Norway">Norway</option>
                                        <option value="Oman">Oman</option>
                                        <option value="Pakistan">Pakistan</option>
                                        <option value="Palestine">Palestine</option>
                                        <option value="Panama">Panama</option>
                                        <option value="Papua New Guinea">Papua New Guinea</option>
                                        <option value="Paraguay">Paraguay</option>
                                        <option value="Peru">Peru</option>
                                        <option value="Philippines">Philippines</option>
                                        <option value="Poland">Poland</option>
                                        <option value="Portugal">Portugal</option>
                                        <option value="Puerto Rico">Puerto Rico</option>
                                        <option value="Qatar">Qatar</option>
                                        <option value="Romania">Romania</option>
                                        <option value="Russia">Russia</option>
                                        <option value="Rwanda">Rwanda</option>
                                        <option value="Saudi Arabia">Saudi Arabia</option>
                                        <option value="Senegal">Senegal</option>
                                        <option value="Serbia">Serbia</option>
                                        <option value="Seychelles">Seychelles</option>
                                        <option value="Sierra Leone">Sierra Leone</option>
                                        <option value="Singapore">Singapore</option>
                                        <option value="Slovakia">Slovakia</option>
                                        <option value="Slovenia">Slovenia</option>
                                        <option value="Somalia">Somalia</option>
                                        <option value="South Africa">South Africa</option>
                                        <option value="South Korea">South Korea</option>
                                        <option value="Spain">Spain</option>
                                        <option value="Sri Lanka">Sri Lanka</option>
                                        <option value="Sudan">Sudan</option>
                                        <option value="Suriname">Suriname</option>
                                        <option value="Sweden">Sweden</option>
                                        <option value="Switzerland">Switzerland</option>
                                        <option value="Syria">Syria</option>
                                        <option value="Taiwan">Taiwan</option>
                                        <option value="Tajikistan">Tajikistan</option>
                                        <option value="Tanzania">Tanzania</option>
                                        <option value="Thailand">Thailand</option>
                                        <option value="Togo">Togo</option>
                                        <option value="Trinidad & Tobago">Trinidad &amp; Tobago</option>
                                        <option value="Tunisia">Tunisia</option>
                                        <option value="Turkey">Turkey</option>
                                        <option value="Turkmenistan">Turkmenistan</option>
                                        <option value="Uganda">Uganda</option>
                                        <option value="Ukraine">Ukraine</option>
                                        <option value="United Arab Emirates">United Arab Emirates</option>
                                        <option value="United Kingdom">United Kingdom</option>
                                        <option value="United States of America">United States of America</option>
                                        <option value="Uruguay">Uruguay</option>
                                        <option value="Uzbekistan">Uzbekistan</option>
                                        <option value="Venezuela">Venezuela</option>
                                        <option value="Vietnam">Vietnam</option>
                                        <option value="Yemen">Yemen</option>
                                        <option value="Zambia">Zambia</option>
                                        <option value="Zimbabwe">Zimbabwe</option>
                                    </select>
                                    <div class="absolute inset-y-0 right-0 pr-4 flex items-center pointer-events-none">
                                        <i data-lucide="chevron-down" class="w-5 h-5 text-[#7A7A7A]"></i>
                                    </div>
                                </div>
                            </div>

                            <!-- Account Type & Currency -->
                            <div class="grid md:grid-cols-2 gap-4">
                                <div class="space-y-2">
                                    <label for="accounttype" class="block text-xs font-semibold text-[#4A4A4A]">
                                        Account Type <span class="text-[#D55672]">*</span>
                                    </label>
                                    <div class="relative">
                                        <select
                                            id="accounttype"
                                            name="acct_type"
                                            required
                                            class="auth-input w-full px-4 py-3 rounded-xl text-sm font-medium focus:ring-0 transition-all appearance-none cursor-pointer"
                                        >
                                            <option value="">Select Account Type</option>
                                            <option value="Savings">Savings Account</option>
                                            <option value="Current">Current Account</option>
                                            <option value="Checking">Checking Account</option>
                                            <option value="Fixed Deposit">Fixed Deposit</option>
                                            <option value="Non Resident">Non Resident Account</option>
                                            <option value="Joint Account">Joint Account</option>
                                        </select>
                                        <div class="absolute inset-y-0 right-0 pr-4 flex items-center pointer-events-none">
                                            <i data-lucide="chevron-down" class="w-5 h-5 text-[#7A7A7A]"></i>
                                        </div>
                                    </div>
                                </div>
                                <div class="space-y-2">
                                    <label for="currency" class="block text-xs font-semibold text-[#4A4A4A]">
                                        Currency <span class="text-[#D55672]">*</span>
                                    </label>
                                    <div class="relative">
                                        <select
                                            id="currency"
                                            name="acct_currency"
                                            required
                                            class="auth-input w-full px-4 py-3 rounded-xl text-sm font-medium focus:ring-0 transition-all appearance-none cursor-pointer"
                                        >
                                            <option value="">Choose Currency</option>
                                            <option value="$" selected>United States Dollars (USD)</option>
                                            <option value="€">Euro (EUR)</option>
                                            <option value="£">British Pounds (GBP)</option>
                                            <option value="¥">Japanese Yen (JPY)</option>
                                            <option value="C$">Canadian Dollar (CAD)</option>
                                            <option value="A$">Australian Dollar (AUD)</option>
                                            <option value="CHF">Swiss Franc (CHF)</option>
                                            <option value="₹">Indian Rupee (INR)</option>
                                            <option value="R$">Brazilian Real (BRL)</option>
                                            <option value="R">South African Rand (ZAR)</option>
                                            <option value="S$">Singapore Dollar (SGD)</option>
                                            <option value="HK$">Hong Kong Dollar (HKD)</option>
                                            <option value="NZ$">New Zealand Dollar (NZD)</option>
                                            <option value="₩">South Korean Won (KRW)</option>
                                            <option value="₺">Turkish Lira (TRY)</option>
                                            <option value="₽">Russian Ruble (RUB)</option>
                                            <option value="د.إ">UAE Dirham (AED)</option>
                                            <option value="﷼">Saudi Riyal (SAR)</option>
                                            <option value="zł">Polish Zloty (PLN)</option>
                                            <option value="฿">Thai Baht (THB)</option>
                                            <option value="₦">Nigerian Naira (NGN)</option>
                                            <option value="KSh">Kenyan Shilling (KES)</option>
                                        </select>
                                        <div class="absolute inset-y-0 right-0 pr-4 flex items-center pointer-events-none">
                                            <i data-lucide="chevron-down" class="w-5 h-5 text-[#7A7A7A]"></i>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <!-- Transaction PIN -->
                            <div class="space-y-2">
                                <label for="pin" class="block text-xs font-semibold text-[#4A4A4A]">
                                    4-Digit Transaction PIN <span class="text-[#D55672]">*</span>
                                </label>
                                <div class="relative">
                                    <div class="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none">
                                        <i data-lucide="hash" class="w-5 h-5 text-[#7A7A7A]"></i>
                                    </div>
                                    <input
                                        id="pin"
                                        type="password"
                                        name="acct_pin"
                                        required
                                        maxlength="4"
                                        pattern="[0-9]{4}"
                                        inputmode="numeric"
                                        autocomplete="off"
                                        placeholder="••••"
                                        class="auth-input w-full pl-12 pr-4 py-3 rounded-xl text-sm font-medium focus:ring-0 transition-all"
                                    />
                                </div>
                                <p class="text-xs text-[#7A7A7A]">Used to authorize transactions</p>
                            </div>

                            <!-- Password Fields -->
                            <div class="grid md:grid-cols-2 gap-4">
                                <div class="space-y-2">
                                    <label for="password" class="block text-xs font-semibold text-[#4A4A4A]">
                                        Password <span class="text-[#D55672]">*</span>
                                    </label>
                                    <div class="relative">
                                        <div class="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none">
                                            <i data-lucide="lock" class="w-5 h-5 text-[#7A7A7A]"></i>
                                        </div>
                                        <input
                                            id="password"
                                            :type="showPassword ? 'text' : 'password'"
                                            name="acct_password"
                                            required
                                            maxlength="20"
                                            placeholder="••••••••••"
                                            class="auth-input w-full pl-12 pr-12 py-3 rounded-xl text-sm font-medium focus:ring-0 transition-all"
                                        />
                                        <button
                                            type="button"
                                            @click="showPassword = !showPassword"
                                            class="absolute inset-y-0 right-0 pr-4 flex items-center text-[#7A7A7A] hover:text-[#4A4A4A] transition-colors"
                                        >
                                            <i :data-lucide="showPassword ? 'eye-off' : 'eye'" class="w-5 h-5"></i>
                                        </button>
                                    </div>
                                </div>
                                <div class="space-y-2">
                                    <label for="password_confirmation" class="block text-xs font-semibold text-[#4A4A4A]">
                                        Confirm Password <span class="text-[#D55672]">*</span>
                                    </label>
                                    <div class="relative">
                                        <div class="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none">
                                            <i data-lucide="lock" class="w-5 h-5 text-[#7A7A7A]"></i>
                                        </div>
                                        <input
                                            id="password_confirmation"
                                            :type="showPasswordConfirm ? 'text' : 'password'"
                                            name="confirmPassword"
                                            required
                                            maxlength="20"
                                            placeholder="••••••••••"
                                            class="auth-input w-full pl-12 pr-12 py-3 rounded-xl text-sm font-medium focus:ring-0 transition-all"
                                        />
                                        <button
                                            type="button"
                                            @click="showPasswordConfirm = !showPasswordConfirm"
                                            class="absolute inset-y-0 right-0 pr-4 flex items-center text-[#7A7A7A] hover:text-[#4A4A4A] transition-colors"
                                        >
                                            <i :data-lucide="showPasswordConfirm ? 'eye-off' : 'eye'" class="w-5 h-5"></i>
                                        </button>
                                    </div>
                                </div>
                            </div>

                            <!-- Terms Checkbox -->
                            <div class="flex items-start space-x-3">
                                <input
                                    type="checkbox"
                                    id="terms"
                                    name="terms"
                                    required
                                    class="mt-1 w-4 h-4 rounded border-[#C8D1D1] bg-white text-primary-500 focus:ring-primary-500 focus:ring-offset-0 focus:ring-2 cursor-pointer"
                                />
                                <label for="terms" class="text-sm text-[#7A7A7A] cursor-pointer select-none">
                                    I agree to <?= $pageTitle ?>'s
                                    <a href="/terms" class="auth-link">Terms &amp; Conditions</a> and
                                    <a href="/privacy" class="auth-link">Privacy Policy</a>
                                </label>
                            </div>

                            <!-- Submit Button -->
                            <button
                                type="submit"
                                name="regSubmit"
                                class="auth-button w-full py-3.5 rounded-xl font-semibold text-white text-sm flex items-center justify-center space-x-2 group"
                            >
                                <span>Create My Account</span>
                                <i data-lucide="arrow-right" class="w-4 h-4 group-hover:translate-x-1 transition-transform"></i>
                            </button>

                            <!-- Divider -->
                            <div class="relative">
                                <div class="absolute inset-0 flex items-center">
                                    <div class="w-full border-t border-[#E0E5E5]"></div>
                                </div>
                                <div class="relative flex justify-center text-sm">
                                    <span class="px-4 bg-white text-[#7A7A7A]">Already have an account?</span>
                                </div>
                            </div>

                            <a
                                href="./login.php"
                                class="block w-full py-3.5 rounded-xl font-semibold text-sm text-center border border-[#E0E5E5] hover:border-primary-500 hover:bg-primary-50 text-[#0D1B23] hover:text-primary-600 transition-all"
                            >
                                <div class="flex items-center justify-center space-x-2">
                                    <i data-lucide="log-in" class="w-4 h-4"></i>
                                    <span>Sign In</span>
                                </div>
                            </a>
                        </form>

                    </div>
                </div>
            </div>
        </div>

    </div>

    <!-- Scripts -->
    <script src="https://code.jquery.com/jquery-3.6.1.min.js"></script>
    <script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

    <script>
        document.addEventListener('DOMContentLoaded', () => {
            if (typeof lucide !== 'undefined') {
                lucide.createIcons();
            }
        });

        document.addEventListener('alpine:initialized', () => {
            if (typeof lucide !== 'undefined') {
                lucide.createIcons();
            }
        });
    </script>

    <script src="https://cdn.jsdelivr.net/npm/intl-tel-input@19.5.6/build/js/intlTelInput.min.js"></script>

    <script>
        const phoneInput = document.querySelector("#phone");
        const phoneError = document.querySelector("#phone-error");
        const form = phoneInput.closest('form');

        const iti = window.intlTelInput(phoneInput, {
            initialCountry: "us",
            preferredCountries: ["us", "gb", "ng", "ca", "au"],
            separateDialCode: true,
            utilsScript: "https://cdn.jsdelivr.net/npm/intl-tel-input@19.5.6/build/js/utils.js",
            autoPlaceholder: "aggressive",
        });

        phoneInput.addEventListener('blur', function() { validatePhone(); });
        phoneInput.addEventListener('countrychange', function() { validatePhone(); });

        function validatePhone() {
            phoneError.classList.add('hidden');
            if (phoneInput.value.trim()) {
                if (iti.isValidNumber()) {
                    phoneInput.classList.remove('border-red-500');
                    phoneInput.classList.add('border-green-500');
                    return true;
                } else {
                    phoneInput.classList.remove('border-green-500');
                    phoneInput.classList.add('border-red-500');
                    const errorCode = iti.getValidationError();
                    const errorMessages = {
                        0: 'Invalid phone number',
                        1: 'Invalid country code',
                        2: 'Phone number too short',
                        3: 'Phone number too long',
                        4: 'Invalid phone number',
                    };
                    phoneError.textContent = errorMessages[errorCode] || 'Invalid phone number format';
                    phoneError.classList.remove('hidden');
                    return false;
                }
            }
            return true;
        }

        form.addEventListener('submit', function(e) {
            if (phoneInput.value.trim()) {
                if (!iti.isValidNumber()) {
                    e.preventDefault();
                    validatePhone();
                    phoneInput.focus();
                    return false;
                }
                phoneInput.value = iti.getNumber();
            }
        });
    </script>

    <div>
    <style>
    .gtranslate_wrapper {
        border-radius: 8px !important;
        padding: 4px 6px !important;
        border: 1px solid rgba(51, 65, 85, 0.6) !important;
        box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
        max-width: 160px !important;
        background: rgba(15, 23, 42, 0.95) !important;
        backdrop-filter: blur(8px) !important;
        position: fixed !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    @media (max-width: 767px) {
        .gtranslate_wrapper { bottom: 52px !important; left: 12px !important; z-index: 45 !important; }
    }
    @media (min-width: 768px) {
        .gtranslate_wrapper { bottom: 20px !important; left: 20px !important; z-index: 45 !important; }
    }
    .gtranslate_wrapper select { font-size: 10px !important; padding: 2px 4px !important; height: auto !important; background: transparent !important; color: #cbd5e1 !important; border: none !important; }
    .gtranslate_wrapper img { width: 14px !important; height: auto !important; margin-right: 4px !important; }
    .gtranslate_wrapper * { font-size: 11px !important; line-height: 1.3 !important; }
    </style>
    <div class="gtranslate_wrapper"></div>
    <script>
        window.gtranslateSettings = {
            default_language: "en",
            alt_flags: {"en": "usa"},
            wrapper_selector: ".gtranslate_wrapper",
            flag_style: "3d",
        };
    </script>
    <script src="https://cdn.gtranslate.net/widgets/latest/float.js" defer></script>
    </div>

</body>
</html>