<?php

$sensfrxImagePage = plugins_url() . '/sensfrx-fraud-prevention-for-woocommerce/admin/image';

function sensfrx_is_admin_email($email) {

    $admins = get_users(['role' => 'administrator']);

    foreach ($admins as $admin) {

        if (strtolower($admin->user_email) === strtolower($email)) {

            return true;

        }

    }

    return false;

}

$options = get_option('sensfrx_options', SensFRX::default_options());

require_once(SENSFRX_DIR . 'sensfrx-php-sdk/SensFRX/autoload.php');

$obj = new SensFRX\SensFRX([

	'property_id' => $options['sensfrx_property_id'],

	'property_secret' => $options['sensfrx_property_secret']

]);

$user = wp_get_current_user();

// Check if user is new (no credentials saved)

$is_new_user = empty($options['sensfrx_property_id']) || empty($options['sensfrx_property_secret']);

?>

<style>

/* Hide WordPress admin elements for full-screen takeover ONLY when onboarding wrapper exists */

.sensfrxOnboaredingwrap ~ #wpadminbar,

.sensfrxOnboaredingwrap ~ * #wpadminbar,

body:has(.sensfrxOnboaredingwrap) #wpadminbar,

body:has(.sensfrxOnboaredingwrap) #adminmenumain,

body:has(.sensfrxOnboaredingwrap) #adminmenuback,

body:has(.sensfrxOnboaredingwrap) #adminmenuwrap,

body:has(.sensfrxOnboaredingwrap) .update-nag {

	display: none !important;

}

body:has(.sensfrxOnboaredingwrap) #wpcontent,

body:has(.sensfrxOnboaredingwrap) #wpfooter {

	margin-left: 0 !important;

	padding-left: 0 !important;

}

</style>

<script>

// Fallback for browsers that don't support :has()

document.addEventListener('DOMContentLoaded', function() {

	if (document.querySelector('.sensfrxOnboaredingwrap')) {

		document.getElementById('wpadminbar')?.style.setProperty('display', 'none', 'important');

		document.getElementById('adminmenumain')?.style.setProperty('display', 'none', 'important');

		document.getElementById('adminmenuback')?.style.setProperty('display', 'none', 'important');

		document.getElementById('adminmenuwrap')?.style.setProperty('display', 'none', 'important');

		var updateNags = document.querySelectorAll('.update-nag');

		updateNags.forEach(function(el) { el.style.setProperty('display', 'none', 'important'); });



		var wpcontent = document.getElementById('wpcontent');

		if (wpcontent) {

			wpcontent.style.setProperty('margin-left', '0', 'important');

			wpcontent.style.setProperty('padding-left', '0', 'important');

		}

		var wpfooter = document.getElementById('wpfooter');

		if (wpfooter) {

			wpfooter.style.setProperty('margin-left', '0', 'important');

			wpfooter.style.setProperty('padding-left', '0', 'important');

		}

	}

});

</script>

<!-- Full-screen wrapper to hide WordPress admin UI -->

