<?php
/**
 * Template Name: Page d'accueil Luxury
 *
 * Template pour la page d'accueil avec design luxury premium
 *
 * @package ChaletMontagne
 * @since 1.0.0
 */

get_header();
?>

<main id="primary" class="site-main luxury-home" tabindex="-1">

    <?php while (have_posts()) : the_post(); ?>

        <!-- Hero Section Luxury -->
        <section class="luxury-hero-home">
            <?php
            $hero_bg_id = get_theme_mod('chaletmontagne_hero_bg');
            $hero_bg_url = $hero_bg_id ? wp_get_attachment_image_url($hero_bg_id, 'full') : '';
            ?>
            <div class="luxury-hero-background" <?php if ($hero_bg_url) echo 'style="background-image: url(' . esc_url($hero_bg_url) . ');"'; ?>></div>
            <div class="luxury-hero-overlay"></div>
            <div class="luxury-container">
                <div class="luxury-hero-content">
                    <span class="luxury-badge">
                        <?php echo esc_html(get_theme_mod('chaletmontagne_station_name', 'Collection Prestige')); ?>
                    </span>
                    <h1 class="luxury-hero-title">
                        <?php echo esc_html(get_theme_mod('chaletmontagne_hero_title', __('L\'Excellence Alpine à Votre Service', 'chalet-montagne'))); ?>
                    </h1>
                    <p class="luxury-hero-subtitle">
                        <?php echo esc_html(get_theme_mod('chaletmontagne_hero_subtitle', __('Découvrez nos chalets d\'exception nichés au cœur des Alpes françaises', 'chalet-montagne'))); ?>
                    </p>
                    <?php
                    $cta_url = get_theme_mod('chaletmontagne_hero_cta_url');
                    $cta_text = get_theme_mod('chaletmontagne_hero_cta_text', __('Découvrir la Collection', 'chalet-montagne'));
                    if ($cta_url) :
                    ?>
                        <a href="<?php echo esc_url($cta_url); ?>" class="luxury-btn luxury-btn-primary">
                            <?php echo esc_html($cta_text); ?>
                        </a>
                    <?php endif; ?>
                </div>
            </div>
        </section>

        <!-- Arguments de vente -->
        <section class="luxury-section luxury-features">
            <div class="luxury-container">
                <div class="luxury-section-header">
                    <div class="luxury-section-subtitle"><?php esc_html_e('Nos Services', 'chalet-montagne'); ?></div>
                    <h2 class="luxury-section-title"><?php esc_html_e('Une Expérience Sur Mesure', 'chalet-montagne'); ?></h2>
                </div>

                <div class="luxury-cards luxury-cards-3">
                    <?php for ($i = 1; $i <= 4; $i++) :
                        $arg_title = get_theme_mod("chaletmontagne_argument_{$i}_title");
                        $arg_text = get_theme_mod("chaletmontagne_argument_{$i}_text");
                        if ($arg_title || $arg_text) :
                    ?>
                        <div class="luxury-card">
                            <div class="luxury-card-icon">
                                <?php
                                // Icônes par défaut
                                $icons = array('🏔️', '✨', '🎿', '🏠');
                                echo esc_html($icons[$i - 1]);
                                ?>
                            </div>
                            <div class="luxury-card-content">
                                <?php if ($arg_title) : ?>
                                    <h3 class="luxury-card-title"><?php echo esc_html($arg_title); ?></h3>
                                <?php endif; ?>
                                <?php if ($arg_text) : ?>
                                    <p class="luxury-card-text"><?php echo esc_html($arg_text); ?></p>
                                <?php endif; ?>
                            </div>
                        </div>
                    <?php
                        endif;
                    endfor;
                    ?>
                </div>
            </div>
        </section>

        <!-- Contenu de la page -->
        <?php if (get_the_content()) : ?>
        <section class="luxury-section luxury-page-content">
            <div class="luxury-container luxury-container-narrow">
                <div class="entry-content">
                    <?php the_content(); ?>
                </div>
            </div>
        </section>
        <?php endif; ?>

        <!-- Section Station Info -->
        <?php
        $station_name = get_theme_mod('chaletmontagne_station_name');
        $station_distance = get_theme_mod('chaletmontagne_station_distance');
        $station_activities = get_theme_mod('chaletmontagne_station_activities');

        if ($station_name || $station_distance || $station_activities) :
        ?>
        <section class="luxury-section luxury-station-info">
            <div class="luxury-container">
                <div class="luxury-section-header">
                    <div class="luxury-section-subtitle"><?php esc_html_e('Notre Destination', 'chalet-montagne'); ?></div>
                    <h2 class="luxury-section-title">
                        <?php echo esc_html($station_name ?: __('La Station', 'chalet-montagne')); ?>
                    </h2>
                </div>

                <div class="luxury-info-grid">
                    <?php if ($station_distance) : ?>
                        <div class="luxury-info-item">
                            <div class="luxury-info-icon">🎿</div>
                            <h3 class="luxury-info-title"><?php esc_html_e('Accès aux pistes', 'chalet-montagne'); ?></h3>
                            <p class="luxury-info-text"><?php echo esc_html($station_distance); ?></p>
                        </div>
                    <?php endif; ?>

                    <?php
                    $center_distance = get_theme_mod('chaletmontagne_center_distance');
                    if ($center_distance) :
                    ?>
                        <div class="luxury-info-item">
                            <div class="luxury-info-icon">🏘️</div>
                            <h3 class="luxury-info-title"><?php esc_html_e('Centre du village', 'chalet-montagne'); ?></h3>
                            <p class="luxury-info-text"><?php echo esc_html($center_distance); ?></p>
                        </div>
                    <?php endif; ?>

                    <?php if ($station_activities) : ?>
                        <div class="luxury-info-item luxury-info-item-wide">
                            <div class="luxury-info-icon">⛷️</div>
                            <h3 class="luxury-info-title"><?php esc_html_e('Activités disponibles', 'chalet-montagne'); ?></h3>
                            <p class="luxury-info-text"><?php echo esc_html($station_activities); ?></p>
                        </div>
                    <?php endif; ?>
                </div>
            </div>
        </section>
        <?php endif; ?>

        <!-- CTA Section -->
        <section class="luxury-section luxury-cta">
            <div class="luxury-container">
                <div class="luxury-cta-content">
                    <h2 class="luxury-cta-title">
                        <?php esc_html_e('Réservez Votre Séjour d\'Exception', 'chalet-montagne'); ?>
                    </h2>
                    <p class="luxury-cta-text">
                        <?php esc_html_e('Notre équipe est à votre disposition pour créer l\'expérience parfaite adaptée à vos attentes.', 'chalet-montagne'); ?>
                    </p>
                    <?php
                    $phone = get_theme_mod('chaletmontagne_phone');
                    $email = get_theme_mod('chaletmontagne_email');
                    ?>
                    <div class="luxury-cta-buttons">
                        <?php if ($phone) : ?>
                            <a href="tel:<?php echo esc_attr(str_replace(' ', '', $phone)); ?>" class="luxury-btn luxury-btn-primary">
                                <?php esc_html_e('Nous Appeler', 'chalet-montagne'); ?>
                            </a>
                        <?php endif; ?>
                        <?php if ($email) : ?>
                            <a href="mailto:<?php echo esc_attr($email); ?>" class="luxury-btn luxury-btn-secondary">
                                <?php esc_html_e('Nous Contacter', 'chalet-montagne'); ?>
                            </a>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        </section>

    <?php endwhile; ?>

</main>

<?php
get_footer();
