<?php

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

$login_template    = gigneo_option( '_gigneo_ts_template_login' );
$role_enable       = gigneo_option( '_gigneo_ts_registration_role' );
$password_strength = gigneo_option( '_gigneo_ts_password_strength', array( 'length' ) );
$privacy_page_id   = gigneo_option( '_gigneo_ts_template_privacy_policy' );
$terms_page_id     = gigneo_option( '_gigneo_ts_template_terms_and_condition' );

$terms_url     = $terms_page_id ? esc_url( get_permalink( $terms_page_id ) ) : '#';
$privacy_url   = $privacy_page_id ? esc_url( get_permalink( $privacy_page_id ) ) : '#';
$terms_title   = $terms_page_id ? esc_html( get_the_title( $terms_page_id ) ) : esc_html__( 'Terms and Condition', 'gigneo' );
$privacy_title = $privacy_page_id ? esc_html( get_the_title( $privacy_page_id ) ) : esc_html__( 'Privacy Policy', 'gigneo' );
?>
<form id="gn-auth-register" class="gn-auth-form gn-auth-register-form" data-action="gigneo_auth_register">
	<!--Register form multistep step basic-->
	<div id="gn-auth-register-basic" class="gn-auth-register-step">
		<div class="gn-auth-heading-area">
			<h3 class="gn-title"><?php echo esc_html__( 'Get started now', 'gigneo' ); ?></h3>
			<p class="gn-description"><?php echo esc_html__( 'Join a global network of top professionals.', 'gigneo' ); ?></p>
		</div>
		<?php if ( in_array( 'social_auth', gigneo_active_modules(), true ) ) { ?>
			<div class="gn-social-auth gn-social-auth-register">
				<?php do_action( 'gigneo_social_auth_register' ); ?>
			</div>
		<?php } ?>
		<div class="gn-form-fields gn-auth-form-fields">
			<div class="gn-form-field gn-auth-col-half">
				<label for="gn-first-name"><?php echo esc_html__( 'First name', 'gigneo' ); ?></label>
				<input id="gn-first-name" type="text" class="gn-required-field" name="first_name" placeholder="<?php echo esc_html__( 'Enter first name', 'gigneo' ); ?>" />
			</div>
			<div class="gn-form-field gn-auth-col-half">
				<label for="gn-last-name"><?php echo esc_html__( 'Last name', 'gigneo' ); ?></label>
				<input id="gn-last-name" type="text" class="gn-required-field" name="last_name" placeholder="<?php echo esc_html__( 'Enter last name', 'gigneo' ); ?>" />
			</div>
			<div class="gn-form-field">
				<label for="gn-register-email"><?php echo esc_html__( 'Email', 'gigneo' ); ?></label>
				<input id="gn-register-email" type="email" class="gn-required-field" name="email" placeholder="<?php echo esc_html__( 'Enter email address', 'gigneo' ); ?>" />
			</div>
			<div class="gn-form-field">
				<label for="gn-register-password"><?php echo esc_html__( 'Password', 'gigneo' ); ?></label>
				<div class="gn-auth-input-wrapper">
					<input id="gn-register-password" autocomplete="new-password" type="password" class="gn-required-field" name="password" placeholder="<?php echo esc_html__( 'Enter password', 'gigneo' ); ?>" />
					<i class="hi hi-eye-slash gn-password-revealed" aria-hidden="true"></i>
				</div>
				<ul class="gn-password-notice">
					<?php
					$password_strength_list = gigneo_password_strength_options();
					foreach ( $password_strength as $strength ) {
						?>
						<li class="<?php echo esc_attr( $strength ); ?>"><?php echo esc_html( $password_strength_list[ $strength ] ); ?></li>
					<?php } ?>
				</ul>
			</div>
			<div class="gn-form-field">
				<div class="gn-form-field-checkbox">
					<input id="gn-register-term-and-privacy" type="checkbox" class="gn-required-field" name="term_and_privacy" />
					<label for="gn-register-term-and-privacy">
						<?php
						printf(
						// translators: 1. Terms and Condition URL, 2. Terms and Condition Title, 3. Privacy Policy URL, 4. Privacy Policy Title.
							wp_kses_post( __( 'I agree to the <a href="%1$s">%2$s</a> & <a href="%3$s">%4$s</a>', 'gigneo' ) ),
							esc_url( $terms_url ),
							esc_html( $terms_title ),
							esc_url( $privacy_url ),
							esc_html( $privacy_title )
						);
						?>
					</label>
				</div>
			</div>
		</div>
		<div class="gn-auth-actions">
			<button type="button" data-step="gn-auth-register-<?php echo esc_attr( $role_enable ? 'role' : 'username' ); ?>" class="gn-auth-register-continue-btn gn-btn gn-btn-primary"><?php echo esc_html__( 'Continue', 'gigneo' ); ?></button>
			<p class="gn-auth-action-text">
				<?php echo esc_html__( 'Already have an account?', 'gigneo' ); ?>
				<a href="<?php echo esc_url( get_permalink( $login_template ) ); ?>" class="gn-sign-in"><?php echo esc_html__( 'Sign in', 'gigneo' ); ?></a>
			</p>
		</div>
	</div>
	<?php if ( $role_enable ) { ?>
		<!--Register form multistep step role-->
		<div id="gn-auth-register-role" class="gn-auth-register-step gn-auth-register-step-role">
			<div class="gn-auth-heading-area">
				<h3 class="gn-title"><?php echo esc_html__( 'Choose your role to get started', 'gigneo' ); ?></h3>
				<p class="gn-description"><?php echo esc_html__( 'This helps us set up the right experience for you.', 'gigneo' ); ?></p>
			</div>
			<div class="gn-form-fields gn-auth-form-fields">
				<div class="gn-form-field gn-field-roles">
					<div class="gn-field-role">
						<?php
						$default_role = gigneo_option( '_gigneo_ts_default_user_role', 'freelancer' );
						?>
						<label for="gn-user-role-1">
							<span class="gn-icon">
								<i class="hi hi-user" aria-hidden="true"></i>
							</span>
							<span class="gn-title">
								<?php
								printf(
									// translators: %s is freelancer singular
									esc_html__( "I'm a %s", 'gigneo' ),
									esc_html( gigneo_freelancer_singular() )
								);
								?>
							</span>
							<span class="gn-description">
								<?php echo esc_html__( 'Looking for jobs and paid work.', 'gigneo' ); ?>
							</span>
						</label>
						<input id="gn-user-role-1" type="radio" class="gn-required-field" name="user_role" value="freelancer"<?php echo esc_attr( 'freelancer' === $default_role ? ' checked' : '' ); ?> />
					</div>
					<div class="gn-field-role">
						<label for="gn-user-role-2">
							<span class="gn-icon">
								<i class="hi hi-briefcase" aria-hidden="true"></i>
							</span>
							<span class="gn-title">
								<?php
								printf(
									// translators: %s is employer singular
									esc_html__( "I'm an %s", 'gigneo' ),
									esc_html( gigneo_employer_singular() )
								);
								?>
							</span>
							<span class="gn-description">
								<?php echo esc_html__( 'Hiring freelancers for jobs.', 'gigneo' ); ?>
							</span>
						</label>
						<input id="gn-user-role-2" type="radio" class="gn-required-field" name="user_role" value="employer" <?php echo esc_attr( 'employer' === $default_role ? ' checked' : '' ); ?> />
					</div>
				</div>
			</div>
			<div class="gn-auth-actions">
				<button type="button" data-step="gn-auth-register-basic" class="gn-auth-register-back-btn gn-btn gn-btn-outline-grey"><i class="hi hi-arrow-left" aria-hidden="true"></i><?php echo esc_html__( 'Back', 'gigneo' ); ?></button>
				<button type="button" data-step="gn-auth-register-username" class="gn-auth-register-continue-btn gn-btn gn-btn-primary"><?php echo esc_html__( 'Continue', 'gigneo' ); ?></button>
			</div>
		</div>
	<?php } ?>
	<!--Register form multistep step username-->
	<div id="gn-auth-register-username" class="gn-auth-register-step gn-auth-register-step-username">
		<div class="gn-auth-heading-area">
			<h3 class="gn-title"><?php echo esc_html__( 'Choose a username', 'gigneo' ); ?></h3>
			<p class="gn-description"><?php echo esc_html__( 'This will be used in your profile and public links. Username can’t be changed later. Please choose carefully.', 'gigneo' ); ?></p>
		</div>
		<div class="gn-form-fields gn-auth-form-fields">
			<div class="gn-form-field">
				<label for="gn-user-name"><?php echo esc_html__( 'Username', 'gigneo' ); ?></label>
				<div class="gn-auth-input-wrapper">
				<input id="gn-user-name" type="text" class="gn-required-field" name="user_name" placeholder="<?php echo esc_html__( 'Enter username', 'gigneo' ); ?>" />
				</div>
			</div>
		</div>
		<div class="gn-auth-actions">
			<button type="button" data-step="gn-auth-register-<?php echo esc_attr( $role_enable ? 'role' : 'basic' ); ?>" class="gn-auth-register-back-btn gn-btn gn-btn-outline-grey"><i class="hi hi-arrow-left" aria-hidden="true"></i><?php echo esc_html__( 'Back', 'gigneo' ); ?></button>
			<button id="gn-register-form-submit-btn" type="submit" class="gn-auth-action-btn gn-btn gn-btn-primary"><?php echo esc_html__( 'Create account', 'gigneo' ); ?></button>
		</div>
	</div>
</form>