<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Prevent direct access to the script.
}


$password_strength = gigneo_option( '_gigneo_ts_password_strength', array( 'length' ) );
$email_verified    = get_user_meta( get_current_user_id(), '_gigneo_um_email_verified', true );
?>
<div id="gn-security-account" class="gn-dashboard-section gn-section-security">
	<div class="gn-head">
		<h3 class="gn-title"><?php echo esc_html__( 'Account Security', 'gigneo' ); ?></h3>
	</div>
	<div class="gn-body">
		<?php if ( in_array( 'email_verification', gigneo_active_modules(), true ) ) { ?>
			<div class="gn-info-inline">
				<div class="gn-info">
					<h4 class="gn-title">
						<?php echo esc_html__( 'Email verification', 'gigneo' ); ?>
						<span class="gn-status-tag gn-<?php echo esc_attr( $email_verified ? 'success' : 'warning' ); ?>"><?php echo $email_verified ? esc_html__( 'Verified', 'gigneo' ) : esc_html__( 'Pending', 'gigneo' ); ?></span>
					</h4>
					<p class="gn-description"><?php echo esc_html__( 'Verify your email to keep your account safe.', 'gigneo' ); ?></p>
				</div>
				<div class="gn-actions">
					<?php if ( $email_verified ) { ?>
						<span class="gn-verified-icon"><i class="hi hi-check" aria-hidden="true"></i></span>
					<?php } else { ?>
						<button id="gn-email-verification-btn" class="gn-btn gn-btn-md gn-btn-primary">
							<?php echo esc_html__( 'Verify your email', 'gigneo' ); ?>
						</button>
					<?php } ?>
				</div>
			</div>
		<?php } ?>
		<div class="gn-info-inline">
			<div class="gn-info">
				<h4 class="gn-title"><?php echo esc_html__( 'Password', 'gigneo' ); ?></h4>
				<p class="gn-description"><?php echo esc_html__( 'Mange or update account password.', 'gigneo' ); ?></p>
			</div>
			<div class="gn-actions">
				<button class="gn-btn gn-btn-md gn-btn-outline-grey" data-gn-modal-toggle="gn-update-account-password">
					<?php echo esc_html__( 'Change password', 'gigneo' ); ?>
				</button>
			</div>
		</div>
	</div>
	<!--Update Password Modal-->
	<div id="gn-update-account-password" class="gn-modal-wrapper gn-account-password-modal">
		<div class="gn-modal-dialog">
			<div class="gn-modal-content">
				<div class="gn-modal-info">
					<div class="gn-modal-header">
						<h4 class="gn-title"><?php echo esc_html__( 'Change password', 'gigneo' ); ?></h4>
						<p class="gn-description"><?php echo esc_html__( 'Update your password to keep your account secure.', 'gigneo' ); ?></p>
						<button type="button" data-gn-modal-close="gn-update-account-password" class="gn-modal-close">
							<i class="hi hi-x-mark" aria-hidden="true"></i>
						</button>
					</div>
					<form id="gn-update-account-password-form" class="gn-theme-form gn-save-user-account-setting">
						<div class="gn-modal-body gn-custom-scrollbar">
							<fieldset class="gn-form-fields">
								<div class="row g-4">
									<div class="col-md-12">
										<div class="gn-form-field">
											<label class="gn-required-field-label" for="gn-current-password"><?php echo esc_html__( 'Current password', 'gigneo' ); ?></label>
											<div class="gn-auth-input-wrapper">
												<input id="gn-current-password" type="password" class="gn-required-field" name="current_password" placeholder="<?php echo esc_html__( 'Enter current password', 'gigneo' ); ?>" />
												<i class="hi hi-eye-slash gn-password-revealed" aria-hidden="true"></i>
											</div>
										</div>
									</div>
									<div class="col-md-12">
										<div class="gn-form-field">
											<label class="gn-required-field-label" for="gn-new-password"><?php echo esc_html__( 'New password', 'gigneo' ); ?></label>
											<div class="gn-auth-input-wrapper">
												<input id="gn-new-password" type="password" class="gn-required-field" name="new_password" placeholder="<?php echo esc_html__( 'Enter new 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>
								</div>
							</fieldset>
						</div>
						<div class="gn-modal-footer">
							<button type="button" class="gn-btn gn-btn-outline-grey" data-gn-modal-close="gn-update-account-password"><?php echo esc_html__( 'Close', 'gigneo' ); ?></button>
							<button type="submit" disabled="disabled" class="gn-btn gn-btn-primary"><?php echo esc_html__( 'Update', 'gigneo' ); ?></button>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>