<?php
/**
 * Template for th// Handle form submission for taxonomies [categories, locations, skills]
if ( isset( $_POST['candidate_resume_form_submit'] ) ) {
	$nonce = isset( $_POST['candidate_resume_nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['candidate_resume_nonce'] ) ) : '';
	if ( ! $nonce || ! wp_verify_nonce( $nonce, 'candidate_resume_update' ) ) {
		wp_die( esc_html__( 'Security check failed.', 'jobus' ) );
	}

	// Check user permissions
	if ( ! is_user_logged_in() || ! current_user_can( 'edit_post', $candidate_id ) ) {
		wp_die( esc_html__( 'You do not have permission to perform this action.', 'jobus' ) );
	}

	if ( isset( $_POST['candidate_categories'] ) ) {
		$cat_ids = array_filter( array_map( 'intval', explode( ',', sanitize_text_field( $_POST['candidate_categories'] ) ) ) );
		wp_set_object_terms( $candidate_id, $cat_ids, 'jobus_candidate_cat' );
	}

	if ( isset( $_POST['candidate_locations'] ) ) {
		$location_ids = array_filter( array_map( 'intval', explode( ',', sanitize_text_field( $_POST['candidate_locations'] ) ) ) );
		wp_set_object_terms( $candidate_id, $location_ids, 'jobus_candidate_location' );
	}

	if ( isset( $_POST['candidate_skills'] ) ) {
		$skill_ids = array_filter( array_map( 'intval', explode( ',', sanitize_text_field( $_POST['candidate_skills'] ) ) ) );
		wp_set_object_terms( $candidate_id, $skill_ids, 'jobus_candidate_skill' );
	}
}e page.
 *
 * @package    Jobus
 * @subpackage Templates
 */

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

// Get current user
$user = wp_get_current_user();

// Called the helper functions
$candidate_form = new \jobus\includes\Classes\submission\Candidate_Form_Submission();

// Get candidate data
$candidate_id    = $candidate_form->get_candidate_id( $user->ID );
$cv_data         = $candidate_form->get_candidate_cv( $candidate_id );
$video_data      = $candidate_form->get_candidate_video( $candidate_id );
$cv_attachment   = $cv_data['cv_attachment'];
$cv_file_name    = $cv_data['cv_file_name'];
$education_data  = $candidate_form->get_candidate_education( $candidate_id );
$experience_data = $candidate_form->get_candidate_experience( $candidate_id );
$portfolio_data  = $candidate_form->get_candidate_portfolio( $candidate_id );

// Get resume settings
$show_cv_upload = jobus_opt( 'candidate_cv_upload', true );
$show_intro_video = jobus_opt( 'candidate_intro_video', true );
$show_education = jobus_opt( 'candidate_education', true );
$show_experience = jobus_opt( 'candidate_experience', true );
$show_portfolio = jobus_opt( 'candidate_portfolio', true );
$show_skills = jobus_opt( 'candidate_skills', true );
$save_changes_label = jobus_opt( 'label_save_changes', esc_html__( 'Save Changes', 'jobus' ) );

// Handle form submission for taxonomies [categories, locations, skills]
if ( isset( $_POST['candidate_resume_form_submit'] ) ) {

	// Check user permissions
	// if ( ! is_user_logged_in() || ! current_user_can( 'edit_post', $candidate_id ) ) {
	// 	wp_die( esc_html__( 'You do not have permission to perform this action.', 'jobus' ) );
	// }

	if ( isset( $_POST['candidate_categories'] ) ) {
		$cat_ids = array_filter( array_map( 'intval', explode( ',', sanitize_text_field( $_POST['candidate_categories'] ) ) ) );
		wp_set_object_terms( $candidate_id, $cat_ids, 'jobus_candidate_cat' );
	}

	if ( isset( $_POST['candidate_locations'] ) ) {
		$location_ids = array_filter( array_map( 'intval', explode( ',', sanitize_text_field( $_POST['candidate_locations'] ) ) ) );
		wp_set_object_terms( $candidate_id, $location_ids, 'jobus_candidate_location' );
	}

	if ( isset( $_POST['candidate_skills'] ) ) {
		$skill_ids = array_filter( array_map( 'intval', explode( ',', sanitize_text_field( $_POST['candidate_skills'] ) ) ) );
		wp_set_object_terms( $candidate_id, $skill_ids, 'jobus_candidate_skill' );
	}
}

