<?php get_header(); ?>

<main id="main" class="wpbs-content-area">
    <div class="container py-5">
        <header class="mb-4">
            <h1 class="h3">
                <?php printf(esc_html__('Search Results for: %s', 'wpbs-theme'), '<span class="text-primary">' . get_search_query() . '</span>'); ?>
            </h1>
        </header>

        <?php if (have_posts()) : ?>
            <div class="list-group list-group-flush">
                <?php while (have_posts()) : the_post(); ?>
                    <a href="<?php the_permalink(); ?>" class="list-group-item list-group-item-action py-3">
                        <h2 class="h5 mb-1"><?php the_title(); ?></h2>
                        <p class="mb-1 text-muted small"><?php echo get_the_excerpt(); ?></p>
                        <small class="text-muted"><?php echo get_the_date(); ?></small>
                    </a>
                <?php endwhile; ?>
            </div>

            <nav class="mt-4">
                <?php the_posts_pagination(['class' => 'pagination justify-content-center']); ?>
            </nav>
        <?php else : ?>
            <div class="text-center py-5">
                <p class="text-muted"><?php esc_html_e('No results found. Try a different search.', 'wpbs-theme'); ?></p>
                <?php get_search_form(); ?>
            </div>
        <?php endif; ?>
    </div>
</main>

<?php get_footer(); ?>