<div class="sensfrxOnboaredingwrap">

    <div class="onboarding-container">

    <!-- Left Section: Form Content -->

    <div class="content-section">

        <div class="logo-container">

            <img src="https://sensfrx.ai/assets/image/sensfrx-new-logo.png" alt="Sensfrx Logo" class="logo">

        </div>



        <!-- Step 1: Email Entry -->

        <div id="step-1" class="step-form">

            <h1 class="main-heading">Stop Fraud. Protect Revenue.</h1>

            <p class="subheading">Enterprise fraud protection for WooCommerce. One-click setup, instant results.</p>



            <!-- Info Box -->

            <div class="info-box">

                <svg class="info-icon" width="20" height="20" viewBox="0 0 20 20" fill="none">

                    <circle cx="10" cy="10" r="9" stroke="currentColor" stroke-width="2"/>

                    <path d="M10 6V10M10 14H10.01" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>

                </svg>

                <span>New or returning user? Just enter your email to get started.</span>

            </div>



            <!-- Email Form - WordPress Integration -->

            <form id="step-1-form" class="email-form" method="post">

                <span class="error-message-step-1" id="step-1-error" style="display:none;"></span>

                <input type="email" name="sensfrx_email" id="sensfrx_email" placeholder="Enter your work email" class="email-input" required>

                <button type="submit" id="sensfrxOnboardinverify_email" name="sensfrxOnboardinverify_email" class="continue-button">

                    <span class="loader" style="display: none;">

                        <img src="<?php echo esc_html( $sensfrxImagePage ).'/loader.png'; ?>" width="20">

                    </span>

                    <span class="button-text">Continue</span>

                    <svg width="20" height="20" viewBox="0 0 20 20" fill="none">

                        <path d="M7.5 15L12.5 10L7.5 5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>

                    </svg>

                </button>

            </form>



            <p class="form-footer">

                We'll send a secure link to your email. Works for both new signups and existing accounts.

            </p>

        </div>

        <!-- Step 2: OTP Verification -->

        <form id="step-2" class="step-form w-100" style="display: none;">

            <div class="w-100">

                <div class="mb-3 mt-3">

                    <div class="rounded-circle bg-primary bg-opacity-25 d-inline-flex align-items-center justify-content-center"

                        style="">

                        <img src="<?php echo esc_url( $sensfrxImagePage ).'/ic_email.svg'; ?>"

                            width="80">

                    </div>

                </div>

                <h5 class="sensheadingwrapper">Check your email</h5>

                <p class="senssubheadingwrapper">We have sent a 6-character verification code to<br><strong

                        id="display-email">your-email@example.com</strong></p>



                <div class="d-flex justify-content-center gap-3 mb-4">

                    <input type="text" class="form-control text-center otp-input" maxlength="1">

                    <input type="text" class="form-control text-center otp-input" maxlength="1">

                    <input type="text" class="form-control text-center otp-input" maxlength="1">

                    <input type="text" class="form-control text-center otp-input" maxlength="1">

                    <input type="text" class="form-control text-center otp-input" maxlength="1">

                    <input type="text" class="form-control text-center otp-input" maxlength="1">

                </div>



                <p class="error-message" style="display:none;">

                    <img src="<?php echo esc_url( $sensfrxImagePage ).'/attencion.png'; ?>"

                        width="24">

                    Please enter the complete 6-character code

                </p>

                <p class="success-message" style="display:none;">

                    <img src="<?php echo esc_url( $sensfrxImagePage ).'/check-mark.png'; ?>"

                        width="24">

                    Code sent to your email

                </p>



                <button type="submit" class="btn btn-sendverify btn-lg w-100">Verify & Continue</button>



                <div class="text-center mt-3">

                    <button type="button" class="btn btn-link resend-btn p-0">Resend code</button><br>

                    <button type="button"

                        class="btn btn-link text-secondary change-email-btn p-0 align-items-center gap-2">

                        <img

                            src="<?php echo esc_url( $sensfrxImagePage ).'/left-arrow.png'; ?>">

                        Change email

                    </button>

                </div>



                <!-- Discord Community Help Section -->

                <div style="background: #f0f0f1; border-radius: 6px; padding: 12px; margin-top: 20px; text-align: center;">

                    <p style="margin: 0 0 8px 0; font-size: 13px; color: #50575e;">

                        <?php echo esc_html__('Need help? Join our community', 'sensfrx-fraud-prevention-for-woocommerce'); ?>

                    </p>

                    <a href="https://discord.gg/zGBGQdwT4r" target="_blank" rel="noopener"

                       style="display: inline-flex; align-items: center; gap: 8px; color: #5865F2; text-decoration: none; font-weight: 600; font-size: 13px;">

                        <svg width="18" height="18" viewBox="0 0 71 55" fill="none">

                            <path d="M60.1045 4.8978C55.5792 2.8214 50.7265 1.2916 45.6527 0.41542C45.5603 0.39851 45.468 0.440769 45.4204 0.525289C44.7963 1.6353 44.105 3.0834 43.6209 4.2216C38.1637 3.4046 32.7345 3.4046 27.3892 4.2216C26.905 3.0581 26.1886 1.6353 25.5617 0.525289C25.5141 0.443589 25.4218 0.40133 25.3294 0.41542C20.2584 1.2888 15.4057 2.8186 10.8776 4.8978C10.8384 4.9147 10.8048 4.9429 10.7825 4.9795C1.57795 18.7309 -0.943561 32.1443 0.293408 45.3914C0.299005 45.4562 0.335386 45.5182 0.385761 45.5576C6.45866 50.0174 12.3413 52.7249 18.1147 54.5195C18.2071 54.5477 18.305 54.5139 18.3638 54.4378C19.7295 52.5728 20.9469 50.6063 21.9907 48.5383C22.0523 48.4172 21.9935 48.2735 21.8676 48.2256C19.9366 47.4931 18.0979 46.6 16.3292 45.5858C16.1893 45.5041 16.1781 45.304 16.3068 45.2082C16.679 44.9293 17.0513 44.6391 17.4067 44.3461C17.471 44.2926 17.5606 44.2813 17.6362 44.3151C29.2558 49.6202 41.8354 49.6202 53.3179 44.3151C53.3935 44.2785 53.4831 44.2898 53.5502 44.3433C53.9057 44.6363 54.2779 44.9293 54.6529 45.2082C54.7816 45.304 54.7732 45.5041 54.6333 45.5858C52.8646 46.6197 51.0259 47.4931 49.0921 48.2228C48.9662 48.2707 48.9102 48.4172 48.9718 48.5383C50.038 50.6034 51.2554 52.5699 52.5959 54.435C52.6519 54.5139 52.7526 54.5477 52.845 54.5195C58.6464 52.7249 64.529 50.0174 70.6019 45.5576C70.6551 45.5182 70.6887 45.459 70.6943 45.3942C72.1747 30.0791 68.2147 16.7757 60.1968 4.9823C60.1772 4.9429 60.1437 4.9147 60.1045 4.8978ZM23.7259 37.3253C20.2276 37.3253 17.3451 34.1136 17.3451 30.1693C17.3451 26.225 20.1717 23.0133 23.7259 23.0133C27.308 23.0133 30.1626 26.2532 30.1066 30.1693C30.1066 34.1136 27.28 37.3253 23.7259 37.3253ZM47.3178 37.3253C43.8196 37.3253 40.9371 34.1136 40.9371 30.1693C40.9371 26.225 43.7636 23.0133 47.3178 23.0133C50.9 23.0133 53.7545 26.2532 53.6986 30.1693C53.6986 34.1136 50.9 37.3253 47.3178 37.3253Z" fill="#5865F2"/>

                        </svg>

                        <?php echo esc_html__('Join Discord Community', 'sensfrx-fraud-prevention-for-woocommerce'); ?>

                    </a>

                </div>



                <!-- Privacy Footer -->

                <p class="legal-text" style="margin-top: 16px; font-size: 13px; color: #94a3b8; text-align: center; line-height: 1.5;">

                    By continuing, you agree to Sensfrx's data processing for fraud detection.

                    <a href="https://sensfrx.ai/privacy-policy" target="_blank" style="color: #0066ff; text-decoration: none;">Privacy Policy</a> ·

                    <a href="https://sensfrx.ai/trust" target="_blank" style="color: #0066ff; text-decoration: none;">Trust & Security</a>

                </p>

            </div>

        </form>



        <!-- Step 3: Final Confirmation -->

        <form id="step-3" class="step-form" style="display: none;">

            <img class="my-3"

                src="<?php echo esc_url( $sensfrxImagePage ).'/loader.png'; ?>"

                width="30">

            <h2 class="sensheadingwrapper">Setting up your access...</h2>

            <p class="senssubheadingwrapper">Please wait while we configure your API keys</p>

        </form>



        <!-- Step 4: Success Screen -->

        <form id="step-4" class="step-form w-100" style="display: none;">

            <img class="mb-3"

                src="<?php echo esc_url( $sensfrxImagePage ).'/ic_Complete.svg'; ?>"

                width="80">

            <h2 class="sensheadingwrapper">Setup Complete!</h2>

            <p class="senssubheadingwrapper fosize mt-4 mb-5">Redirecting to dashboard in <span id="countdown">3</span> seconds</p>

            <p class="accessgranted mt-5 mb-3">Access Granted</p>

            <p class="senssubheadingwrapper fosize mb-0">Your property credentials have been configured</p>

            <p class="senssubheadingwrapper fosize mb-3">Welcome to Sensfrx.ai (SFX)!</p>



            <a href="" class="btn btn-sendverify btn-lg w-100 text-decoration-none mb-3">Go to Dashboard</a>



            <!-- Discord Community CTA -->

            <div style="background: #f0f0f1; border-radius: 6px; padding: 16px; margin-top: 16px; text-align: center;">

                <p style="margin: 0 0 10px 0; font-size: 14px; font-weight: 600; color: #1d2327;">

                    <?php echo esc_html__('Join Our Community', 'sensfrx-fraud-prevention-for-woocommerce'); ?>

                </p>

                <p style="margin: 0 0 12px 0; font-size: 13px; color: #50575e;">

                    <?php echo esc_html__('Get help, share tips, and connect with other store owners', 'sensfrx-fraud-prevention-for-woocommerce'); ?>

                </p>

                <a href="https://discord.gg/zGBGQdwT4r" target="_blank" rel="noopener"

                   class="btn btn-link"

                   style="display: inline-flex; align-items: center; gap: 8px; background: #5865F2; color: #fff; text-decoration: none; padding: 10px 20px; border-radius: 6px; font-weight: 600; font-size: 14px;">

                    <svg width="20" height="20" viewBox="0 0 71 55" fill="none">

                        <path d="M60.1045 4.8978C55.5792 2.8214 50.7265 1.2916 45.6527 0.41542C45.5603 0.39851 45.468 0.440769 45.4204 0.525289C44.7963 1.6353 44.105 3.0834 43.6209 4.2216C38.1637 3.4046 32.7345 3.4046 27.3892 4.2216C26.905 3.0581 26.1886 1.6353 25.5617 0.525289C25.5141 0.443589 25.4218 0.40133 25.3294 0.41542C20.2584 1.2888 15.4057 2.8186 10.8776 4.8978C10.8384 4.9147 10.8048 4.9429 10.7825 4.9795C1.57795 18.7309 -0.943561 32.1443 0.293408 45.3914C0.299005 45.4562 0.335386 45.5182 0.385761 45.5576C6.45866 50.0174 12.3413 52.7249 18.1147 54.5195C18.2071 54.5477 18.305 54.5139 18.3638 54.4378C19.7295 52.5728 20.9469 50.6063 21.9907 48.5383C22.0523 48.4172 21.9935 48.2735 21.8676 48.2256C19.9366 47.4931 18.0979 46.6 16.3292 45.5858C16.1893 45.5041 16.1781 45.304 16.3068 45.2082C16.679 44.9293 17.0513 44.6391 17.4067 44.3461C17.471 44.2926 17.5606 44.2813 17.6362 44.3151C29.2558 49.6202 41.8354 49.6202 53.3179 44.3151C53.3935 44.2785 53.4831 44.2898 53.5502 44.3433C53.9057 44.6363 54.2779 44.9293 54.6529 45.2082C54.7816 45.304 54.7732 45.5041 54.6333 45.5858C52.8646 46.6197 51.0259 47.4931 49.0921 48.2228C48.9662 48.2707 48.9102 48.4172 48.9718 48.5383C50.038 50.6034 51.2554 52.5699 52.5959 54.435C52.6519 54.5139 52.7526 54.5477 52.845 54.5195C58.6464 52.7249 64.529 50.0174 70.6019 45.5576C70.6551 45.5182 70.6887 45.459 70.6943 45.3942C72.1747 30.0791 68.2147 16.7757 60.1968 4.9823C60.1772 4.9429 60.1437 4.9147 60.1045 4.8978ZM23.7259 37.3253C20.2276 37.3253 17.3451 34.1136 17.3451 30.1693C17.3451 26.225 20.1717 23.0133 23.7259 23.0133C27.308 23.0133 30.1626 26.2532 30.1066 30.1693C30.1066 34.1136 27.28 37.3253 23.7259 37.3253ZM47.3178 37.3253C43.8196 37.3253 40.9371 34.1136 40.9371 30.1693C40.9371 26.225 43.7636 23.0133 47.3178 23.0133C50.9 23.0133 53.7545 26.2532 53.6986 30.1693C53.6986 34.1136 50.9 37.3253 47.3178 37.3253Z" fill="#fff"/>

                    </svg>

                    <?php echo esc_html__('Join Discord Community', 'sensfrx-fraud-prevention-for-woocommerce'); ?>

                </a>

            </div>

        </form>



    </div>



    <!-- Right Section: Visual Content -->

    <div class="visual-section">

        <h2 class="trust-heading">The Choice of Top WooCommerce Merchants</h2>



        <!-- Hero Image -->

        <div class="hero-image-wrapper">

            <img src="<?php echo esc_url( $sensfrxImagePage ).'/hero-business-owner.png'; ?>" alt="Professional business owner" class="hero-image">

        </div>



        <!-- Testimonial Slider -->

        <div class="testimonial-container">

            <div class="testimonial-slider">

                <!-- Testimonial 1 -->

                <div class="testimonial-card active">

                    <div class="rating">

                        <span class="stars">★★★★★</span>

                        <span class="rating-number">5.0</span>

                    </div>

                    <p class="testimonial-text">"Blocked $47K in fraudulent orders in the first month. Setup took literally 2 minutes. Best ROI of any plugin we use."</p>

                    <div class="customer-info">

                        <div class="customer-details">

                            <div class="customer-name">Sarah Chen</div>

                            <div class="customer-business">Fashion E-commerce, $2M/year</div>

                        </div>

                    </div>

                </div>



                <!-- Testimonial 2 -->

                <div class="testimonial-card">

                    <div class="rating">

                        <span class="stars">★★★★★</span>

                        <span class="rating-number">5.0</span>

                    </div>

                    <p class="testimonial-text">"Zero chargebacks since installing. The AI catches patterns we never would have seen. Worth every penny."</p>

                    <div class="customer-info">

                        <div class="customer-details">

                            <div class="customer-name">Mike Patterson</div>

                            <div class="customer-business">Electronics Store, $5M/year</div>

                        </div>

                    </div>

                </div>



                <!-- Testimonial 3 -->

                <div class="testimonial-card">

                    <div class="rating">

                        <span class="stars">★★★★★</span>

                        <span class="rating-number">5.0</span>

                    </div>

                    <p class="testimonial-text">"No false positives blocking real customers. Integrates seamlessly with WooCommerce. Can't imagine running without it."</p>

                    <div class="customer-info">

                        <div class="customer-details">

                            <div class="customer-name">Lisa Rodriguez</div>

                            <div class="customer-business">Home & Garden, $1.5M/year</div>

                        </div>

                    </div>

                </div>

            </div>



            <!-- Slider Dots -->

            <div class="slider-dots">

                <span class="dot active"></span>

                <span class="dot"></span>

                <span class="dot"></span>

            </div>

        </div>



        <!-- Security Badges -->

        <div class="security-badges-right">

            <div class="badge-right">

                <svg class="badge-icon-right" width="16" height="16" viewBox="0 0 16 16" fill="none">

                    <path d="M13 5L6 12L3 9" stroke="#ffffff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>

                </svg>

                <span>SOC 2 Certified</span>

            </div>

            <div class="badge-right">

                <svg class="badge-icon-right" width="16" height="16" viewBox="0 0 16 16" fill="none">

                    <path d="M13 5L6 12L3 9" stroke="#ffffff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>

                </svg>

                <span>GDPR Compliant</span>

            </div>

        </div>

    </div>

</div>



<script>

// Testimonial Slider

let currentSlide = 0;

const slides = document.querySelectorAll('.testimonial-card');

const dots = document.querySelectorAll('.dot');

const totalSlides = slides.length;



function showSlide(index) {

    slides.forEach(slide => slide.classList.remove('active'));

    dots.forEach(dot => dot.classList.remove('active'));



    slides[index].classList.add('active');

    dots[index].classList.add('active');

}



function nextSlide() {

    currentSlide = (currentSlide + 1) % totalSlides;

    showSlide(currentSlide);

}



// Auto-advance every 5 seconds

setInterval(nextSlide, 5000);



// Dot click handlers

dots.forEach((dot, index) => {

    dot.addEventListener('click', () => {

        currentSlide = index;

        showSlide(currentSlide);

    });

});

</script>

    </div> <!-- Close onboarding-container -->

</div> <!-- Close sensfrxOnboaredingwrap - Full screen wrapper -->



    </div>



</div>

