<!-- CTA Section -->
<section class="cta-section">
    <div class="cta-overlay"></div>
    <div class="container">
        <h2><?php _e('Travel beyond your imagination, with our Travel Agency!', 'travel-mountain'); ?></h2>
        <div class="cta-buttons">
            <a href="<?php echo esc_url(home_url('/contact')); ?>" class="btn btn-cta-primary"><?php _e('Contact Us', 'travel-mountain'); ?></a>
            <a href="<?php echo esc_url(home_url('/packages')); ?>" class="btn btn-cta-outline"><?php _e('View Packages', 'travel-mountain'); ?></a>
        </div>
    </div>
</section>

<!-- Footer -->
<footer class="footer">
    <div class="container">
        <div class="footer-grid">
            <!-- Address Column -->
            <div class="footer-col">
                <h4><?php _e('Address', 'travel-mountain'); ?></h4>
                <?php
                $address = get_theme_mod('footer_address', "1080 Brickell Ave\nMiami - Florida\nU.S. of America");
                $address_lines = explode("\n", $address);
                ?>
                <ul class="footer-address">
                    <?php foreach ($address_lines as $line) : ?>
                        <li><?php echo esc_html($line); ?></li>
                    <?php endforeach; ?>
                </ul>
                <div class="footer-social">
                    <?php if (get_theme_mod('social_facebook')) : ?>
                        <a href="<?php echo esc_url(get_theme_mod('social_facebook')); ?>" target="_blank"><i class="fab fa-facebook-f"></i></a>
                    <?php endif; ?>
                    <?php if (get_theme_mod('social_twitter')) : ?>
                        <a href="<?php echo esc_url(get_theme_mod('social_twitter')); ?>" target="_blank"><i class="fab fa-twitter"></i></a>
                    <?php endif; ?>
                    <?php if (get_theme_mod('social_instagram')) : ?>
                        <a href="<?php echo esc_url(get_theme_mod('social_instagram')); ?>" target="_blank"><i class="fab fa-youtube"></i></a>
                    <?php endif; ?>
                </div>
            </div>
            
            <!-- Contact Column -->
            <div class="footer-col">
                <h4><?php _e('Contact', 'travel-mountain'); ?></h4>
                <p class="footer-email"><?php echo esc_html(get_theme_mod('contact_email', 'info@travel.com')); ?></p>
                <p class="footer-phone"><?php echo esc_html(get_theme_mod('contact_phone', '+1 836 483 384')); ?></p>
            </div>
            
            <!-- Quick Links Column -->
            <div class="footer-col">
                <h4><?php _e('Quick Links', 'travel-mountain'); ?></h4>
                <?php
                wp_nav_menu(array(
                    'theme_location' => 'footer',
                    'container' => false,
                    'menu_class' => 'footer-links',
                    'fallback_cb' => 'travel_mountain_footer_default_menu'
                ));
                ?>
            </div>
            
            <!-- Newsletter Column -->
            <div class="footer-col">
                <h4><?php _e('Newsletter', 'travel-mountain'); ?></h4>
                <p><?php _e('Discover the World, one Full Adventure at a Time!', 'travel-mountain'); ?></p>
                <form class="newsletter-form" method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>">
                    <input type="hidden" name="action" value="newsletter_signup">
                    <?php wp_nonce_field('newsletter_signup', 'newsletter_nonce'); ?>
                    <input type="email" name="newsletter_email" placeholder="<?php esc_attr_e('Your email address', 'travel-mountain'); ?>" required>
                    <button type="submit"><i class="fas fa-paper-plane"></i></button>
                </form>
            </div>
        </div>
    </div>
    
    <!-- Footer Bottom -->
    <div class="footer-bottom">
        <div class="container">
            <p><?php echo esc_html(get_theme_mod('footer_copyright', '© 2024 Travel Mountain. All Rights Reserved.')); ?></p>
        </div>
    </div>
</footer>

<?php wp_footer(); ?>
</body>
</html>

<?php
// Default footer menu
function travel_mountain_footer_default_menu() {
    ?>
    <ul class="footer-links">
        <li><a href="<?php echo esc_url(home_url('/')); ?>"><?php _e('Home', 'travel-mountain'); ?></a></li>
        <li><a href="<?php echo esc_url(home_url('/packages')); ?>"><?php _e('Packages', 'travel-mountain'); ?></a></li>
        <li><a href="<?php echo esc_url(home_url('/about')); ?>"><?php _e('About', 'travel-mountain'); ?></a></li>
    </ul>
    <?php
}

// Handle newsletter signup
add_action('admin_post_newsletter_signup', 'travel_mountain_newsletter_signup');
add_action('admin_post_nopriv_newsletter_signup', 'travel_mountain_newsletter_signup');

function travel_mountain_newsletter_signup() {
    if (isset($_POST['newsletter_nonce']) && wp_verify_nonce($_POST['newsletter_nonce'], 'newsletter_signup')) {
        $email = sanitize_email($_POST['newsletter_email']);
        
        // Save to database or integrate with email service
        // For now, we'll just redirect back
        
        wp_redirect(add_query_arg('newsletter', 'success', wp_get_referer()));
        exit;
    }
}
?>