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

$profile_id = $args['profile_id'] ?? gigneo_active_profile_id();

if ( ! in_array( 'close_account', gigneo_active_modules(), true ) ) {
	return;
}
$close_reasons = gigneo_option( '_gigneo_ts_close_account_reasons' );
?>
<div class="gn-info-inline">
	<div class="gn-info">
		<h4 class="gn-title"><?php echo esc_html__( 'Close account', 'gigneo' ); ?></h4>
		<p class="gn-description"><?php echo esc_html__( 'Closing your account will permanently disable it, and you’ll lose access to all your information.', 'gigneo' ); ?></p>
	</div>
	<div class="gn-actions">
		<button class="gn-btn gn-btn-toggle-icon" data-gn-modal-toggle="gn-account-close">
			<i class="hi hi-arrow-up-right" aria-hidden="true"></i>
		</button>
	</div>
	<!--Account Deactivation Modal-->
	<div id="gn-account-close" class="gn-modal-wrapper gn-user-setting-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__( 'Close account', 'gigneo' ); ?></h4>
						<p class="gn-description"><?php echo esc_html__( 'This action is permanent and irreversible.', 'gigneo' ); ?></p>
						<button type="button" data-gn-modal-close="gn-account-close" class="gn-modal-close">
							<i class="hi hi-x-mark" aria-hidden="true"></i>
						</button>
					</div>
					<form id="gn-account-close-form" class="gn-theme-form gn-save-user-account-setting">
						<div class="gn-modal-body gn-custom-scrollbar">
							<div class="gn-notices-wrapper">
								<div class="gn-notice gn-notice-warning">
									<div class="gn-info">
										<h3 class="gn-title"><?php echo esc_html__( 'This will:', 'gigneo' ); ?></h3>
										<ul class="gn-info-list">
											<li><?php echo esc_html__( 'Permanently close your account.', 'gigneo' ); ?></li>
											<li><?php echo esc_html__( 'Revoke your access to the platform and its services.', 'gigneo' ); ?></li>
											<li><?php echo esc_html__( 'Hide your profile from all client views and search results.', 'gigneo' ); ?></li>
										</ul>
									</div>
								</div>
							</div>
							<fieldset class="gn-form-fields">
								<div class="row g-4">
									<div class="col-md-12">
										<div class="gn-form-field">
											<h4 class="gn-section-title gn-required-field-label"><?php echo esc_html__( 'Let us know what didn’t work for you.', 'gigneo' ); ?></h4>
											<?php
											foreach ( $close_reasons as $key => $close_reason ) {
												if ( empty( $close_reason['reason'] ) ) {
													continue;
												}
												?>
												<div class="gn-radio">
													<input type="radio" name="close_reason" id="gn-close-reason-<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $close_reason['reason'] ); ?>" <?php echo esc_attr( 0 === $key ? ' checked="checked"' : '' ); ?>>
													<label for="gn-close-reason-<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $close_reason['reason'] ); ?></label>
												</div>
											<?php } ?>
										</div>
									</div>
									<div class="col-md-12">
										<div class="gn-form-field">
											<label class="gn-section-title gn-alt-font gn-required-field-label" for="gn-close-detail"><?php echo esc_html__( 'Tell us more', 'gigneo' ); ?></label>
											<textarea id="gn-close-detail" class="gn-required-field gn-textarea-counter" name="close_detail" autocomplete="off" rows="5" placeholder="<?php echo esc_attr__( 'Write detail here...', 'gigneo' ); ?>"></textarea>
										</div>
									</div>
								</div>
							</fieldset>
						</div>
						<div class="gn-modal-footer">
							<input type="hidden" name="type" value="close_account">
							<button type="button" class="gn-btn gn-btn-outline-grey" data-gn-modal-close="gn-account-close"><?php echo esc_html__( 'Close', 'gigneo' ); ?></button>
							<button type="submit" class="gn-btn gn-btn-danger"><?php echo esc_html__( 'Close', 'gigneo' ); ?></button>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>