<section class="aboutus  section-container   ">
    <div class="container">


  <div class="col-12 see-all-lawyers">
    <a href="/staff/team/">See all Lawyers +</a>
    <br><br>
  </div>

</div>



<div class="container">
  <div class="row justify-content-center profile-card">
    <?php if (have_rows('our_team')) : ?>
      <?php while (have_rows('our_team')) : the_row(); ?>
        <?php
        // Get custom fields from the repeater
        $image = get_sub_field('team_member_image');
        $name = get_sub_field('team_member_name');
        $position = get_sub_field('team_member_position');
        $bio = get_sub_field('team_member_bio'); // Assuming a WYSIWYG field for bio

        // Contact Information
        $contact_info = get_sub_field('team_member_contact');
        $phone = $contact_info['phone'];
        $mobile = $contact_info['mobile'];
        $email = $contact_info['email'];

        // Social Media
        $social_media = get_sub_field('team_member_social');

        // Qualifications
        $qualifications = get_sub_field('team_member_qualifications');
        $memberships = get_sub_field('team_member_memberships'); // Assuming similar structure for memberships
        ?>
        <div class="col-md-5 text-center">
          <?php if ($image) : ?>
            <img src="<?php echo esc_url($image['url']); ?>" alt="<?php echo esc_attr($name); ?>" class="img-fluid profile-image rounded-card">
          <?php endif; ?>
        </div>

        <div class="col-md-7">
          <div class="row">
            <div class="col-12">
              <h2 class="title-team"><?php echo esc_html($name); ?></h2>
              <h3 class="card__title_white"><?php echo esc_html($position); ?></h3>
              <div><?php echo apply_filters('the_content', $bio); ?></div>
              <div class="contact-info">
                <?php if ($phone) : ?>
                  <p><i class="fas fa-phone-volume text-muted"></i> <a href="tel:<?php echo esc_attr($phone); ?>" class="text-primary"><?php echo esc_html($phone); ?></a></p>
                <?php endif; ?>
                <?php if ($mobile) : ?>
                  <p><i class="fas fa-mobile-alt text-muted"></i> <a href="tel:<?php echo esc_attr($mobile); ?>" class="text-primary"><?php echo esc_html($mobile); ?></a></p>
                <?php endif; ?>
                <?php if ($email) : ?>
                  <p><i class="fas fa-envelope-open-text text-muted"></i> <a href="mailto:<?php echo esc_attr($email); ?>" class="text-primary"><?php echo esc_html($email); ?></a></p>
                <?php endif; ?>
              </div>

              <div class="center text-left mt-4">
    <div id="social">
        <ul>
            <?php if ($social_media) : ?>
                <?php foreach ($social_media as $social) : ?>
                    <?php
                    // Get social platform and link
                    $platform = strtolower(esc_attr($social['social_platform']));
                    $link = esc_url($social['social_link']);
                    ?>
                    <li class="<?php echo esc_attr($platform); ?>">
                        <a href="<?php echo $link; ?>" target="_blank" class="border">
                            <i class="fab fa-<?php echo esc_attr($platform); ?>"></i>
                        </a>
                    </li>
                <?php endforeach; ?>
            <?php else : ?>
                <!-- Optionally display a message or fallback content if no social media links are provided -->
                <li>No social media links available.</li>
            <?php endif; ?>
        </ul>
    </div>
</div>

            </div>

          </div>
        </div>

  </div>
</div>

