<?php
/**
 * Template part for displaying about section
 *
 * @package HR Services
 * @subpackage hr_services
 */

$hr_services_static_image = get_stylesheet_directory_uri() . '/assets/images/about-img.png';

if (get_theme_mod('hr_services_service_enable', true) != '') : ?>
<section id="service" class="my-5">
    <div class="container">
        <?php
        $hr_services_about_page_id = absint(get_theme_mod('hr_services_about_page'));
        if ($hr_services_about_page_id != 0) : 
            $hr_services_args = array(
                'post_type' => 'page',
                'p' => $hr_services_about_page_id
            );
            $hr_services_query = new WP_Query($hr_services_args);
            if ($hr_services_query->have_posts()) :
                while ($hr_services_query->have_posts()) : $hr_services_query->the_post(); ?>
                  <div class="row">
                    <div class="col-lg-4 col-md-4">
                      <?php 
                        if (
                          get_theme_mod('hr_services_yr_experience_total_no') != '' ) : ?>
                          <div class="feature-content-main mb-lg-2 mb-md-3 mb-4">
                            <div class="abt-sentences">
                              <div class="tab-details align-items-center mb-lg-4 mb-md-3 mb-4">
                                <?php
                                // Fetch icon setting, fallback to default
                                $hr_services_icon_class = get_theme_mod('hr_services_yr_experience_icon', 'fas fa-medal');
                                ?>
                                <i class="<?php echo esc_attr($hr_services_icon_class); ?>"></i>
                                <div class="abt-content">
                                  <h4 class="m-0"><?php echo esc_html(get_theme_mod('hr_services_yr_experience_total_no')); ?></h4>
                                  <p class="m-0"><?php echo esc_html(get_theme_mod('hr_services_yr_experience_text','Year Of Experience')); ?></p>
                                </div>
                              </div>
                            </div>
                          </div>
                        <?php endif; ?>
                      <div class="about-left-img mb-3">
                        <?php
                            $hr_services_about_bg = get_theme_mod('hr_services_about_bg');
                            $hr_services_default_img = get_stylesheet_directory_uri() . '/assets/images/about-bg.png'; 
                        ?>
                        <div class="<?php echo empty($hr_services_about_bg) ? 'no-image1' : ''; ?>">
                          <?php if (!empty($hr_services_about_bg)) : ?>
                            <img class="left-img-abt" src="<?php echo esc_url($hr_services_about_bg); ?>" alt="<?php esc_attr_e('Background Image 1', 'hr-services'); ?>" />
                          <?php else: ?>
                            <img class="left-img-abt" src="<?php echo esc_url($hr_services_default_img); ?>" alt="<?php esc_attr_e('Default Background Image 1', 'hr-services'); ?>" />
                          <?php endif; ?>
                        </div>
                        <div class="hr-logo mb-3">
                        <?php
                            $hr_services_hr_logo = get_theme_mod('hr_services_hr_logo');
                            $hr_services_default_hr_img = get_stylesheet_directory_uri() . '/assets/images/hr-logo.png'; 
                        ?>
                        <div class="<?php echo empty($hr_services_hr_logo) ? 'no-image1' : ''; ?>">
                          <?php if (!empty($hr_services_hr_logo)) : ?>
                            <img src="<?php echo esc_url($hr_services_hr_logo); ?>" alt="<?php esc_attr_e('Background Image 1', 'hr-services'); ?>" />
                          <?php else: ?>
                            <img src="<?php echo esc_url($hr_services_default_hr_img); ?>" alt="<?php esc_attr_e('Default Background Image 1', 'hr-services'); ?>" />
                          <?php endif; ?>
                        </div>
                      </div>
                      </div>
                      </div>
                    <div class="col-lg-8 col-md-8 image-abt position-relative">
                      <div class="row">
                        <div class="col-lg-5 col-md-6 about-block">
                          <div class="about-image1 mb-3">
                            <?php if (has_post_thumbnail()) { ?>
                                <img src="<?php the_post_thumbnail_url('full'); ?>" />
                            <?php } else { ?>
                                <img src="<?php echo esc_url($hr_services_static_image); ?>" />
                            <?php } ?>
                            <div class="hr-name-heading">
                              <?php if (get_theme_mod('hr_services_service_hr_name') != '') : ?>
                                <h4 class="hr-name m-0 text-capitalize"><?php echo esc_html(get_theme_mod('hr_services_service_hr_name')); ?></h4>
                              <?php endif; ?>
                          </div>
                          </div>
                        </div>
                        <div class="col-lg-7 col-md-6 col-md-3about-block">
                          <div class="match-heading position-relative">
                            <?php if (get_theme_mod('hr_services_service_sub_heading') != '') : ?>
                              <h2 class="serv-short m-0 text-capitalize"><?php echo esc_html(get_theme_mod('hr_services_service_sub_heading')); ?></h2>
                            <?php endif; ?>
                          </div>
                        <h3 class="mt-3 mb-2">
                          <a href="<?php the_permalink(); ?>">
                            <?php echo esc_html( get_the_title() ); ?>
                          </a>
                        </h3>
                        <p class="mb-3 abt-content"><?php echo esc_html(wp_trim_words(get_the_content(), 30)); ?></p>
                          <?php if (get_theme_mod('hr_services_tab_heading1') != '' || get_theme_mod('hr_services_tab_heading2') != '' || get_theme_mod('hr_services_tab_heading3') != '') : ?>
                          <div class="main-bottom-box mt-4">
                            <?php for ($hr_services_i = 1; $hr_services_i <= 3; $hr_services_i++) : ?>
                              <?php if (get_theme_mod('hr_services_tab_heading' . $hr_services_i) != '') : ?>
                                <div class="bottom-tab-details d-flex align-items-center py-2 my-xl-2">
                                  <?php
                                  $hr_services_icon_class = get_theme_mod('hr_services_tab_icon' . $hr_services_i);
                                  if (!$hr_services_icon_class) {
                                      $hr_services_icon_class = 'fas fa-check'; // Default icon
                                  }
                                  ?>
                                  <i class="me-2 <?php echo esc_attr($hr_services_icon_class); ?>"></i>
                                  <h3 class="m-0"><?php echo esc_html(get_theme_mod('hr_services_tab_heading' . $hr_services_i)); ?></h3>
                                </div>
                              <?php endif; ?>
                            <?php endfor; ?>
                          </div>
                          <?php endif; ?>
                        </div>
                      </div>
                    </div>
                  </div>
                <?php endwhile;
                wp_reset_postdata();
            endif;
        endif; ?>
    </div>
</section>
<?php endif; ?>