?>
<div class="jbs-position-relative">
    <h2 class="main-title"><?php esc_html_e( 'My Resume', 'jobus' ); ?></h2>

    <form action="" id="candidate-resume-form" method="post" enctype="multipart/form-data">

		<?php wp_nonce_field( 'candidate_resume_update', 'candidate_resume_nonce' ); ?>
        <input type="hidden" name="candidate_resume_form_submit" value="1">

        <?php if ( $show_cv_upload ) : ?>
        <div class="jbs-bg-white card-box border-20" id="candidate-resume">
            <h4 class="dash-title-three"><?php esc_html_e( 'Resume Attachment', 'jobus' ); ?></h4>
            <div class="dash-input-wrapper jbs-mb-20">
                <label for="cv_attachment"><?php esc_html_e( 'CV Attachment*', 'jobus' ); ?></label>
                <div id="cv-upload-preview" class="preview <?php echo empty( $cv_attachment ) ? 'hidden' : ''; ?>">
                    <div class="attached-file jbs-d-flex jbs-align-items-center jbs-justify-content-between">
                        <span id="cv-uploaded-filename"><?php echo esc_html( $cv_file_name ); ?></span>
                        <a href="#" id="remove-uploaded-cv" class="remove-btn"><i class="bi bi-x"></i></a>
                    </div>
                </div>
                <input type="hidden" name="profile_cv_action" id="profile_cv_action" value="">
                <input type="hidden" name="cv_attachment_id" id="cv_attachment_id" value="<?php echo esc_attr( $cv_attachment ); ?>">
            </div>
            <div id="cv-upload-btn-wrapper" class="<?php echo ! empty( $cv_attachment ) ? 'hidden' : ''; ?>">
                <div class="dash-btn-one jbs-d-inline-block jbs-position-relative jbs-me-3">
                    <i class="bi bi-plus"></i>
					<?php esc_html_e( 'Upload CV', 'jobus' ); ?>
                    <input type="file" id="upload_cv_button" name="upload_cv_button">
                </div>
            </div>
            <div id="cv-file-info" class="file-info <?php echo ! empty( $cv_attachment ) ? 'hidden' : ''; ?>">
                <small><?php esc_html_e( 'Upload file .pdf, .doc, .docx', 'jobus' ); ?></small>
            </div>
        </div>
        <?php endif; ?>

        <?php if ( $show_intro_video ) : ?>
        <div class="jbs-bg-white card-box jbs-border-20 jbs-mt-40" id="candidate-resume-video">
            <h4 class="dash-title-three"><?php esc_html_e( 'Intro Video', 'jobus' ); ?></h4>
            <div class="intro-video-form jbs-position-relative jbs-mt-20 w-100">
                <div class="dash-input-wrapper jbs-mb-15">
                    <label for="video-title"><?php esc_html_e( 'Title', 'jobus' ); ?></label>
                    <input type="text" id="video-title" name="video_title" value="<?php echo esc_attr( $video_data['video_title'] ); ?>"
                           placeholder="<?php esc_attr_e( 'Intro', 'jobus' ); ?>">
                </div>
                <div class="dash-input-wrapper jbs-mb-15">
                    <label for="video-url"><?php esc_html_e( 'Video URL', 'jobus' ); ?></label>
                    <input type="text" id="video-url" name="video_url" value="<?php echo esc_attr( $video_data['video_url'] ); ?>"
                           placeholder="<?php esc_attr_e( 'Enter your video URL', 'jobus' ); ?>">
                </div>
                <div class="dash-input-wrapper jbs-mb-15">
                    <label for="video-bg-img"><?php esc_html_e( 'Background Image', 'jobus' ); ?></label>

                    <!-- Image Preview Section -->
                    <div id="candidate-bg-img-preview" class="preview bg-img-preview <?php echo empty( $video_data['video_bg_img']['url'] ) ? 'hidden' : ''; ?>">
                        <div class="attached-file jbs-d-flex jbs-align-items-center jbs-justify-content-between">
                            <span id="candidate-video-bg-image-uploaded-filename"><?php echo esc_url( $video_data['video_bg_img']['url'] ); ?></span>
                            <a href="#" id="candidate-remove-uploaded-bg-img" class="remove-btn"><i class="bi bi-x"></i></a>
                        </div>
                    </div>

                    <div id="candidate-bg-img-upload-btn-wrapper" class="<?php echo ! empty( $video_data['video_bg_img']['url'] ) ? 'hidden' : ''; ?>">
                        <div class="dash-btn-one jbs-d-inline-block jbs-position-relative jbs-me-3">
                            <i class="bi bi-plus"></i>
                            <?php esc_html_e( 'Upload Image', 'jobus' ); ?>
                            <button type="button" id="candidate-video-bg-img-upload-btn" class="jbs-position-absolute jbs-w-100 jbs-h-100 jbs-start-0 jbs-top-0 jbs-opacity-0 jbs-pointer"></button>
                        </div>
                    </div>
                    <!-- Hidden field for image ID -->
                    <input type="hidden" id="candidate-video-bg-img" name="video_bg_img" value="<?php echo esc_attr( $video_data['video_bg_img']['id'] ?? '' ); ?>">
                    <input type="hidden" id="candidate-video-bg-img-action" name="video_bg_img_action" value="">
                </div>
            </div>
        </div>
        <?php endif; ?>

        <?php if ( $show_education ) : ?>
        <div class="jbs-bg-white card-box border-20 jbs-mt-40" id="candidate-resume-education">
            <h4 class="dash-title-three"><?php esc_html_e( 'Education', 'jobus' ); ?></h4>

            <div class="dash-input-wrapper jbs-mb-15">
                <label for="education_title"><?php esc_html_e( 'Title', 'jobus' ); ?></label>
                <input type="text" id="education_title" name="education_title"
                       value="<?php echo esc_attr( $education_data['education_title'] ); ?>"
                       placeholder="<?php esc_attr_e( 'Education', 'jobus' ); ?>">
            </div>

            <div class="jbs-accordion dash-accordion-one" id="education-repeater">
				<?php
				$education = $education_data['education'];
				if ( empty( $education ) ) {
					$education[] = array(
						'sl_num'      => '',
						'title'       => '',
						'academy'     => '',
						'description' => '',
					);
				}
				foreach ( $education as $key => $value ) {
					$accordion_id = 'collapseOne-' . esc_attr( $key );
					?>
                    <div class="jbs-accordion-item education-item">
                        <div class="jbs-accordion-header" id="headingOne-<?php echo esc_attr( $key ); ?>">
                            <button class="jbs-accordion-button jbs-collapsed" type="button"
                                    data-jbs-toggle="collapse"
                                    data-jbs-target="#<?php echo esc_attr( $accordion_id ); ?>"
                                    data-jbs-parent="#education-repeater"
                                    aria-expanded="false"
                                    aria-controls="<?php echo esc_attr( $accordion_id ); ?>">
								<?php echo esc_html( $value['title'] ?? esc_html__( 'Education', 'jobus' ) ); ?>
                            </button>
                        </div>
                        <div id="<?php echo esc_attr( $accordion_id ); ?>" class="jbs-accordion-collapse jbs-collapse"
                             aria-labelledby="headingOne-<?php echo esc_attr( $key ); ?>"
                             data-jbs-parent="#education-repeater">
                            <div class="jbs-accordion-body">
                                <div class="jbs-row">
                                    <div class="jbs-col-lg-2">
                                        <div class="dash-input-wrapper jbs-mb-30 md-mb-10">
                                            <label for="<?php echo esc_attr( 'education_' . $key . '_sl_num' ); ?>">
												<?php esc_html_e( 'Serial Number', 'jobus' ); ?>*
                                            </label>
                                        </div>
                                    </div>
                                    <div class="jbs-col-lg-10">
                                        <div class="dash-input-wrapper jbs-mb-30">
                                            <input type="text"
                                                   class="form-control"
                                                   name="<?php echo esc_attr( 'education[' . $key . '][sl_num]' ); ?>"
                                                   id="<?php echo esc_attr( 'education_' . $key . '_sl_num' ); ?>"
                                                   value="<?php echo esc_attr( $value['sl_num'] ?? '' ); ?>">
                                        </div>
                                    </div>
                                </div>
                                <div class="jbs-row">
                                    <div class="jbs-col-lg-2">
                                        <div class="dash-input-wrapper jbs-mb-30 md-mb-10">
                                            <label for="<?php echo esc_attr( 'education_' . $key . '_title' ); ?>">
												<?php esc_html_e( 'Title', 'jobus' ); ?>
                                            </label>
                                        </div>
                                    </div>
                                    <div class="jbs-col-lg-10">
                                        <div class="dash-input-wrapper jbs-mb-30">
                                            <input type="text" class="form-control"
                                                   name="education[<?php echo esc_attr( $key ); ?>][title]"
                                                   id="education_<?php echo esc_attr( $key ); ?>_title"
                                                   value="<?php echo esc_attr( $value['title'] ?? '' ); ?>">
                                        </div>
                                    </div>
                                </div>
                                <div class="jbs-row">
                                    <div class="jbs-col-lg-2">
                                        <div class="dash-input-wrapper jbs-mb-30 md-mb-10">
                                            <label for="<?php echo esc_attr( 'education_' . $key . '_academy' ); ?>">
												<?php esc_html_e( 'Academy', 'jobus' ); ?>*
                                            </label>
                                        </div>
                                    </div>
                                    <div class="jbs-col-lg-10">
                                        <div class="dash-input-wrapper jbs-mb-30">
                                            <input type="text" class="form-control"
                                                   name="education[<?php echo esc_attr( $key ); ?>][academy]"
                                                   id="education_<?php echo esc_attr( $key ); ?>_academy"
                                                   value="<?php echo esc_attr( $value['academy'] ?? '' ); ?>"
                                                   placeholder="<?php esc_attr_e( 'Google Arts College & University', 'jobus' ); ?>">
                                        </div>
                                    </div>
                                </div>
                                <div class="jbs-row">
                                    <div class="jbs-col-lg-2">
                                        <div class="dash-input-wrapper jbs-mb-30 md-mb-10">
                                            <label for="<?php echo esc_attr( 'education_' . $key . '_description' ); ?>">
												<?php esc_html_e( 'Description', 'jobus' ); ?>*
                                            </label>
                                        </div>
                                    </div>
                                    <div class="jbs-col-lg-10">
                                        <div class="dash-input-wrapper jbs-mb-30">
                                            <textarea class="size-lg form-control"
                                                      name="education[<?php echo esc_attr( $key ); ?>][description]"
                                                      id="education_<?php echo esc_attr( $key ); ?>_description"
                                                      placeholder="<?php esc_attr_e( 'Description of your education',
	                                                      'jobus' ); ?>"><?php echo esc_textarea( $value['description'] ?? '' ); ?></textarea>
                                        </div>
                                    </div>
                                </div>
                                <div class="jbs-text-end">
                                    <button type="button" class="jbs-btn jbs-btn-danger jbs-btn-sm remove-education jbs-mt-2 jbs-mb-2"
                                            title="<?php esc_attr_e( 'Remove Item', 'jobus' ); ?>">
                                        <i class="bi bi-x"></i> <?php esc_html_e( 'Remove', 'jobus' ); ?>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
					<?php
				}
				?>
            </div>
            <button href="javascript:void(0)" class="dash-btn-one jbs-mt-2" id="add-education">
                <i class="bi bi-plus"></i> <?php esc_html_e( 'Add Education Item', 'jobus' ); ?>
            </button>
        </div>
        <?php endif; ?>

        <?php if ( $show_experience ) : ?>
        <div class="jbs-bg-white card-box border-20 jbs-mt-40" id="candidate-resume-experience">
            <h4 class="dash-title-three"><?php esc_html_e( 'Experience', 'jobus' ); ?></h4>
            <div class="dash-input-wrapper jbs-mb-15">
                <label for="experience_title"><?php esc_html_e( 'Title', 'jobus' ); ?></label>
                <input type="text" id="experience_title" name="experience_title"
                       value="<?php echo esc_attr( $experience_data['experience_title'] ); ?>"
                       placeholder="<?php esc_attr_e( 'Work Experience', 'jobus' ); ?>">
            </div>

            <div class="jbs-accordion dash-accordion-one" id="experience-repeater">
				<?php
				$experience = $experience_data['experience'];
				if ( empty( $experience ) ) {
					$experience[] = array(
						'sl_num'      => '',
						'title'       => '',
						'start_date'  => '',
						'end_date'    => '',
						'description' => '',
					);
				}
				foreach ( $experience as $key => $value ) {
					$accordion_id = 'experience-' . esc_attr( $key );
					?>
                    <div class="jbs-accordion-item experience-item">
                        <div class="jbs-accordion-header" id="headingExp-<?php echo esc_attr( $key ); ?>">
                            <button class="jbs-accordion-button jbs-collapsed" type="button"
                                    data-jbs-toggle="collapse"
                                    data-jbs-target="#<?php echo esc_attr( $accordion_id ); ?>"
                                    data-jbs-parent="#experience-repeater"
                                    aria-expanded="false"
                                    aria-controls="<?php echo esc_attr( $accordion_id ); ?>">
								<?php echo esc_html( $value['title'] ?? esc_html__( 'Experience', 'jobus' ) ); ?>
                            </button>
                        </div>
                        <div id="<?php echo esc_attr( $accordion_id ); ?>" class="jbs-accordion-collapse jbs-collapse"
                             aria-labelledby="headingExp-<?php echo esc_attr( $key ); ?>"
                             data-jbs-parent="#experience-repeater">
                            <div class="jbs-accordion-body">
                                <div class="jbs-row">
                                    <div class="jbs-col-lg-2">
                                        <div class="dash-input-wrapper jbs-mb-30 md-mb-10">
                                            <label for="experience_<?php echo esc_attr( $key ); ?>_sl_num">
												<?php esc_html_e( 'Serial Number', 'jobus' ); ?>
                                            </label>
                                        </div>
                                    </div>
                                    <div class="jbs-col-lg-10">
                                        <div class="dash-input-wrapper jbs-mb-30">
                                            <input type="text" class="form-control"
                                                   name="experience[<?php echo esc_attr( $key ); ?>][sl_num]"
                                                   id="experience_<?php echo esc_attr( $key ); ?>_sl_num"
                                                   value="<?php echo esc_attr( $value['sl_num'] ?? '' ); ?>"
                                                   placeholder="<?php esc_attr_e( 'Enter serial number', 'jobus' ); ?>">
                                        </div>
                                    </div>
                                </div>

                                <div class="jbs-row">
                                    <div class="jbs-col-lg-2">
                                        <div class="dash-input-wrapper jbs-mb-30 md-mb-10">
                                            <label for="experience_<?php echo esc_attr( $key ); ?>_title">
												<?php esc_html_e( 'Title', 'jobus' ); ?>
                                            </label>
                                        </div>
                                    </div>
                                    <div class="jbs-col-lg-10">
                                        <div class="dash-input-wrapper jbs-mb-30">
                                            <input type="text" class="form-control"
                                                   name="experience[<?php echo esc_attr( $key ); ?>][title]"
                                                   id="experience_<?php echo esc_attr( $key ); ?>_title"
                                                   value="<?php echo esc_attr( $value['title'] ?? '' ); ?>"
                                                   placeholder="<?php esc_attr_e( 'Lead Product Designer', 'jobus' ); ?>">
                                        </div>
                                    </div>
                                </div>

                                <div class="jbs-row">
                                    <div class="jbs-col-lg-2">
                                        <div class="dash-input-wrapper jbs-mb-30 md-mb-10">
                                            <label><?php esc_html_e( 'Duration', 'jobus' ); ?></label>
                                        </div>
                                    </div>
                                    <div class="jbs-col-lg-10">
                                        <div class="jbs-row">
                                            <div class="jbs-col-sm-6">
                                                <div class="dash-input-wrapper jbs-mb-30">
                                                    <input type="date" class="form-control"
                                                           name="experience[<?php echo esc_attr( $key ); ?>][start_date]"
                                                           id="experience_<?php echo esc_attr( $key ); ?>_start_date"
                                                           value="<?php echo esc_attr( $value['start_date'] ?? '' ); ?>">
                                                </div>
                                            </div>
                                            <div class="jbs-col-sm-6">
                                                <div class="dash-input-wrapper jbs-mb-30">
                                                    <input type="date" class="form-control"
                                                           name="experience[<?php echo esc_attr( $key ); ?>][end_date]"
                                                           id="experience_<?php echo esc_attr( $key ); ?>_end_date"
                                                           value="<?php echo esc_attr( $value['end_date'] ?? '' ); ?>">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <div class="jbs-row">
                                    <div class="jbs-col-lg-2">
                                        <div class="dash-input-wrapper jbs-mb-30 md-mb-10">
                                            <label for="experience_<?php echo esc_attr( $key ); ?>_description">
												<?php esc_html_e( 'Description', 'jobus' ); ?>
                                            </label>
                                        </div>
                                    </div>
                                    <div class="jbs-col-lg-10">
                                        <div class="dash-input-wrapper jbs-mb-30">
                                            <textarea class="form-control"
                                                      name="experience[<?php echo esc_attr( $key ); ?>][description]"
                                                      id="experience_<?php echo esc_attr( $key ); ?>_description"
                                                      placeholder="<?php esc_attr_e( 'Describe your role and achievements', 'jobus' ); ?>"
                                                      rows="4"><?php echo esc_textarea( $value['description'] ?? '' ); ?></textarea>
                                        </div>
                                    </div>
                                </div>

                                <div class="jbs-text-end">
                                    <button type="button" class="btn jbs-btn-danger jbs-btn-sm remove-experience jbs-mt-2 jbs-mb-2"
                                            title="<?php esc_attr_e( 'Remove Item', 'jobus' ); ?>">
                                        <i class="bi bi-x"></i> <?php esc_html_e( 'Remove', 'jobus' ); ?>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
					<?php
				}
				?>
            </div>
            <button href="javascript:void(0)" class="dash-btn-one jbs-mt-2" id="add-experience">
                <i class="bi bi-plus"></i> <?php esc_html_e( 'Add Experience Item', 'jobus' ); ?>
            </button>
        </div>
        <?php endif; ?>

        <div class="jbs-bg-white card-box border-20 jbs-mt-40" id="candidate-taxonomy">
            <h4 class="dash-title-three"><?php esc_html_e( 'Taxonomies', 'jobus' ); ?></h4>

            <!-- Add Categories -->
            <div class="dash-input-wrapper jbs-mb-40 jbs-mt-20">
                <label for="candidate-category-list"><?php esc_html_e( 'Categories', 'jobus' ); ?></label>
                <div class="skills-wrapper">
					<?php
					$current_categories = array();
					if ( isset( $candidate_id ) && $candidate_id ) {
						$current_categories = wp_get_object_terms( $candidate_id, 'jobus_candidate_cat' );
					}

					// To store category IDs
					$category_ids = ! empty( $current_categories ) ? implode( ',', wp_list_pluck( $current_categories, 'term_id' ) ) : '';
					?>
                    <ul id="candidate-category-list" class="jbs-style-none jbs-d-flex flex-wrap jbs-align-items-center">
						<?php if ( ! empty( $current_categories ) ): ?>
							<?php foreach ( $current_categories as $cat ): ?>
                                <li class="is_tag" data-category-id="<?php echo esc_attr( $cat->term_id ); ?>">
                                    <button type="button"><?php echo esc_html( $cat->name ); ?> <i class="bi bi-x"></i></button>
                                </li>
							<?php endforeach; ?>
						<?php endif; ?>
                        <li class="more_tag">
                            <button type="button"><?php esc_html_e( '+', 'jobus' ); ?></button>
                        </li>
                    </ul>
                    <input type="hidden" name="candidate_categories" id="candidate_categories_input" value="<?php echo esc_attr( $category_ids ); ?>">
                </div>
            </div>

            <!-- Add Locations -->
            <div class="dash-input-wrapper jbs-mb-40 jbs-mt-20">
                <label for="candidate-location-list"><?php esc_html_e( 'Locations', 'jobus' ); ?></label>
                <div class="skills-wrapper">
					<?php
					$current_location = array();
					if ( isset( $candidate_id ) && $candidate_id ) {
						$current_location = wp_get_object_terms( $candidate_id, 'jobus_candidate_location' );
					}

					// To store category IDs
					$locations_ids = ! empty( $current_location ) ? implode( ',', wp_list_pluck( $current_location, 'term_id' ) ) : '';
					?>
                    <ul id="candidate-location-list" class="jbs-style-none jbs-d-flex flex-wrap jbs-align-items-center">
						<?php if ( ! empty( $current_location ) ) : ?>
							<?php foreach ( $current_location as $location ): ?>
                                <li class="is_tag" data-location-id="<?php echo esc_attr( $location->term_id ); ?>">
                                    <button type="button"><?php echo esc_html( $location->name ); ?> <i class="bi bi-x"></i></button>
                                </li>
							<?php endforeach; ?>
						<?php endif; ?>
                        <li class="more_tag">
                            <button type="button"><?php esc_html_e( '+', 'jobus' ); ?></button>
                        </li>
                    </ul>
                    <input type="hidden" name="candidate_locations" id="candidate_locations_input" value="<?php echo esc_attr( $locations_ids ); ?>">
                </div>
            </div>

            <!-- Add Skills -->
            <div class="dash-input-wrapper jbs-mb-40 jbs-mt-20">
                <label for="candidate-skills-list"><?php esc_html_e( 'Add Skills', 'jobus' ); ?></label>
                <div class="skills-wrapper">
					<?php
					$current_skills = array();
					if ( isset( $candidate_id ) && $candidate_id ) {
						$current_skills = wp_get_object_terms( $candidate_id, 'jobus_candidate_skill' );
					}

					// To store category IDs
					$skill_ids = ! empty( $current_skills ) ? implode( ',', wp_list_pluck( $current_skills, 'term_id' ) ) : '';
					?>
                    <ul id="candidate-skills-list" class="jbs-style-none jbs-d-flex flex-wrap jbs-align-items-center">
						<?php if ( ! empty( $current_skills ) ) : ?>
							<?php foreach ( $current_skills as $skill ): ?>
                                <li class="is_tag" data-skill-id="<?php echo esc_attr( $skill->term_id ); ?>">
                                    <button type="button"><?php echo esc_html( $skill->name ); ?> <i class="bi bi-x"></i></button>
                                </li>
							<?php endforeach; ?>
						<?php endif; ?>
                        <li class="more_tag">
                            <button type="button"><?php esc_html_e( '+', 'jobus' ); ?></button>
                        </li>
                    </ul>
                    <input type="hidden" name="candidate_skills" id="candidate_skills_input" value="<?php echo esc_attr( $skill_ids ); ?>">
                </div>
            </div>
        </div>

        <?php if ( $show_portfolio ) : ?>
        <div class="jbs-bg-white card-box border-20 jbs-mt-40" id="portfolio-section">
            <h4 class="dash-title-three"><?php esc_html_e( 'Portfolio', 'jobus' ); ?></h4>
            <div class="dash-input-wrapper jbs-mb-30">
                <label for="portfolio_title"><?php esc_html_e( 'Title', 'jobus' ); ?></label>
                <input type="text"
                       id="portfolio_title"
                       name="portfolio_title"
                       value="<?php echo esc_attr( $portfolio_data['portfolio_title'] ); ?>"
                       class="form-control">
            </div>

            <!-- Portfolio Preview Gallery -->
            <div class="portfolio-preview-wrapper jbs-mb-4">
                <div id="portfolio-items">
					<?php
					if ( ! empty( $portfolio_data['portfolio'] ) ) {
                        ?>
                        <ul class="portfolio-image-list">
							<?php
                            foreach ( $portfolio_data['portfolio'] as $image_id ) {
								$image_url = wp_get_attachment_image_url( $image_id );
								if ( $image_url ) { ?>
                                    <li data-id="<?php echo esc_attr( $image_id ); ?>">
                                        <img src="<?php echo esc_url( $image_url ); ?>" alt="<?php echo esc_attr( get_post_meta( $image_id, '_wp_attachment_image_alt', true ) ); ?>">
                                    </li>
								    <?php
								}
                            }
                            ?>
                        </ul>
					    <?php
					}
                    ?>
                </div>
            </div>

            <input type="hidden" name="portfolio[]" id="portfolio_ids"
                   value="<?php echo ! empty( $portfolio_data['portfolio'] ) ? esc_attr( implode( ',', $portfolio_data['portfolio'] ) ) : ''; ?>">
            <button type="button" id="add-portfolio-images" class="dash-btn-one jbs-mt-3">
                <i class="bi bi-plus"></i> <?php esc_html_e( 'Add Gallery', 'jobus' ); ?>
            </button>
        </div>
        <?php endif; ?>

        <div class="button-group d-inline-flex align-items-center jbs-mt-30">
            <button type="submit" class="dash-btn-two tran3s me-3"><?php echo esc_html( $save_changes_label ); ?></button>
        </div>
    </form>
</div>