<?php

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

$login_template           = gigneo_option( '_gigneo_ts_template_login' );
$forgot_password_template = gigneo_option( '_gigneo_ts_template_forgot_password' );

// phpcs:disable WordPress.Security.NonceVerification.Recommended -- Read-only parameters no nonce required.
$user_id   = isset( $_GET['id'] ) ? sanitize_text_field( wp_unslash( $_GET['id'] ) ) : '';
$user_lgn  = isset( $_GET['login'] ) ? sanitize_text_field( wp_unslash( $_GET['login'] ) ) : '';
$reset_key = isset( $_GET['key'] ) ? sanitize_text_field( wp_unslash( $_GET['key'] ) ) : '';
// phpcs:enable WordPress.Security.NonceVerification.Recommended -- Read-only parameters no nonce required.

if ( ! empty( $user_id ) && ! empty( $user_lgn ) && ! empty( $reset_key ) ) {
	require gigneo_get_template( 'auth/change-password' );
	return;
}
?>
<form id="gn-auth-forgot-password" class="gn-auth-form gn-auth-forgot-password-form" data-action="gigneo_auth_forgot_password">
	<div class="gn-auth-heading-area">
		<h3 class="gn-title"><?php echo esc_html__( 'Reset password', 'gigneo' ); ?></h3>
		<p class="gn-description"><?php echo esc_html__( "Enter your email address and we'll send you a link to reset your password.", 'gigneo' ); ?></p>
	</div>
	<div class="gn-form-fields gn-auth-form-fields">
		<div class="gn-form-field">
			<label for="gn-forgot-password-email"><?php echo esc_html__( 'Email', 'gigneo' ); ?></label>
			<input id="gn-forgot-password-email" type="text" class="gn-required-field" name="email" placeholder="<?php echo esc_html__( 'Enter email address', 'gigneo' ); ?>" />
		</div>
	</div>
	<div class="gn-auth-actions">
		<button id="gn-forgot-password-form-submit-btn" type="submit" class="gn-auth-action-btn gn-btn gn-btn-primary"><?php echo esc_html__( 'Reset password', 'gigneo' ); ?></button>
		<p class="gn-auth-action-text">
			<?php echo esc_html__( 'Go back to', '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>
</form>