<?php
/**
 * Search Results Template
 *
 * @package Navier_Instruments
 */

get_header();
?>

<div class="archive-header">
    <div class="container">
        <h1 class="page-title">
            <?php
            printf(
                /* translators: %s: search query */
                esc_html__('Search Results for: %s', 'navier-instruments'),
                '<span>' . get_search_query() . '</span>'
            );
            ?>
        </h1>
    </div>
</div>

<div class="container">
    <?php if (have_posts()) : ?>
        <p style="margin-bottom: var(--spacing-xl);">
            <?php
            printf(
                /* translators: %d: number of results */
                esc_html(_n('%d result found', '%d results found', $wp_query->found_posts, 'navier-instruments')),
                $wp_query->found_posts
            );
            ?>
        </p>

        <div class="posts-grid">
            <?php
            while (have_posts()) :
                the_post();
                get_template_part('template-parts/content', 'search');
            endwhile;
            ?>
        </div>

        <?php
        the_posts_pagination(array(
            'mid_size'  => 2,
            'prev_text' => '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"></polyline></svg>',
            'next_text' => '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"></polyline></svg>',
        ));
        ?>

    <?php else : ?>
        <div class="no-results" style="padding: var(--spacing-4xl) 0; text-align: center;">
            <h2><?php esc_html_e('Nothing Found', 'navier-instruments'); ?></h2>
            <p><?php esc_html_e('Sorry, but nothing matched your search terms. Please try again with different keywords.', 'navier-instruments'); ?></p>
            <?php get_search_form(); ?>
        </div>
    <?php endif; ?>
</div>

<?php
get_footer();