<div class="container">
  <div class="row justify-content-center mt-4">
    <div class="col-md-5">
      <div class="qualifications">
        <h4 class="card__title_white">Qualifications</h4>
        <ul class="custom-bullets">
          <?php if ($qualifications) : ?>
            <?php foreach ($qualifications as $qualification) : ?>
              <li><?php echo esc_html($qualification['qualification']); ?></li>
            <?php endforeach; ?>
          <?php endif; ?>
        </ul>
      </div>
    </div>

    <div class="col-md-5">
      <div class="memberships">
        <h4 class="card__title_white">Memberships</h4>
        <ul class="custom-bullets">
          <?php if ($memberships) : ?>
            <?php foreach ($memberships as $membership) : ?>
              <li><?php echo esc_html($membership['membership']); ?></li>
            <?php endforeach; ?>
          <?php endif; ?>
        </ul>
      </div>




    <?php endwhile; ?>
  <?php else : ?>
    <p><?php _e('No team member found.', 'text-domain'); ?></p>
  <?php endif; ?>
    </div>
  </div>
  <br> <br> <br>
  </section>

  <section class=" aboutus section-container container-white services section ">
  <div class="container">
    <h2 class="title-span-hd">Area of <span class="title-span-head">specialization </span></h2>
    <div class="row gy-4">
        <?php if (have_rows('our_team')) : ?>
            <?php while (have_rows('our_team')) : the_row(); ?>
                <?php
                // Get the selected specializations from the checkbox field
                $specializations = get_sub_field('specializations');
                
                if ($specializations) : ?>
                    <?php foreach ($specializations as $specialization) : ?>
                        <div class="col-lg-4 col-md-6 mt-3" data-aos="fade-up">
                            <div class="service-item position-relative">
                                <h3><?php echo esc_html($specialization); ?></h3>
                            </div>
                        </div>
                    <?php endforeach; ?>
                <?php endif; ?>
            <?php endwhile; ?>
        <?php else : ?>
            <p><?php _e('No specializations found.', 'text-domain'); ?></p>
        <?php endif; ?>
    </div>
</div>
<br> <br> <br>


  </section>

  <section class="Testimony section-container container-white blog-posts section">
    <div class="container">
      <p class="title-span-head">Publications </p>


      <div class="container">
    <div class="row gy-4">
        <?php
        // WP_Query setup for fetching recent posts
        $recent_posts = new WP_Query(array(
            'posts_per_page' => 3, // Number of posts to display
            'post_status'    => 'publish', // Only show published posts
        ));

        // Start the Loop
        if ($recent_posts->have_posts()) : 
            while ($recent_posts->have_posts()) : 
                $recent_posts->the_post(); ?>
                <div class="col-lg-4" data-aos="fade-up">
                    <article class="mt-4">
                        <div class="post-img position-relative overflow-hidden" >
                            <?php if (has_post_thumbnail()) : ?>
                                <img src="<?php the_post_thumbnail_url('blog-small'); ?>" class="img-fluid" alt="<?php the_title(); ?>">
                            <?php endif; ?>
                            <span class="post-date"><?php echo get_the_date('F j'); ?></span>
                        </div>

                        <div class="post-content d-flex flex-column">
                            <h3 class="post-title"><?php the_title(); ?></h3>
                            <div class="meta d-flex align-items-center">
                                <div class="d-flex align-items-center">
                                    <i class="bi bi-person"></i> <span class="ps-2">
                                    <?php 
                                    $fname = get_the_author_meta('first_name'); 
                                    $lname = get_the_author_meta('last_name');
                                    echo esc_html($fname . ' ' . $lname);
                                    ?>
                                    </span>
                                </div>
                                <span class="px-3 text-black-50">/</span>
                                <div class="d-flex align-items-center">
                                    <i class="bi bi-folder2"></i> <span class="ps-2"><?php the_category(', '); ?></span>
                                </div>
                            </div>
                            <p><?php echo wp_trim_words(get_the_excerpt(), 20, '...'); ?></p>
                            <a href="<?php the_permalink(); ?>" class="readmore stretched-link">
                                <span>Read More</span><i class="bi bi-arrow-right"></i>
                            </a>
                        </div>
                    </article>
                </div>
            <?php endwhile;
        else : ?>
            <p><?php esc_html_e('Sorry, no posts matched your criteria.'); ?></p>
        <?php endif; ?>

        <?php
        // Reset Post Data
        wp_reset_postdata();
        ?>
    </div>
</div>


      <div class="container -6 py-5">

      </div>
    </div>
    </section>