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

global $current_user;
$profile_id = $args['profile_id'] ?? gigneo_active_profile_id();
$content    = gigneo_post_meta( $profile_id, '_gigneo_pm_bio' );

?>
<div id="gn-profile-description" class="gn-setting-section">
	<div class="gn-head">
		<h3 class="gn-title"><?php echo esc_html__( 'Bio description', 'gigneo' ); ?></h3>
		<button class="gn-link gn-link-primary" data-gn-modal-toggle="gn-edit-profile-description">
			<i class="hi hi-pencil-edit" aria-hidden="true"></i>
			<?php echo esc_html__( 'Edit', 'gigneo' ); ?>
		</button>
	</div>
	<?php if ( ! empty( $content ) ) { ?>
		<div class="gn-body">
			<div class="gn-description">
				<?php
				echo wp_kses(
					wp_html_excerpt(
						$content,
						500,
						'...'
					),
					gigneo_allowed_html_tags()
				);
				?>
			</div>
		</div>
		<?php
	} else {
		$not_found_args = array(
			'image'       => false,
			'title'       => esc_html__( 'No bio description', 'gigneo' ),
			'description' => esc_html__( 'Write a brief bio to showcase your skills and experience.', 'gigneo' ),
		);
		gigneo_not_found( 'gn-profile-description', $not_found_args );
	}
	?>
	<!--Edit Personal Info Modal-->
	<div id="gn-edit-profile-description" class="gn-modal-wrapper gn-profile-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__( 'Bio description', 'gigneo' ); ?></h4>
						<p class="gn-description"><?php echo esc_html__( 'Manage or update your bio description.', 'gigneo' ); ?></p>
						<button type="button" data-gn-modal-close="gn-edit-profile-description" class="gn-modal-close">
							<i class="hi hi-x-mark" aria-hidden="true"></i>
						</button>
					</div>
					<form id="gn-save-profile-setting-form" class="gn-theme-form gn-save-profile-setting">
						<div class="gn-modal-body gn-custom-scrollbar">
							<fieldset class="gn-form-fields">
								<div class="gn-form-field gn-wysiwyg-editor-two">
									<label for="gn-description"><?php echo esc_html__( 'Description', 'gigneo' ); ?></label>
									<?php
									wp_editor(
										wp_kses_post( $content ),
										'gn-description',
										array(
											'textarea_name' => 'description',
											'media_buttons' => false,
											'quicktags'    => false,
											'textarea_rows' => 7,
											'editor_class' => 'gn-wp-editor gn-required-field',
											'tinymce'      => array(
												'toolbar1' => 'bold italic bullist numlist link unlink',
												'toolbar2' => '',
												'plugins'  => 'lists link',
												'directionality' => is_rtl() ? 'rtl' : 'ltr',
												'forced_root_block' => false,
												'force_br_newlines' => true,
												'force_p_newlines' => false,
												'convert_newlines_to_brs' => true,
												'valid_elements' => 'strong/b,em/i,ul,ol,li,a[href|target],br,hr',
												'invalid_elements' => 'p,pre,h1,h2,h3,h4,h5,h6,img',
												'content_style' => 'body { font-size: 14px; background-color: transparent; font-family: var(--gigneo-primary-font,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji) }',
											),
										)
									);
									?>
								</div>
							</fieldset>
						</div>
						<div class="gn-modal-footer">
							<input type="hidden" name="type" value="description">
							<button type="button" class="gn-btn gn-btn-outline-grey" data-gn-modal-close="gn-edit-profile-description"><?php echo esc_html__( 'Close', 'gigneo' ); ?></button>
							<button type="submit" class="gn-btn gn-btn-primary"><?php echo esc_html__( 'Save', 'gigneo' ); ?></button>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
