<?php
/**
 * The template for displaying 404 pages (not found)
 *
 * @package Nihongo
 */

get_header(); ?>

<main id="main" class="site-main">
    <!-- 404 Hero Section -->
    <section class="error-hero">
        <div class="error-hero-background">
            <img src="<?php echo get_template_directory_uri(); ?>/assets/img/n1.jpg" alt="<?php echo nihongo_translate('page_not_found'); ?>" class="error-hero-image">
            <div class="error-hero-overlay"></div>
        </div>
        <div class="container">
            <div class="error-hero-content">
                <h1 class="error-code">404</h1>
                <h2 class="error-title"><?php echo nihongo_translate('page_not_found'); ?></h2>
                <p class="error-subtitle"><?php echo nihongo_translate('page_not_found_message'); ?></p>
            </div>
        </div>
    </section>

    <!-- 404 Content Section -->
    <section class="section error-content">
        <div class="container">
            <div class="error-layout">
                <div class="error-main-content">
                    <div class="error-text">
                        <h3><?php echo nihongo_translate('what_can_you_do'); ?></h3>
                        <ul class="error-suggestions">
                            <li><?php echo nihongo_translate('check_url_spelling'); ?></li>
                            <li><?php echo nihongo_translate('use_navigation_menu'); ?></li>
                            <li><?php echo nihongo_translate('search_our_site'); ?></li>
                            <li><?php echo nihongo_translate('contact_us_for_help'); ?></li>
                        </ul>
                    </div>

                    <div class="error-search">
                        <h3><?php echo nihongo_translate('search_our_site'); ?></h3>
                        <?php get_search_form(); ?>
                    </div>

                    <div class="error-cta">
                        <a href="<?php echo home_url(); ?>" class="hero-cta">
                            <?php echo nihongo_translate('go_to_homepage'); ?>
                        </a>
                    </div>
                </div>

                <div class="error-sidebar">
                    <div class="error-info-card">
                        <h3><?php echo nihongo_translate('popular_pages'); ?></h3>
                        <ul class="popular-pages">
                            <li><a href="<?php echo home_url(); ?>"><?php echo nihongo_translate('nav_home'); ?></a></li>
                            <li><a href="<?php echo get_permalink(get_page_by_path('courses')); ?>"><?php echo nihongo_translate('nav_courses'); ?></a></li>
                            <li><a href="<?php echo get_permalink(get_page_by_path('j-bridge')); ?>"><?php echo nihongo_translate('nav_j_bridge'); ?></a></li>
                            <li><a href="<?php echo get_permalink(get_page_by_path('contact')); ?>"><?php echo nihongo_translate('nav_contact'); ?></a></li>
                            <li><a href="<?php echo get_permalink(get_page_by_path('news')); ?>"><?php echo nihongo_translate('news_title'); ?></a></li>
                            <li><a href="<?php echo get_permalink(get_page_by_path('voices')); ?>"><?php echo nihongo_translate('voices_title'); ?></a></li>
                        </ul>
                    </div>

                    <div class="error-contact-card">
                        <h3><?php echo nihongo_translate('need_help'); ?></h3>
                        <p><?php echo nihongo_translate('contact_us_for_assistance'); ?></p>
                        <a href="<?php echo get_permalink(get_page_by_path('contact')); ?>" class="btn-secondary">
                            <?php echo nihongo_translate('contact_us'); ?>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Recent Content Section -->
    <section class="section recent-content">
        <div class="container">
            <h2 class="section-title"><?php echo nihongo_translate('recent_content'); ?></h2>
            
            <div class="recent-content-grid">
                <!-- Recent Courses -->
                <div class="recent-section">
                    <h3><?php echo nihongo_translate('recent_courses'); ?></h3>
                    <?php
                    $recent_courses = get_posts(array(
                        'post_type' => 'course',
                        'posts_per_page' => 3,
                        'orderby' => 'date',
                        'order' => 'DESC'
                    ));
                    ?>
                    <?php if ($recent_courses) : ?>
                        <div class="recent-items">
                            <?php foreach ($recent_courses as $course) : ?>
                                <div class="recent-item">
                                    <h4><a href="<?php echo get_permalink($course->ID); ?>"><?php echo esc_html($course->post_title); ?></a></h4>
                                    <p><?php echo esc_html($course->post_excerpt); ?></p>
                                </div>
                            <?php endforeach; ?>
                        </div>
                    <?php endif; ?>
                </div>

                <!-- Recent News -->
                <div class="recent-section">
                    <h3><?php echo nihongo_translate('recent_news'); ?></h3>
                    <?php
                    $recent_news = get_posts(array(
                        'post_type' => 'news',
                        'posts_per_page' => 3,
                        'orderby' => 'date',
                        'order' => 'DESC'
                    ));
                    ?>
                    <?php if ($recent_news) : ?>
                        <div class="recent-items">
                            <?php foreach ($recent_news as $news) : ?>
                                <div class="recent-item">
                                    <h4><a href="<?php echo get_permalink($news->ID); ?>"><?php echo esc_html($news->post_title); ?></a></h4>
                                    <p><?php echo esc_html($news->post_excerpt); ?></p>
                                </div>
                            <?php endforeach; ?>
                        </div>
                    <?php endif; ?>
                </div>

                <!-- Recent Testimonials -->
                <div class="recent-section">
                    <h3><?php echo nihongo_translate('recent_testimonials'); ?></h3>
                    <?php
                    $recent_testimonials = get_posts(array(
                        'post_type' => 'testimonial',
                        'posts_per_page' => 3,
                        'orderby' => 'date',
                        'order' => 'DESC'
                    ));
                    ?>
                    <?php if ($recent_testimonials) : ?>
                        <div class="recent-items">
                            <?php foreach ($recent_testimonials as $testimonial) : ?>
                                <div class="recent-item">
                                    <h4><a href="<?php echo get_permalink($testimonial->ID); ?>"><?php echo esc_html($testimonial->post_title); ?></a></h4>
                                    <p><?php echo esc_html($testimonial->post_excerpt); ?></p>
                                </div>
                            <?php endforeach; ?>
                        </div>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </section>
</main>

<?php get_footer(); ?>
