<?php
/**
 * Travel Mountain WordPress Theme
 * Functions and definitions
 */

// Theme Setup
function travel_mountain_setup()
{
    // Styles
    wp_enqueue_style('google-fonts', 'https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Montserrat:wght@300;400;500;600;700&display=swap', array(), null);
    wp_enqueue_style('font-awesome', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css', array(), '6.5.1');
    wp_enqueue_style('travel-mountain-style', get_stylesheet_uri(), array(), '1.0.0');
    wp_enqueue_style('travel-mountain-main', get_template_directory_uri() . '/css/style.css', array(), '1.0.0');
    // Add theme support
    add_theme_support('title-tag');
    add_theme_support('post-thumbnails');
    add_theme_support('custom-logo');
    add_theme_support('html5', array('search-form', 'comment-form', 'comment-list', 'gallery', 'caption'));

    register_nav_menus(array(
        'primary' => __('Primary Menu', 'travel-mountain'),
        'footer' => __('Footer Menu', 'travel-mountain')
    ));

    add_image_size('package-thumbnail', 600, 250, true);
    add_image_size('destination-thumbnail', 800, 450, true);
    add_image_size('blog-thumbnail', 800, 300, true);
}
add_action('after_setup_theme', 'travel_mountain_setup');

// Enqueue Scripts and Styles
function travel_mountain_scripts()
{
    wp_enqueue_style('google-fonts', 'https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Montserrat:wght@300;400;500;600;700&display=swap', array(), null);
    wp_enqueue_style('font-awesome', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css', array(), '6.5.1');

    // Slick Carousel
    wp_enqueue_style('slick-css', 'https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.css', array(), '1.8.1');
    wp_enqueue_style('slick-theme-css', 'https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick-theme.min.css', array(), '1.8.1');

    wp_enqueue_style('travel-mountain-style', get_stylesheet_uri(), array(), '1.0.0');
    wp_enqueue_style('travel-mountain-main', get_template_directory_uri() . '/css/style.css', array(), '1.0.0');

    // jQuery (WordPress includes it)
    wp_enqueue_script('jquery');

    // Slick Carousel
    wp_enqueue_script('slick-js', 'https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.js', array('jquery'), '1.8.1', true);

    wp_enqueue_script('travel-mountain-main', get_template_directory_uri() . '/js/main.js', array('jquery'), '1.0.0', true);
}
add_action('wp_enqueue_scripts', 'travel_mountain_scripts');

// Register Custom Post Types
function travel_mountain_register_post_types()
{

    // Travel Packages
    register_post_type('package', array(
        'labels' => array(
            'name' => __('Travel Packages', 'travel-mountain'),
            'singular_name' => __('Package', 'travel-mountain'),
            'add_new' => __('Add New Package', 'travel-mountain')
        ),
        'public' => true,
        'has_archive' => true,
        'menu_icon' => 'dashicons-palmtree',
        'supports' => array('title', 'editor', 'thumbnail', 'excerpt'),
        'rewrite' => array('slug' => 'packages')
    ));

    // Destinations
    register_post_type('destination', array(
        'labels' => array(
            'name' => __('Destinations', 'travel-mountain'),
            'singular_name' => __('Destination', 'travel-mountain')
        ),
        'public' => true,
        'has_archive' => true,
        'menu_icon' => 'dashicons-location-alt',
        'supports' => array('title', 'editor', 'thumbnail'),
        'rewrite' => array('slug' => 'destinations')
    ));

    // Testimonials
    register_post_type('testimonial', array(
        'labels' => array(
            'name' => __('Testimonials', 'travel-mountain'),
            'singular_name' => __('Testimonial', 'travel-mountain')
        ),
        'public' => true,
        'menu_icon' => 'dashicons-format-quote',
        'supports' => array('title', 'editor', 'thumbnail'),
        'show_in_rest' => true
    ));

    // Experiences
    register_post_type('experience', array(
        'labels' => array(
            'name' => __('Experiences', 'travel-mountain'),
            'singular_name' => __('Experience', 'travel-mountain')
        ),
        'public' => true,
        'menu_icon' => 'dashicons-star-filled',
        'supports' => array('title'),
        'show_in_rest' => true
    ));

    // Pricing Plans
    register_post_type('pricing', array(
        'labels' => array(
            'name' => __('Pricing Plans', 'travel-mountain'),
            'singular_name' => __('Pricing Plan', 'travel-mountain')
        ),
        'public' => true,
        'menu_icon' => 'dashicons-tag',
        'supports' => array('title', 'editor'),
        'show_in_rest' => true
    ));

    // Partners
    register_post_type('partner', array(
        'labels' => array(
            'name' => __('Travel Partners', 'travel-mountain'),
            'singular_name' => __('Partner', 'travel-mountain')
        ),
        'public' => true,
        'menu_icon' => 'dashicons-groups',
        'supports' => array('title'),
        'show_in_rest' => true
    ));

    // Hero Slides
    register_post_type('hero_slide', array(
        'labels' => array(
            'name' => __('Hero Slides', 'travel-mountain'),
            'singular_name' => __('Hero Slide', 'travel-mountain'),
            'add_new' => __('Add New Slide', 'travel-mountain'),
            'add_new_item' => __('Add New Hero Slide', 'travel-mountain')
        ),
        'public' => true,
        'menu_icon' => 'dashicons-images-alt2',
        'supports' => array('title', 'editor', 'thumbnail', 'page-attributes'),
        'show_in_rest' => true
    ));

    // Company Values (for About Page)
    register_post_type('company_value', array(
        'labels' => array(
            'name' => __('Company Values', 'travel-mountain'),
            'singular_name' => __('Company Value', 'travel-mountain'),
            'add_new' => __('Add New Value', 'travel-mountain')
        ),
        'public' => true,
        'menu_icon' => 'dashicons-heart',
        'supports' => array('title', 'editor', 'page-attributes'),
        'show_in_rest' => true
    ));

    // Team Members (for About Page)
    register_post_type('team_member', array(
        'labels' => array(
            'name' => __('Team Members', 'travel-mountain'),
            'singular_name' => __('Team Member', 'travel-mountain'),
            'add_new' => __('Add New Member', 'travel-mountain')
        ),
        'public' => true,
        'menu_icon' => 'dashicons-businessperson',
        'supports' => array('title', 'editor', 'thumbnail', 'page-attributes'),
        'show_in_rest' => true
    ));
}
add_action('init', 'travel_mountain_register_post_types');

// Add Custom Meta Boxes
function travel_mountain_add_meta_boxes()
{
    add_meta_box('package_details', __('Package Details', 'travel-mountain'), 'travel_mountain_package_meta_box', 'package', 'normal', 'high');
    add_meta_box('destination_details', __('Destination Details', 'travel-mountain'), 'travel_mountain_destination_meta_box', 'destination', 'normal', 'high');
    add_meta_box('testimonial_details', __('Testimonial Details', 'travel-mountain'), 'travel_mountain_testimonial_meta_box', 'testimonial', 'normal', 'high');
    add_meta_box('experience_details', __('Experience Icon', 'travel-mountain'), 'travel_mountain_experience_meta_box', 'experience', 'normal', 'high');
    add_meta_box('pricing_details', __('Pricing Details', 'travel-mountain'), 'travel_mountain_pricing_meta_box', 'pricing', 'normal', 'high');
    add_meta_box('partner_details', __('Partner Icon', 'travel-mountain'), 'travel_mountain_partner_meta_box', 'partner', 'normal', 'high');
    add_meta_box('hero_slide_details', __('Hero Slide Details', 'travel-mountain'), 'travel_mountain_hero_slide_meta_box', 'hero_slide', 'normal', 'high');

    // About Page Meta Boxes
    add_meta_box('about_hero_details', __('Hero Section', 'travel-mountain'), 'travel_mountain_about_hero_meta_box', 'page', 'normal', 'high');
    add_meta_box('about_mission_details', __('Mission Section', 'travel-mountain'), 'travel_mountain_about_mission_meta_box', 'page', 'normal', 'high');
    add_meta_box('about_story_details', __('Story Section', 'travel-mountain'), 'travel_mountain_about_story_meta_box', 'page', 'normal', 'high');
    add_meta_box('about_vision_details', __('Vision Section', 'travel-mountain'), 'travel_mountain_about_vision_meta_box', 'page', 'normal', 'high');


    // Company Value Meta Box
    add_meta_box('value_details', __('Value Icon', 'travel-mountain'), 'travel_mountain_value_meta_box', 'company_value', 'normal', 'high');

    // Team Member Meta Box
    add_meta_box('team_details', __('Team Member Details', 'travel-mountain'), 'travel_mountain_team_meta_box', 'team_member', 'normal', 'high');
}
add_action('add_meta_boxes', 'travel_mountain_add_meta_boxes');

// Package Meta Box
function travel_mountain_package_meta_box($post)
{
    wp_nonce_field('package_meta_box', 'package_meta_box_nonce');
    $city = get_post_meta($post->ID, '_package_city', true);
    $country = get_post_meta($post->ID, '_package_country', true);
    $duration = get_post_meta($post->ID, '_package_duration', true);
    $price = get_post_meta($post->ID, '_package_price', true);
    $old_price = get_post_meta($post->ID, '_package_old_price', true);
    $on_sale = get_post_meta($post->ID, '_package_on_sale', true);
    ?>
    <p><label><strong>Package:</strong></label><br>
        <input type="text" name="package_city" value="<?php echo esc_attr($city); ?>" style="width:100%;">
    </p>
    <p><label><strong>Duration:</strong></label><br>
        <input type="text" name="package_duration" value="<?php echo esc_attr($duration); ?>" style="width:100%;">
    </p>
    <p><label><strong>Price ($):</strong></label><br>
        <input type="number" name="package_price" value="<?php echo esc_attr($price); ?>" style="width:100%;">
    </p>
    <p><label><strong>Old Price ($):</strong></label><br>
        <input type="number" name="package_old_price" value="<?php echo esc_attr($old_price); ?>" style="width:100%;">
    </p>
    <p><label><input type="checkbox" name="package_on_sale" value="1" <?php checked($on_sale, '1'); ?>> Show "SALE"
            Badge</label></p>
    <?php
}

// Destination Meta Box
function travel_mountain_destination_meta_box($post)
{
    wp_nonce_field('destination_meta_box', 'destination_meta_box_nonce');
    $subtitle = get_post_meta($post->ID, '_destination_subtitle', true);
    ?>
    <p><label><strong>Subtitle:</strong></label><br>
        <input type="text" name="destination_subtitle" value="<?php echo esc_attr($subtitle); ?>" style="width:100%;">
    </p>
    <?php
}

// Testimonial Meta Box
function travel_mountain_testimonial_meta_box($post)
{
    wp_nonce_field('testimonial_meta_box', 'testimonial_meta_box_nonce');
    $author_name = get_post_meta($post->ID, '_testimonial_author', true);
    $location = get_post_meta($post->ID, '_testimonial_location', true);
    ?>
    <p><label><strong>Author Name:</strong></label><br>
        <input type="text" name="testimonial_author" value="<?php echo esc_attr($author_name); ?>" style="width:100%;">
    </p>
    <p><label><strong>Location:</strong></label><br>
        <input type="text" name="testimonial_location" value="<?php echo esc_attr($location); ?>" style="width:100%;">
    </p>
    <?php
}

// Experience Meta Box
function travel_mountain_experience_meta_box($post)
{
    wp_nonce_field('experience_meta_box', 'experience_meta_box_nonce');
    $icon = get_post_meta($post->ID, '_experience_icon', true);
    ?>
    <p><label><strong>Font Awesome Icon Class:</strong></label><br>
        <input type="text" name="experience_icon" value="<?php echo esc_attr($icon); ?>" style="width:100%;"
            placeholder="fa-horse">
        <br><small>Visit <a href="https://fontawesome.com/icons" target="_blank">Font Awesome</a> for icon classes</small>
    </p>
    <?php
}

// Pricing Meta Box
function travel_mountain_pricing_meta_box($post)
{
    wp_nonce_field('pricing_meta_box', 'pricing_meta_box_nonce');
    $price = get_post_meta($post->ID, '_pricing_price', true);
    $period = get_post_meta($post->ID, '_pricing_period', true);
    $currency = get_post_meta($post->ID, '_pricing_currency', true);
    $features = get_post_meta($post->ID, '_pricing_features', true);
    $button_text = get_post_meta($post->ID, '_pricing_button_text', true);
    $button_url = get_post_meta($post->ID, '_pricing_button_url', true);
    $is_popular = get_post_meta($post->ID, '_pricing_popular', true);
    $display_order = get_post_meta($post->ID, '_pricing_order', true);
    ?>
    <p><label><strong>Price:</strong></label><br>
        <input type="number" name="pricing_price" value="<?php echo esc_attr($price); ?>" style="width:100%;">
    </p>
    <p><label><strong>Currency:</strong></label><br>
        <input type="text" name="pricing_currency" value="<?php echo esc_attr($currency ? $currency : '$'); ?>"
            style="width:100px;">
    </p>
    <p><label><strong>Period:</strong></label><br>
        <input type="text" name="pricing_period" value="<?php echo esc_attr($period ? $period : '/ Day'); ?>"
            style="width:100%;">
    </p>
    <p><label><strong>Features (one per line):</strong></label><br>
        <textarea name="pricing_features" rows="8" style="width:100%;"><?php echo esc_textarea($features); ?></textarea>
        <br><small>Start with ✓ for included, ✗ for not included</small>
    </p>
    <p><label><strong>Button Text:</strong></label><br>
        <input type="text" name="pricing_button_text"
            value="<?php echo esc_attr($button_text ? $button_text : 'View Trips'); ?>" style="width:100%;">
    </p>
    <p><label><strong>Button URL:</strong></label><br>
        <input type="url" name="pricing_button_url" value="<?php echo esc_url($button_url); ?>" style="width:100%;">
    </p>
    <p><label><strong>Display Order:</strong></label><br>
        <input type="number" name="pricing_order" value="<?php echo esc_attr($display_order ? $display_order : 0); ?>"
            style="width:100px;">
    </p>
    <p><label><input type="checkbox" name="pricing_popular" value="1" <?php checked($is_popular, '1'); ?>> Mark as
            POPULAR</label></p>
    <?php
}

// Partner Meta Box
function travel_mountain_partner_meta_box($post)
{
    wp_nonce_field('partner_meta_box', 'partner_meta_box_nonce');
    $icon = get_post_meta($post->ID, '_partner_icon', true);
    ?>
    <p><label><strong>Font Awesome Icon Class:</strong></label><br>
        <input type="text" name="partner_icon" value="<?php echo esc_attr($icon); ?>" style="width:100%;"
            placeholder="fa-plane">
        <br><small>Visit <a href="https://fontawesome.com/icons" target="_blank">Font Awesome</a> for icon classes</small>
    </p>
    <?php
}

// Hero Slide Meta Box
function travel_mountain_hero_slide_meta_box($post)
{
    wp_nonce_field('hero_slide_meta_box', 'hero_slide_meta_box_nonce');

    //    $subtitle = get_post_meta($post->ID, '_hero_subtitle', true);
//    $tagline = get_post_meta($post->ID, '_hero_tagline', true);
    $button_text = get_post_meta($post->ID, '_hero_button_text', true);
    $button_url = get_post_meta($post->ID, '_hero_button_url', true);
    ?>

    <p><label><strong>Button Text:</strong></label><br>
        <input type="text" name="hero_button_text"
            value="<?php echo esc_attr($button_text ? $button_text : 'More Info'); ?>" style="width:100%;">
    </p>

    <p><label><strong>Button URL:</strong></label><br>
        <input type="url" name="hero_button_url" value="<?php echo esc_url($button_url); ?>" style="width:100%;"
            placeholder="https://">
    </p>

    <hr style="margin: 20px 0;">

    <p><strong>Instructions:</strong></p>
    <ul style="margin-left: 20px; line-height: 1.8;">
        <li><strong>Title:</strong> Used as main heading (large text)</li>
        <li><strong>Content Editor:</strong> Used as description paragraph</li>
        <li><strong>Featured Image:</strong> Background image for this slide (1920x1080px recommended)</li>
        <li><strong>Order:</strong> Use "Order" field (right sidebar) to control slide sequence</li>
    </ul>
    <?php
}

// About Page - Hero Section Meta Box
function travel_mountain_about_hero_meta_box($post)
{
    wp_nonce_field('about_hero_meta_box', 'about_hero_meta_box_nonce');
    $hero_image = get_post_meta($post->ID, '_about_hero_image', true);
    $hero_subtitle = get_post_meta($post->ID, '_about_hero_subtitle', true);
    ?>
    <p><label><strong>Hero Subtitle:</strong></label><br>
        <input type="text" name="about_hero_subtitle" value="<?php echo esc_attr($hero_subtitle); ?>" style="width:100%;"
            placeholder="e.g., About Us">
    </p>

    <p><label><strong>Hero Background Image URL:</strong></label><br>
        <input type="url" name="about_hero_image" value="<?php echo esc_url($hero_image); ?>" style="width:100%;"
            placeholder="https://">
    </p>

    <p><small><strong>Note:</strong> You can also use the Featured Image as the hero background (if Hero Background Image
            URL is empty).</small></p>
    <?php
}

// About Page - Mission Section Meta Box
function travel_mountain_about_mission_meta_box($post)
{
    wp_nonce_field('about_mission_meta_box', 'about_mission_meta_box_nonce');
    $mission_title = get_post_meta($post->ID, '_about_mission_title', true);
    $mission_text = get_post_meta($post->ID, '_about_mission_text', true);
    $mission_image = get_post_meta($post->ID, '_about_mission_image', true);
    ?>
    <p><label><strong>Mission Title:</strong></label><br>
        <input type="text" name="about_mission_title" value="<?php echo esc_attr($mission_title); ?>" style="width:100%;"
            placeholder="e.g., Our Mission">
    </p>

    <p><label><strong>Mission Text:</strong></label><br>
        <textarea name="about_mission_text" rows="6"
            style="width:100%;"><?php echo esc_textarea($mission_text); ?></textarea>
    </p>

    <p><label><strong>Mission Image URL:</strong></label><br>
        <input type="url" name="about_mission_image" value="<?php echo esc_url($mission_image); ?>" style="width:100%;"
            placeholder="https://">
    </p>
    <?php
}

// About Page - Story Section Meta Box
function travel_mountain_about_story_meta_box($post)
{
    wp_nonce_field('about_story_meta_box', 'about_story_meta_box_nonce');
    $story_title = get_post_meta($post->ID, '_about_story_title', true);
    $story_text = get_post_meta($post->ID, '_about_story_text', true);
    $story_image = get_post_meta($post->ID, '_about_story_image', true);
    ?>
    <p><label><strong>Story Title:</strong></label><br>
        <input type="text" name="about_story_title" value="<?php echo esc_attr($story_title); ?>" style="width:100%;"
            placeholder="e.g., Our Story">
    </p>

    <p><label><strong>Story Text:</strong></label><br>
        <textarea name="about_story_text" rows="6" style="width:100%;"><?php echo esc_textarea($story_text); ?></textarea>
    </p>

    <p><label><strong>Story Image URL:</strong></label><br>
        <input type="url" name="about_story_image" value="<?php echo esc_url($story_image); ?>" style="width:100%;"
            placeholder="https://">
    </p>
    <?php
}

// About Page - Vision Section Meta Box
function travel_mountain_about_vision_meta_box($post)
{
    wp_nonce_field('about_vision_meta_box', 'about_vision_meta_box_nonce');
    $vision_title = get_post_meta($post->ID, '_about_vision_title', true);
    $vision_text = get_post_meta($post->ID, '_about_vision_text', true);
    $vision_person_image = get_post_meta($post->ID, '_about_vision_person_image', true);
    $vision_person_name = get_post_meta($post->ID, '_about_vision_person_name', true);
    $vision_person_title = get_post_meta($post->ID, '_about_vision_person_title', true);
    ?>
    <p><label><strong>Vision Title:</strong></label><br>
        <input type="text" name="about_vision_title" value="<?php echo esc_attr($vision_title); ?>" style="width:100%;"
            placeholder="e.g., Our Vision">
    </p>

    <p><label><strong>Vision Text:</strong></label><br>
        <textarea name="about_vision_text" rows="6" style="width:100%;"><?php echo esc_textarea($vision_text); ?></textarea>
    </p>
    
    <hr style="margin: 25px 0;">
    
    <p><label><strong>Person Photo (Rounded):</strong></label><br>
        <input type="text" id="about_vision_person_image" name="about_vision_person_image" value="<?php echo esc_attr($vision_person_image); ?>" style="width:80%;">
        <button type="button" class="button" onclick="uploadVisionImage()">Upload Image</button>
    </p>
    <?php if ($vision_person_image): ?>
        <div style="margin: 10px 0;">
            <img src="<?php echo esc_url($vision_person_image); ?>" style="max-width: 150px; height: 150px; border-radius: 50%; object-fit: cover; border: 3px solid #ccc;">
        </div>
    <?php endif; ?>
    
    <p><label><strong>Person Name:</strong></label><br>
        <input type="text" name="about_vision_person_name" value="<?php echo esc_attr($vision_person_name); ?>" style="width:100%;"
            placeholder="e.g., John Doe">
    </p>
    
    <p><label><strong>Person Title/Position:</strong></label><br>
        <input type="text" name="about_vision_person_title" value="<?php echo esc_attr($vision_person_title); ?>" style="width:100%;"
            placeholder="e.g., Founder & CEO">
    </p>
    
    <script>
    function uploadVisionImage() {
        var custom_uploader = wp.media({
            title: 'Select Person Image',
            button: { text: 'Use this image' },
            multiple: false
        })
        .on('select', function() {
            var attachment = custom_uploader.state().get('selection').first().toJSON();
            jQuery('#about_vision_person_image').val(attachment.url);
        })
        .open();
    }
    </script>
    <?php
}




// Company Value Meta Box
function travel_mountain_value_meta_box($post)
{
    wp_nonce_field('value_meta_box', 'value_meta_box_nonce');
    $icon = get_post_meta($post->ID, '_value_icon', true);
    ?>
    <p><label><strong>Font Awesome Icon Class:</strong></label><br>
        <input type="text" name="value_icon" value="<?php echo esc_attr($icon); ?>" style="width:100%;"
            placeholder="fa-heart">
        <br><small>Visit <a href="https://fontawesome.com/icons" target="_blank">Font Awesome</a> for icon classes</small>
    </p>

    <p><small><strong>Note:</strong> Use the content editor below to add the value description.</small></p>
    <?php
}

// Team Member Meta Box
function travel_mountain_team_meta_box($post)
{
    wp_nonce_field('team_meta_box', 'team_meta_box_nonce');
    $position = get_post_meta($post->ID, '_team_position', true);
    $facebook = get_post_meta($post->ID, '_team_facebook', true);
    $twitter = get_post_meta($post->ID, '_team_twitter', true);
    $instagram = get_post_meta($post->ID, '_team_instagram', true);
    ?>
    <p><label><strong>Position/Role:</strong></label><br>
        <input type="text" name="team_position" value="<?php echo esc_attr($position); ?>" style="width:100%;"
            placeholder="e.g., CEO & Founder">
    </p>

    <p><label><strong>Facebook URL:</strong></label><br>
        <input type="url" name="team_facebook" value="<?php echo esc_url($facebook); ?>" style="width:100%;"
            placeholder="https://facebook.com/...">
    </p>

    <p><label><strong>Twitter URL:</strong></label><br>
        <input type="url" name="team_twitter" value="<?php echo esc_url($twitter); ?>" style="width:100%;"
            placeholder="https://twitter.com/...">
    </p>

    <p><label><strong>Instagram URL:</strong></label><br>
        <input type="url" name="team_instagram" value="<?php echo esc_url($instagram); ?>" style="width:100%;"
            placeholder="https://instagram.com/...">
    </p>

    <p><small><strong>Note:</strong> Use the Featured Image for the team member photo and the content editor for their
            bio.</small></p>
    <?php
}

// Save Meta Box Data
function travel_mountain_save_meta_boxes($post_id)
{
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
        return;

    // Package
    if (isset($_POST['package_meta_box_nonce']) && wp_verify_nonce($_POST['package_meta_box_nonce'], 'package_meta_box')) {
        if (isset($_POST['package_city']))
            update_post_meta($post_id, '_package_city', sanitize_text_field($_POST['package_city']));
        if (isset($_POST['package_country']))
            update_post_meta($post_id, '_package_country', sanitize_text_field($_POST['package_country']));
        if (isset($_POST['package_duration']))
            update_post_meta($post_id, '_package_duration', sanitize_text_field($_POST['package_duration']));
        if (isset($_POST['package_price']))
            update_post_meta($post_id, '_package_price', sanitize_text_field($_POST['package_price']));
        if (isset($_POST['package_old_price']))
            update_post_meta($post_id, '_package_old_price', sanitize_text_field($_POST['package_old_price']));
        update_post_meta($post_id, '_package_on_sale', isset($_POST['package_on_sale']) ? '1' : '0');
    }

    // Destination
    if (isset($_POST['destination_meta_box_nonce']) && wp_verify_nonce($_POST['destination_meta_box_nonce'], 'destination_meta_box')) {
        if (isset($_POST['destination_subtitle']))
            update_post_meta($post_id, '_destination_subtitle', sanitize_text_field($_POST['destination_subtitle']));
    }

    // Testimonial
    if (isset($_POST['testimonial_meta_box_nonce']) && wp_verify_nonce($_POST['testimonial_meta_box_nonce'], 'testimonial_meta_box')) {
        if (isset($_POST['testimonial_author']))
            update_post_meta($post_id, '_testimonial_author', sanitize_text_field($_POST['testimonial_author']));
        if (isset($_POST['testimonial_location']))
            update_post_meta($post_id, '_testimonial_location', sanitize_text_field($_POST['testimonial_location']));
    }

    // Experience
    if (isset($_POST['experience_meta_box_nonce']) && wp_verify_nonce($_POST['experience_meta_box_nonce'], 'experience_meta_box')) {
        if (isset($_POST['experience_icon']))
            update_post_meta($post_id, '_experience_icon', sanitize_text_field($_POST['experience_icon']));
    }

    // Pricing
    if (isset($_POST['pricing_meta_box_nonce']) && wp_verify_nonce($_POST['pricing_meta_box_nonce'], 'pricing_meta_box')) {
        if (isset($_POST['pricing_price']))
            update_post_meta($post_id, '_pricing_price', sanitize_text_field($_POST['pricing_price']));
        if (isset($_POST['pricing_period']))
            update_post_meta($post_id, '_pricing_period', sanitize_text_field($_POST['pricing_period']));
        if (isset($_POST['pricing_currency']))
            update_post_meta($post_id, '_pricing_currency', sanitize_text_field($_POST['pricing_currency']));
        if (isset($_POST['pricing_features']))
            update_post_meta($post_id, '_pricing_features', sanitize_textarea_field($_POST['pricing_features']));
        if (isset($_POST['pricing_button_text']))
            update_post_meta($post_id, '_pricing_button_text', sanitize_text_field($_POST['pricing_button_text']));
        if (isset($_POST['pricing_button_url']))
            update_post_meta($post_id, '_pricing_button_url', esc_url_raw($_POST['pricing_button_url']));
        if (isset($_POST['pricing_order']))
            update_post_meta($post_id, '_pricing_order', intval($_POST['pricing_order']));
        update_post_meta($post_id, '_pricing_popular', isset($_POST['pricing_popular']) ? '1' : '0');
    }

    // Partner
    if (isset($_POST['partner_meta_box_nonce']) && wp_verify_nonce($_POST['partner_meta_box_nonce'], 'partner_meta_box')) {
        if (isset($_POST['partner_icon']))
            update_post_meta($post_id, '_partner_icon', sanitize_text_field($_POST['partner_icon']));
    }

    // Hero Slide
    if (isset($_POST['hero_slide_meta_box_nonce']) && wp_verify_nonce($_POST['hero_slide_meta_box_nonce'], 'hero_slide_meta_box')) {
        if (isset($_POST['hero_subtitle']))
            update_post_meta($post_id, '_hero_subtitle', sanitize_text_field($_POST['hero_subtitle']));
        if (isset($_POST['hero_tagline']))
            update_post_meta($post_id, '_hero_tagline', sanitize_text_field($_POST['hero_tagline']));
        if (isset($_POST['hero_button_text']))
            update_post_meta($post_id, '_hero_button_text', sanitize_text_field($_POST['hero_button_text']));
        if (isset($_POST['hero_button_url']))
            update_post_meta($post_id, '_hero_button_url', esc_url_raw($_POST['hero_button_url']));
    }

    // About Page - Hero Section
    if (isset($_POST['about_hero_meta_box_nonce']) && wp_verify_nonce($_POST['about_hero_meta_box_nonce'], 'about_hero_meta_box')) {
        if (isset($_POST['about_hero_subtitle']))
            update_post_meta($post_id, '_about_hero_subtitle', sanitize_text_field($_POST['about_hero_subtitle']));
        if (isset($_POST['about_hero_image']))
            update_post_meta($post_id, '_about_hero_image', esc_url_raw($_POST['about_hero_image']));
    }

    // About Page - Mission Section
    if (isset($_POST['about_mission_meta_box_nonce']) && wp_verify_nonce($_POST['about_mission_meta_box_nonce'], 'about_mission_meta_box')) {
        if (isset($_POST['about_mission_title']))
            update_post_meta($post_id, '_about_mission_title', sanitize_text_field($_POST['about_mission_title']));
        if (isset($_POST['about_mission_text']))
            update_post_meta($post_id, '_about_mission_text', sanitize_textarea_field($_POST['about_mission_text']));
        if (isset($_POST['about_mission_image']))
            update_post_meta($post_id, '_about_mission_image', esc_url_raw($_POST['about_mission_image']));
    }

    // About Page - Story Section
    if (isset($_POST['about_story_meta_box_nonce']) && wp_verify_nonce($_POST['about_story_meta_box_nonce'], 'about_story_meta_box')) {
        if (isset($_POST['about_story_title']))
            update_post_meta($post_id, '_about_story_title', sanitize_text_field($_POST['about_story_title']));
        if (isset($_POST['about_story_text']))
            update_post_meta($post_id, '_about_story_text', sanitize_textarea_field($_POST['about_story_text']));
        if (isset($_POST['about_story_image']))
            update_post_meta($post_id, '_about_story_image', esc_url_raw($_POST['about_story_image']));
    }

    // About Page - Vision Section
    if (isset($_POST['about_vision_meta_box_nonce']) && wp_verify_nonce($_POST['about_vision_meta_box_nonce'], 'about_vision_meta_box')) {
        if (isset($_POST['about_vision_title']))
            update_post_meta($post_id, '_about_vision_title', sanitize_text_field($_POST['about_vision_title']));
        if (isset($_POST['about_vision_text']))
            update_post_meta($post_id, '_about_vision_text', sanitize_textarea_field($_POST['about_vision_text']));
        if (isset($_POST['about_vision_person_image']))
            update_post_meta($post_id, '_about_vision_person_image', esc_url_raw($_POST['about_vision_person_image']));
        if (isset($_POST['about_vision_person_name']))
            update_post_meta($post_id, '_about_vision_person_name', sanitize_text_field($_POST['about_vision_person_name']));
        if (isset($_POST['about_vision_person_title']))
            update_post_meta($post_id, '_about_vision_person_title', sanitize_text_field($_POST['about_vision_person_title']));
    }

    // About Page - Values Section
    if (isset($_POST['about_values_meta_box_nonce']) && wp_verify_nonce($_POST['about_values_meta_box_nonce'], 'about_values_meta_box')) {
        if (isset($_POST['about_values_title']))
            update_post_meta($post_id, '_about_values_title', sanitize_text_field($_POST['about_values_title']));
    }

    // About Page - CTA Section
    if (isset($_POST['about_cta_meta_box_nonce']) && wp_verify_nonce($_POST['about_cta_meta_box_nonce'], 'about_cta_meta_box')) {
        if (isset($_POST['about_cta_title']))
            update_post_meta($post_id, '_about_cta_title', sanitize_text_field($_POST['about_cta_title']));
        if (isset($_POST['about_cta_button_text']))
            update_post_meta($post_id, '_about_cta_button_text', sanitize_text_field($_POST['about_cta_button_text']));
        if (isset($_POST['about_cta_button_url']))
            update_post_meta($post_id, '_about_cta_button_url', esc_url_raw($_POST['about_cta_button_url']));
    }

    // Company Value
    if (isset($_POST['value_meta_box_nonce']) && wp_verify_nonce($_POST['value_meta_box_nonce'], 'value_meta_box')) {
        if (isset($_POST['value_icon']))
            update_post_meta($post_id, '_value_icon', sanitize_text_field($_POST['value_icon']));
    }

    // Team Member
    if (isset($_POST['team_meta_box_nonce']) && wp_verify_nonce($_POST['team_meta_box_nonce'], 'team_meta_box')) {
        if (isset($_POST['team_position']))
            update_post_meta($post_id, '_team_position', sanitize_text_field($_POST['team_position']));
        if (isset($_POST['team_facebook']))
            update_post_meta($post_id, '_team_facebook', esc_url_raw($_POST['team_facebook']));
        if (isset($_POST['team_twitter']))
            update_post_meta($post_id, '_team_twitter', esc_url_raw($_POST['team_twitter']));
        if (isset($_POST['team_instagram']))
            update_post_meta($post_id, '_team_instagram', esc_url_raw($_POST['team_instagram']));
    }
}
add_action('save_post', 'travel_mountain_save_meta_boxes');

// Customizer Settings
function travel_mountain_customize_register($wp_customize)
{

    // Hero Section
    $wp_customize->add_section('hero_section', array('title' => __('Hero Section', 'travel-mountain'), 'priority' => 30));
    $wp_customize->add_setting('hero_subtitle', array('default' => 'Adventure'));
    $wp_customize->add_control('hero_subtitle', array('label' => __('Hero Subtitle', 'travel-mountain'), 'section' => 'hero_section', 'type' => 'text'));
    $wp_customize->add_setting('hero_tagline', array('default' => 'Dream Vacation Destination'));
    $wp_customize->add_control('hero_tagline', array('label' => __('Hero Tagline', 'travel-mountain'), 'section' => 'hero_section', 'type' => 'text'));
    $wp_customize->add_setting('hero_title', array('default' => 'Plan the Trip of a Lifetime with Ease'));
    $wp_customize->add_control('hero_title', array('label' => __('Hero Title', 'travel-mountain'), 'section' => 'hero_section', 'type' => 'textarea'));
    $wp_customize->add_setting('hero_description', array('default' => 'Whether you\'re looking for a romantic getaway...'));
    $wp_customize->add_control('hero_description', array('label' => __('Hero Description', 'travel-mountain'), 'section' => 'hero_section', 'type' => 'textarea'));

    // Contact Info
    $wp_customize->add_section('contact_info', array('title' => __('Contact Information', 'travel-mountain'), 'priority' => 35));
    $wp_customize->add_setting('contact_phone', array('default' => '+1 836 483 384'));
    $wp_customize->add_control('contact_phone', array('label' => __('Phone', 'travel-mountain'), 'section' => 'contact_info', 'type' => 'text'));
    $wp_customize->add_setting('contact_whatsapp_number', array('default' => '+1 836 483 384'));
    $wp_customize->add_control('contact_whatsapp_number', array('label' => __('WhatsApp Number (with country code)', 'travel-mountain'), 'section' => 'contact_info', 'type' => 'text', 'description' => __('Contact form submissions will open WhatsApp with this number', 'travel-mountain')));
    $wp_customize->add_setting('contact_email', array('default' => 'info@travel.com'));
    $wp_customize->add_control('contact_email', array('label' => __('Email', 'travel-mountain'), 'section' => 'contact_info', 'type' => 'email'));
    $wp_customize->add_setting('social_twitter', array('default' => '#'));
    $wp_customize->add_control('social_twitter', array('label' => __('Twitter URL', 'travel-mountain'), 'section' => 'contact_info', 'type' => 'url'));
    $wp_customize->add_setting('social_facebook', array('default' => '#'));
    $wp_customize->add_control('social_facebook', array('label' => __('Facebook URL', 'travel-mountain'), 'section' => 'contact_info', 'type' => 'url'));
    $wp_customize->add_setting('social_instagram', array('default' => '#'));
    $wp_customize->add_control('social_instagram', array('label' => __('Instagram URL', 'travel-mountain'), 'section' => 'contact_info', 'type' => 'url'));

    // Footer
    $wp_customize->add_section('footer_section', array('title' => __('Footer Settings', 'travel-mountain'), 'priority' => 40));
    $wp_customize->add_setting('footer_address', array('default' => "1080 Brickell Ave\nMiami - Florida\nU.S. of America"));
    $wp_customize->add_control('footer_address', array('label' => __('Footer Address', 'travel-mountain'), 'section' => 'footer_section', 'type' => 'textarea'));
    $wp_customize->add_setting('footer_copyright', array('default' => '© 2024 Travel Mountain. All Rights Reserved.'));
    $wp_customize->add_control('footer_copyright', array('label' => __('Copyright', 'travel-mountain'), 'section' => 'footer_section', 'type' => 'text'));

    // Pricing Section
    $wp_customize->add_section('pricing_section', array('title' => __('Pricing Section', 'travel-mountain'), 'priority' => 45));
    $wp_customize->add_setting('pricing_subtitle', array('default' => 'Clear Price'));
    $wp_customize->add_control('pricing_subtitle', array('label' => __('Subtitle', 'travel-mountain'), 'section' => 'pricing_section', 'type' => 'text'));
    $wp_customize->add_setting('pricing_title', array('default' => 'Affordable Travel Packages'));
    $wp_customize->add_control('pricing_title', array('label' => __('Title', 'travel-mountain'), 'section' => 'pricing_section', 'type' => 'text'));
    $wp_customize->add_setting('pricing_description', array('default' => 'We believe that everyone deserves to experience their dream vacation without breaking the bank.'));
    $wp_customize->add_control('pricing_description', array('label' => __('Description', 'travel-mountain'), 'section' => 'pricing_section', 'type' => 'textarea'));
    $wp_customize->add_setting('pricing_note', array('default' => '* All trips include medical insurance'));
    $wp_customize->add_control('pricing_note', array('label' => __('Note', 'travel-mountain'), 'section' => 'pricing_section', 'type' => 'text'));

    // Partners Section
    $wp_customize->add_section('partners_section', array('title' => __('Partners Section', 'travel-mountain'), 'priority' => 46));
    $wp_customize->add_setting('partners_title', array('default' => 'Travel Itineraries'));
    $wp_customize->add_control('partners_title', array('label' => __('Title', 'travel-mountain'), 'section' => 'partners_section', 'type' => 'text'));

    // Discover Section
    $wp_customize->add_section('discover_section', array('title' => __('Discover Section', 'travel-mountain'), 'priority' => 47));
    $wp_customize->add_setting('discover_subtitle', array('default' => 'Wandering Souls'));
    $wp_customize->add_control('discover_subtitle', array('label' => __('Subtitle', 'travel-mountain'), 'section' => 'discover_section', 'type' => 'text'));
    $wp_customize->add_setting('discover_title', array('default' => 'Discover Your Next Adventure'));
    $wp_customize->add_control('discover_title', array('label' => __('Title', 'travel-mountain'), 'section' => 'discover_section', 'type' => 'text'));
    $wp_customize->add_setting('discover_description', array('default' => 'Whether you\'re planning a romantic honeymoon or a family vacation...'));
    $wp_customize->add_control('discover_description', array('label' => __('Description', 'travel-mountain'), 'section' => 'discover_section', 'type' => 'textarea'));
    $wp_customize->add_setting('discover_image_1');
    $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'discover_image_1', array('label' => __('Image 1', 'travel-mountain'), 'section' => 'discover_section')));
    $wp_customize->add_setting('discover_label_1', array('default' => 'Organized Group Tour'));
    $wp_customize->add_control('discover_label_1', array('label' => __('Image 1 Label', 'travel-mountain'), 'section' => 'discover_section', 'type' => 'text'));
    $wp_customize->add_setting('discover_image_2');
    $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'discover_image_2', array('label' => __('Image 2', 'travel-mountain'), 'section' => 'discover_section')));
    $wp_customize->add_setting('discover_label_2', array('default' => 'Single Customized Trip'));
    $wp_customize->add_control('discover_label_2', array('label' => __('Image 2 Label', 'travel-mountain'), 'section' => 'discover_section', 'type' => 'text'));

    // TripAdvisor Section
    $wp_customize->add_section('tripadvisor_section', array('title' => __('TripAdvisor Section', 'travel-mountain'), 'priority' => 48));

    $wp_customize->add_setting('tripadvisor_show', array('default' => '1'));
    $wp_customize->add_control('tripadvisor_show', array(
        'label' => __('Show TripAdvisor Section', 'travel-mountain'),
        'section' => 'tripadvisor_section',
        'type' => 'checkbox'
    ));

    $wp_customize->add_setting('tripadvisor_title', array('default' => 'What Our Customers Say'));
    $wp_customize->add_control('tripadvisor_title', array(
        'label' => __('Section Title (Optional)', 'travel-mountain'),
        'section' => 'tripadvisor_section',
        'type' => 'text'
    ));

    $wp_customize->add_setting('tripadvisor_embed_code', array('default' => ''));
    $wp_customize->add_control('tripadvisor_embed_code', array(
        'label' => __('TripAdvisor Embed Code', 'travel-mountain'),
        'description' => __('Paste your TripAdvisor widget code here. Get it from TripAdvisor.com → Management Center → Marketing Tools → Widgets', 'travel-mountain'),
        'section' => 'tripadvisor_section',
        'type' => 'textarea'
    ));

    $wp_customize->add_setting('tripadvisor_background', array('default' => 'green'));
    $wp_customize->add_control('tripadvisor_background', array(
        'label' => __('Background Color', 'travel-mountain'),
        'section' => 'tripadvisor_section',
        'type' => 'select',
        'choices' => array(
            'green' => __('Green (Theme Primary)', 'travel-mountain'),
            'white' => __('White', 'travel-mountain'),
            'cream' => __('Cream', 'travel-mountain'),
            'dark' => __('Dark', 'travel-mountain')
        )
    ));

    // Packages Archive Page Header
    $wp_customize->add_section('packages_archive_section', array('title' => __('Packages Archive Page', 'travel-mountain'), 'priority' => 49));

    $wp_customize->add_setting('packages_banner_image');
    $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'packages_banner_image', array(
        'label' => __('Banner Image', 'travel-mountain'),
        'description' => __('Upload a banner image for the packages page header (1920x400px recommended)', 'travel-mountain'),
        'section' => 'packages_archive_section'
    )));

    $wp_customize->add_setting('packages_page_title', array('default' => 'Travel Packages'));
    $wp_customize->add_control('packages_page_title', array(
        'label' => __('Page Title', 'travel-mountain'),
        'section' => 'packages_archive_section',
        'type' => 'text'
    ));

    $wp_customize->add_setting('packages_page_description', array('default' => 'Discover our carefully curated travel packages for your perfect adventure'));
    $wp_customize->add_control('packages_page_description', array(
        'label' => __('Page Description', 'travel-mountain'),
        'section' => 'packages_archive_section',
        'type' => 'textarea'
    ));

    // Destinations Archive Page Header
    $wp_customize->add_section('destinations_archive_section', array('title' => __('Destinations Archive Page', 'travel-mountain'), 'priority' => 50));

    $wp_customize->add_setting('destinations_banner_image');
    $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'destinations_banner_image', array(
        'label' => __('Banner Image', 'travel-mountain'),
        'description' => __('Upload a banner image for the destinations page header (1920x400px recommended)', 'travel-mountain'),
        'section' => 'destinations_archive_section'
    )));

    $wp_customize->add_setting('destinations_page_title', array('default' => 'Travel Destinations'));
    $wp_customize->add_control('destinations_page_title', array(
        'label' => __('Page Title', 'travel-mountain'),
        'section' => 'destinations_archive_section',
        'type' => 'text'
    ));

    $wp_customize->add_setting('destinations_page_description', array('default' => 'Explore our handpicked destinations across the globe and find your next adventure'));
    $wp_customize->add_control('destinations_page_description', array(
        'label' => __('Page Description', 'travel-mountain'),
        'section' => 'destinations_archive_section',
        'type' => 'textarea'
    ));
}
add_action('customize_register', 'travel_mountain_customize_register');

// Widget Areas
function travel_mountain_widgets_init()
{
    register_sidebar(array('name' => __('Footer Column 1', 'travel-mountain'), 'id' => 'footer-1'));
    register_sidebar(array('name' => __('Footer Column 2', 'travel-mountain'), 'id' => 'footer-2'));
    register_sidebar(array('name' => __('Footer Column 3', 'travel-mountain'), 'id' => 'footer-3'));
}
add_action('widgets_init', 'travel_mountain_widgets_init');

// conact us page 

/**
 * Contact Page Settings & Form Handler
 * Add this to your functions.php file
 */

// =====================================================
// CONTACT PAGE CUSTOMIZER SETTINGS
// =====================================================

function travel_mountain_contact_customize_register($wp_customize)
{

    // Add Contact Page Section
    $wp_customize->add_section('contact_settings', array(
        'title' => __('Contact Page Settings', 'travel-mountain'),
        'priority' => 50
    ));

    // ============ Location Settings ============

    // Travel Agency Address Line 1
    $wp_customize->add_setting('contact_agency_address_line1', array(
        'default' => '3104 Michigan Ave, Miami Beach',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('contact_agency_address_line1', array(
        'label' => __('Travel Agency Address Line 1', 'travel-mountain'),
        'section' => 'contact_settings',
        'type' => 'text'
    ));

    // Travel Agency Address Line 2
    $wp_customize->add_setting('contact_agency_address_line2', array(
        'default' => 'FL 33139, United States',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('contact_agency_address_line2', array(
        'label' => __('Travel Agency Address Line 2', 'travel-mountain'),
        'section' => 'contact_settings',
        'type' => 'text'
    ));

    // Travel Operator Address Line 1
    $wp_customize->add_setting('contact_operator_address_line1', array(
        'default' => '3081 Biscayne Blvd, Miami',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('contact_operator_address_line1', array(
        'label' => __('Travel Operator Address Line 1', 'travel-mountain'),
        'section' => 'contact_settings',
        'type' => 'text'
    ));

    // Travel Operator Address Line 2
    $wp_customize->add_setting('contact_operator_address_line2', array(
        'default' => 'FL 33137, United States',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('contact_operator_address_line2', array(
        'label' => __('Travel Operator Address Line 2', 'travel-mountain'),
        'section' => 'contact_settings',
        'type' => 'text'
    ));

    // ============ Phone Settings ============

    // Agency Phone 1
    $wp_customize->add_setting('contact_agency_phone', array(
        'default' => 'Paul Davis "Tour Consultant" +1 629 592 593',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('contact_agency_phone', array(
        'label' => __('Agency Mobile Number 1', 'travel-mountain'),
        'section' => 'contact_settings',
        'type' => 'text'
    ));

    // Agency Phone 2
    $wp_customize->add_setting('contact_agency_phone2', array(
        'default' => 'Amy Moore "Local Guide" +1 483 832 205',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('contact_agency_phone2', array(
        'label' => __('Agency Mobile Number 2', 'travel-mountain'),
        'section' => 'contact_settings',
        'type' => 'text'
    ));

    // Operator Phone 1
    $wp_customize->add_setting('contact_operator_phone', array(
        'default' => 'Administration: +1 184 016 482',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('contact_operator_phone', array(
        'label' => __('Office Number 1', 'travel-mountain'),
        'section' => 'contact_settings',
        'type' => 'text'
    ));

    // Operator Phone 2
    $wp_customize->add_setting('contact_operator_phone2', array(
        'default' => 'Technical Office: +1 863 826 836',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('contact_operator_phone2', array(
        'label' => __('Office Number 2', 'travel-mountain'),
        'section' => 'contact_settings',
        'type' => 'text'
    ));

    // ============ Email Settings ============

    // Quotes Email
    $wp_customize->add_setting('contact_quotes_email', array(
        'default' => 'quote@travel.com',
        'sanitize_callback' => 'sanitize_email'
    ));
    $wp_customize->add_control('contact_quotes_email', array(
        'label' => __('Quotes Email', 'travel-mountain'),
        'section' => 'contact_settings',
        'type' => 'email'
    ));

    // Quotes Description
    $wp_customize->add_setting('contact_quotes_text', array(
        'default' => 'Write to this email for a detailed quotation and information.',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('contact_quotes_text', array(
        'label' => __('Quotes Description', 'travel-mountain'),
        'section' => 'contact_settings',
        'type' => 'text'
    ));

    // Consulting Email
    $wp_customize->add_setting('contact_consulting_email', array(
        'default' => 'info@travel.com',
        'sanitize_callback' => 'sanitize_email'
    ));
    $wp_customize->add_control('contact_consulting_email', array(
        'label' => __('Consulting Email', 'travel-mountain'),
        'section' => 'contact_settings',
        'type' => 'email'
    ));

    // Consulting Description
    $wp_customize->add_setting('contact_consulting_text', array(
        'default' => 'Our free consultation service can be requested here every day.',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('contact_consulting_text', array(
        'label' => __('Consulting Description', 'travel-mountain'),
        'section' => 'contact_settings',
        'type' => 'text'
    ));

    // ============ Form Settings ============

    // Form Title
    $wp_customize->add_setting('contact_form_title', array(
        'default' => 'Get in Touch',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('contact_form_title', array(
        'label' => __('Contact Form Title', 'travel-mountain'),
        'section' => 'contact_settings',
        'type' => 'text'
    ));

    // Form Subtitle
    $wp_customize->add_setting('contact_form_subtitle', array(
        'default' => 'Plan Your Next Trip',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('contact_form_subtitle', array(
        'label' => __('Contact Form Subtitle', 'travel-mountain'),
        'section' => 'contact_settings',
        'type' => 'text'
    ));

    // Form Description
    $wp_customize->add_setting('contact_form_description', array(
        'default' => 'Write to us for personalized travel advice or for information on group travel and best minute travel, all travel is insured and safe.',
        'sanitize_callback' => 'sanitize_textarea_field'
    ));
    $wp_customize->add_control('contact_form_description', array(
        'label' => __('Contact Form Description', 'travel-mountain'),
        'section' => 'contact_settings',
        'type' => 'textarea'
    ));

    // Form Recipient Email
    $wp_customize->add_setting('contact_form_recipient', array(
        'default' => get_option('admin_email'),
        'sanitize_callback' => 'sanitize_email'
    ));
    $wp_customize->add_control('contact_form_recipient', array(
        'label' => __('Form Submission Email', 'travel-mountain'),
        'description' => __('Email address where contact form submissions will be sent', 'travel-mountain'),
        'section' => 'contact_settings',
        'type' => 'email'
    ));

    // ============ Map Settings ============

    // Map Embed Code
    $wp_customize->add_setting('contact_map_embed', array(
        'default' => '',
        'sanitize_callback' => 'travel_mountain_sanitize_map_embed'
    ));

    // Sanitize Map Embed Code (allows both iframe and direct URL)
    if (!function_exists('travel_mountain_sanitize_map_embed')) {
        function travel_mountain_sanitize_map_embed($input)
        {
            // If empty, return empty
            if (empty($input)) {
                return '';
            }

            // Trim whitespace
            $input = trim($input);

            // If it's a URL, sanitize as URL
            if (filter_var($input, FILTER_VALIDATE_URL)) {
                return esc_url_raw($input);
            }

            // If it's iframe code, sanitize with wp_kses
            $allowed_html = array(
                'iframe' => array(
                    'src' => array(),
                    'width' => array(),
                    'height' => array(),
                    'style' => array(),
                    'allowfullscreen' => array(),
                    'loading' => array(),
                    'referrerpolicy' => array(),
                    'frameborder' => array(),
                    'title' => array(),
                )
            );
            return wp_kses($input, $allowed_html);
        }
    }
    $wp_customize->add_control('contact_map_embed', array(
        'label' => __('Google Maps Embed Code or URL', 'travel-mountain'),
        'description' => __('Paste EITHER the complete iframe embed code OR just the src URL from Google Maps. Get it from Google Maps → Share → Embed a map → Copy HTML', 'travel-mountain'),
        'section' => 'contact_settings',
        'type' => 'textarea',
        'input_attrs' => array(
            'placeholder' => 'Paste: <iframe src="https://www.google.com/maps/embed?pb=..."></iframe> OR https://www.google.com/maps/embed?pb=...'
        )
    ));

    // Map Address
    $wp_customize->add_setting('contact_map_address', array(
        'default' => 'London Eye',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('contact_map_address', array(
        'label' => __('Map Address/Location Name', 'travel-mountain'),
        'section' => 'contact_settings',
        'type' => 'text'
    ));
}
add_action('customize_register', 'travel_mountain_contact_customize_register');

// =====================================================
// CONTACT FORM HANDLER
// =====================================================

function travel_mountain_handle_contact_form()
{
    // Verify nonce
    if (!isset($_POST['contact_form_nonce']) || !wp_verify_nonce($_POST['contact_form_nonce'], 'contact_form_submit')) {
        wp_send_json_error(array(
            'message' => __('Security check failed. Please refresh and try again.', 'travel-mountain')
        ));
    }

    // Get and sanitize form data
    $name = sanitize_text_field($_POST['contact_name']);
    $email = sanitize_email($_POST['contact_email']);
    $phone = sanitize_text_field($_POST['contact_phone']);
    $nationality = sanitize_text_field($_POST['contact_nationality']);
    $start_date = sanitize_text_field($_POST['contact_start_date']);
    $end_date = sanitize_text_field($_POST['contact_end_date']);
    $adults = absint($_POST['contact_adults']);
    $children = absint($_POST['contact_children']);
    $service = sanitize_text_field($_POST['contact_service']);
    $message = sanitize_textarea_field($_POST['contact_message']);
    $privacy = isset($_POST['contact_privacy']) ? 'Yes' : 'No';

    // Validate
    if (empty($name) || empty($email) || empty($phone) || empty($nationality) || empty($service)) {
        wp_send_json_error(array(
            'message' => __('Please fill in all required fields.', 'travel-mountain')
        ));
    }

    if (!is_email($email)) {
        wp_send_json_error(array(
            'message' => __('Please enter a valid email address.', 'travel-mountain')
        ));
    }

    if (!isset($_POST['contact_privacy'])) {
        wp_send_json_error(array(
            'message' => __('Please accept the Privacy Policy to continue.', 'travel-mountain')
        ));
    }

    // Get recipient email from customizer
    $to = get_theme_mod('contact_form_recipient', get_option('admin_email'));

    // Email subject
    $subject = sprintf(__('New Contact Form Submission from %s', 'travel-mountain'), get_bloginfo('name'));

    // Email body
    $body = sprintf(
        __(
            "You have received a new contact form submission:\n\n" .
            "CONTACT INFORMATION:\n" .
            "Name: %s\n" .
            "Email: %s\n" .
            "Phone: %s\n" .
            "Nationality: %s\n\n" .
            "TRAVEL DETAILS:\n" .
            "Service Requested: %s\n" .
            "Start Date: %s\n" .
            "End Date: %s\n" .
            "Number of Adults: %d\n" .
            "Number of Children: %d\n\n" .
            "MESSAGE:\n%s\n\n" .
            "PRIVACY POLICY:\n" .
            "Accepted: %s\n\n" .
            "---\n" .
            "This email was sent from the contact form at %s",
            'travel-mountain'
        ),
        $name,
        $email,
        $phone,
        $nationality,
        $service,
        $start_date,
        $end_date,
        $adults,
        $children,
        $message,
        $privacy,
        home_url()
    );

    // Email headers
    $headers = array(
        'Content-Type: text/plain; charset=UTF-8',
        'From: ' . get_bloginfo('name') . ' <' . get_option('admin_email') . '>',
        'Reply-To: ' . $name . ' <' . $email . '>'
    );

    // Get WhatsApp number from customizer (or use default contact phone)
    $whatsapp_number = get_theme_mod('contact_whatsapp_number', get_theme_mod('contact_phone', ''));

    // Create WhatsApp message
    $whatsapp_message = sprintf(
        "Hi! I'm %s\n\n" .
        "📧 Email: %s\n" .
        "📱 Phone: %s\n" .
        "🌍 Nationality: %s\n\n" .
        "📅 Start Date: %s\n" .
        "📅 End Date: %s\n\n" .
        "Service Requested: %s\n" .
        "👥 Adults: %d | Children: %d\n\n" .
        "Message: %s",
        $name,
        $email,
        $phone,
        $nationality,
        $start_date,
        $end_date,
        $service,
        $adults,
        $children,
        $message
    );

    // Format WhatsApp number (remove spaces and special characters)
    $whatsapp_phone = preg_replace('/[^0-9+]/', '', $whatsapp_number);

    // Generate WhatsApp URL
    $whatsapp_url = '';
    if (!empty($whatsapp_phone)) {
        $whatsapp_url = 'https://wa.me/' . $whatsapp_phone . '?text=' . urlencode($whatsapp_message);
    }

    // Send email (but don't fail if email doesn't work in local development)
    $sent = wp_mail($to, $subject, $body, $headers);

    // Always return success with WhatsApp URL (email failure shouldn't block the form)
    // This is especially useful for local development environments
    if ($sent) {
        wp_send_json_success(array(
            'message' => __('Thank you for contacting us! We will get back to you soon.', 'travel-mountain'),
            'whatsapp_url' => $whatsapp_url,
            'email_sent' => true
        ));
    } else {
        // Email failed but still allow WhatsApp communication
        wp_send_json_success(array(
            'message' => __('Thank you for contacting us! Please continue via WhatsApp.', 'travel-mountain'),
            'whatsapp_url' => $whatsapp_url,
            'email_sent' => false,
            'email_note' => __('Email notification failed (mail server not configured). Please contact via WhatsApp.', 'travel-mountain')
        ));
    }
}
add_action('admin_post_submit_contact_form', 'travel_mountain_handle_contact_form');
add_action('admin_post_nopriv_submit_contact_form', 'travel_mountain_handle_contact_form');

// =====================================================
// ADD GOOGLE FONTS (Dancing Script for subtitle)
// =====================================================

function travel_mountain_add_dancing_script()
{
    wp_enqueue_style('dancing-script', 'https://fonts.googleapis.com/css2?family=Dancing+Script:wght@400;500;600;700&display=swap', array(), null);
}
add_action('wp_enqueue_scripts', 'travel_mountain_add_dancing_script');


// =====================================================
// REGISTER TRANSPORT PARTNERS CUSTOM POST TYPE
// =====================================================

function travel_mountain_register_transport_partners()
{
    register_post_type('transport', array(
        'labels' => array(
            'name' => __('Transport Partners', 'travel-mountain'),
            'singular_name' => __('Transport Partner', 'travel-mountain'),
            'add_new' => __('Add New Vehicle', 'travel-mountain'),
            'add_new_item' => __('Add New Transport Partner', 'travel-mountain'),
            'edit_item' => __('Edit Transport Partner', 'travel-mountain'),
            'new_item' => __('New Transport Partner', 'travel-mountain'),
            'view_item' => __('View Transport Partner', 'travel-mountain'),
            'search_items' => __('Search Transport Partners', 'travel-mountain'),
            'not_found' => __('No transport partners found', 'travel-mountain'),
            'not_found_in_trash' => __('No transport partners found in trash', 'travel-mountain')
        ),
        'public' => true,
        'menu_icon' => 'dashicons-car',
        'supports' => array('title', 'editor', 'thumbnail', 'page-attributes'),
        'show_in_rest' => true,
        'menu_position' => 26
    ));
}
add_action('init', 'travel_mountain_register_transport_partners');

// =====================================================
// ADD TRANSPORT PARTNERS META BOX
// =====================================================

function travel_mountain_add_transport_meta_boxes()
{
    add_meta_box(
        'transport_details',
        __('Transport Partner Details', 'travel-mountain'),
        'travel_mountain_transport_meta_box',
        'transport',
        'normal',
        'high'
    );
}
add_action('add_meta_boxes', 'travel_mountain_add_transport_meta_boxes');

// =====================================================
// TRANSPORT PARTNERS META BOX CALLBACK
// =====================================================

function travel_mountain_transport_meta_box($post)
{
    wp_nonce_field('transport_meta_box', 'transport_meta_box_nonce');

    $vehicle_type = get_post_meta($post->ID, '_transport_vehicle_type', true);
    $driver_name = get_post_meta($post->ID, '_transport_driver_name', true);
    $capacity = get_post_meta($post->ID, '_transport_capacity', true);
    $price_per_day = get_post_meta($post->ID, '_transport_price_per_day', true);
    $phone = get_post_meta($post->ID, '_transport_phone', true);
    $features = get_post_meta($post->ID, '_transport_features', true);
    $is_featured = get_post_meta($post->ID, '_transport_featured', true);
    ?>

        <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px;">
            <div>
                <p><label><strong>Vehicle Type:</strong></label><br>
                    <select name="transport_vehicle_type" style="width:100%;">
                        <option value="Car" <?php selected($vehicle_type, 'Car'); ?>>Car</option>
                        <option value="Van" <?php selected($vehicle_type, 'Van'); ?>>Van</option>
                        <option value="Bus" <?php selected($vehicle_type, 'Bus'); ?>>Bus</option>
                        <option value="Minibus" <?php selected($vehicle_type, 'Minibus'); ?>>Minibus</option>
                        <option value="SUV" <?php selected($vehicle_type, 'SUV'); ?>>SUV</option>
                        <option value="Luxury Car" <?php selected($vehicle_type, 'Luxury Car'); ?>>Luxury Car</option>
                    </select>
                </p>

                <p><label><strong>Driver Name:</strong></label><br>
                    <input type="text" name="transport_driver_name" value="<?php echo esc_attr($driver_name); ?>"
                        style="width:100%;" placeholder="e.g., John Smith">
                </p>

                <p><label><strong>Passenger Capacity:</strong></label><br>
                    <input type="number" name="transport_capacity" value="<?php echo esc_attr($capacity); ?>"
                        style="width:100%;" placeholder="e.g., 4" min="1" max="50">
                </p>
            </div>

            <div>
                <p><label><strong>Price Per Day ($):</strong></label><br>
                    <input type="number" name="transport_price_per_day" value="<?php echo esc_attr($price_per_day); ?>"
                        style="width:100%;" placeholder="e.g., 150" step="0.01">
                </p>

                <p><label><strong>Contact Phone:</strong></label><br>
                    <input type="text" name="transport_phone" value="<?php echo esc_attr($phone); ?>" style="width:100%;"
                        placeholder="+1 234 567 8900">
                </p>

                <p><label><input type="checkbox" name="transport_featured" value="1" <?php checked($is_featured, '1'); ?>>
                        <strong>Mark as Featured</strong></label></p>
            </div>
        </div>

        <hr style="margin: 20px 0;">

        <p><label><strong>Vehicle Features (one per line):</strong></label><br>
            <textarea name="transport_features" rows="6" style="width:100%;"
                placeholder="Air Conditioning&#10;GPS Navigation&#10;WiFi Available&#10;Leather Seats"><?php echo esc_textarea($features); ?></textarea>
            <br><small>Each feature will be displayed with a checkmark icon</small>
        </p>

        <hr style="margin: 20px 0;">

        <div style="background: #f9f9f9; padding: 15px; border-left: 4px solid #2271b1;">
            <p><strong>Instructions:</strong></p>
            <ul style="margin-left: 20px; line-height: 1.8;">
                <li><strong>Title:</strong> Enter the vehicle name/model (e.g., "Toyota Hiace 2023")</li>
                <li><strong>Content Editor:</strong> Add detailed description of the vehicle and services</li>
                <li><strong>Featured Image:</strong> Upload a photo of the vehicle (recommended: 800x600px)</li>
                <li><strong>Order:</strong> Use "Order" field in the sidebar to control display sequence</li>
            </ul>
        </div>
        <?php
}

// =====================================================
// SAVE TRANSPORT PARTNERS META DATA
// =====================================================

function travel_mountain_save_transport_meta($post_id)
{
    // Check nonce
    if (
        !isset($_POST['transport_meta_box_nonce']) ||
        !wp_verify_nonce($_POST['transport_meta_box_nonce'], 'transport_meta_box')
    ) {
        return;
    }

    // Check autosave
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return;
    }

    // Check permissions
    if (!current_user_can('edit_post', $post_id)) {
        return;
    }

    // Save fields
    if (isset($_POST['transport_vehicle_type'])) {
        update_post_meta($post_id, '_transport_vehicle_type', sanitize_text_field($_POST['transport_vehicle_type']));
    }

    if (isset($_POST['transport_driver_name'])) {
        update_post_meta($post_id, '_transport_driver_name', sanitize_text_field($_POST['transport_driver_name']));
    }

    if (isset($_POST['transport_capacity'])) {
        update_post_meta($post_id, '_transport_capacity', absint($_POST['transport_capacity']));
    }

    if (isset($_POST['transport_price_per_day'])) {
        update_post_meta($post_id, '_transport_price_per_day', sanitize_text_field($_POST['transport_price_per_day']));
    }

    if (isset($_POST['transport_phone'])) {
        update_post_meta($post_id, '_transport_phone', sanitize_text_field($_POST['transport_phone']));
    }

    if (isset($_POST['transport_features'])) {
        update_post_meta($post_id, '_transport_features', sanitize_textarea_field($_POST['transport_features']));
    }

    // Featured checkbox
    update_post_meta($post_id, '_transport_featured', isset($_POST['transport_featured']) ? '1' : '0');
}
add_action('save_post', 'travel_mountain_save_transport_meta');

// =====================================================
// CUSTOMIZER SETTINGS FOR TRANSPORT SECTION
// =====================================================

function travel_mountain_transport_customize_register($wp_customize)
{

    // Transport Section
    $wp_customize->add_section('transport_section', array(
        'title' => __('Transport Partners Section', 'travel-mountain'),
        'priority' => 45
    ));

    $wp_customize->add_setting('transport_subtitle', array(
        'default' => 'Our Fleet'
    ));
    $wp_customize->add_control('transport_subtitle', array(
        'label' => __('Section Subtitle', 'travel-mountain'),
        'section' => 'transport_section',
        'type' => 'text'
    ));

    $wp_customize->add_setting('transport_title', array(
        'default' => 'Available Transport Partners'
    ));
    $wp_customize->add_control('transport_title', array(
        'label' => __('Section Title', 'travel-mountain'),
        'section' => 'transport_section',
        'type' => 'text'
    ));

    $wp_customize->add_setting('transport_description', array(
        'default' => 'Choose from our fleet of comfortable and reliable vehicles with experienced drivers for your journey.'
    ));
    $wp_customize->add_control('transport_description', array(
        'label' => __('Section Description', 'travel-mountain'),
        'section' => 'transport_section',
        'type' => 'textarea'
    ));
}
add_action('customize_register', 'travel_mountain_transport_customize_register');

// =====================================================
// ADD CUSTOM COLUMNS TO ADMIN LIST
// =====================================================

function travel_mountain_transport_columns($columns)
{
    $new_columns = array();
    $new_columns['cb'] = $columns['cb'];
    $new_columns['thumbnail'] = __('Image', 'travel-mountain');
    $new_columns['title'] = __('Vehicle', 'travel-mountain');
    $new_columns['vehicle_type'] = __('Type', 'travel-mountain');
    $new_columns['driver'] = __('Driver', 'travel-mountain');
    $new_columns['capacity'] = __('Capacity', 'travel-mountain');
    $new_columns['price'] = __('Price/Day', 'travel-mountain');
    $new_columns['featured'] = __('Featured', 'travel-mountain');
    $new_columns['date'] = $columns['date'];

    return $new_columns;
}
add_filter('manage_transport_posts_columns', 'travel_mountain_transport_columns');

function travel_mountain_transport_column_content($column, $post_id)
{
    switch ($column) {
        case 'thumbnail':
            if (has_post_thumbnail($post_id)) {
                echo get_the_post_thumbnail($post_id, array(50, 50));
            } else {
                echo '<span style="color: #999;">—</span>';
            }
            break;

        case 'vehicle_type':
            $type = get_post_meta($post_id, '_transport_vehicle_type', true);
            echo $type ? esc_html($type) : '—';
            break;

        case 'driver':
            $driver = get_post_meta($post_id, '_transport_driver_name', true);
            echo $driver ? esc_html($driver) : '—';
            break;

        case 'capacity':
            $capacity = get_post_meta($post_id, '_transport_capacity', true);
            echo $capacity ? esc_html($capacity) . ' passengers' : '—';
            break;

        case 'price':
            $price = get_post_meta($post_id, '_transport_price_per_day', true);
            echo $price ? '$' . esc_html($price) : '—';
            break;

        case 'featured':
            $featured = get_post_meta($post_id, '_transport_featured', true);
            if ($featured == '1') {
                echo '<span style="color: #2271b1;">★ Featured</span>';
            } else {
                echo '—';
            }
            break;
    }
}
add_action('manage_transport_posts_custom_column', 'travel_mountain_transport_column_content', 10, 2);

// =====================================================
// SITEMAP & SEO ENHANCEMENTS
// =====================================================

/**
 * Add custom post types to WordPress sitemap
 */
function travel_mountain_add_to_sitemap($post_types)
{
    $post_types[] = 'package';
    $post_types[] = 'destination';
    $post_types[] = 'hero_slide';
    $post_types[] = 'partner';
    $post_types[] = 'transport';
    return $post_types;
}
add_filter('wp_sitemaps_post_types', 'travel_mountain_add_to_sitemap');

/**
 * Customize robots.txt via WordPress
 */
function travel_mountain_robots_txt($output, $public)
{
    if ('0' == $public) {
        return $output;
    }

    $site_url = get_site_url();

    $custom_output = "# Custom robots.txt for Travel Mountain\n\n";
    $custom_output .= "User-agent: *\n";
    $custom_output .= "Allow: /\n\n";

    $custom_output .= "# WordPress System Files\n";
    $custom_output .= "Disallow: /wp-admin/\n";
    $custom_output .= "Disallow: /wp-includes/\n";
    $custom_output .= "Allow: /wp-admin/admin-ajax.php\n\n";

    $custom_output .= "# Sitemap Location\n";
    $custom_output .= "Sitemap: " . $site_url . "/wp-sitemap.xml\n";
    $custom_output .= "Sitemap: " . $site_url . "/sitemap.xml\n";

    return $custom_output;
}
add_filter('robots_txt', 'travel_mountain_robots_txt', 10, 2);

/**
 * Generate custom HTML sitemap shortcode
 * Usage: [travel_sitemap]
 */
function travel_mountain_html_sitemap()
{
    ob_start();
    ?>
        <div class="travel-sitemap" style="padding: 40px 0;">
            <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 40px;">

                <!-- Pages -->
                <div>
                    <h3
                        style="color: var(--primary); margin-bottom: 20px; font-size: 22px; border-bottom: 2px solid var(--primary); padding-bottom: 10px;">
                        <i class="fas fa-file-alt"></i> <?php _e('Pages', 'travel-mountain'); ?>
                    </h3>
                    <ul style="list-style: none; padding: 0;">
                        <?php
                        $pages = get_pages();
                        foreach ($pages as $page) {
                            echo '<li style="margin-bottom: 10px;"><a href="' . get_permalink($page->ID) . '" style="color: var(--dark); text-decoration: none; transition: color 0.3s;">' . $page->post_title . '</a></li>';
                        }
                        ?>
                    </ul>
                </div>

                <!-- Packages -->
                <div>
                    <h3
                        style="color: var(--primary); margin-bottom: 20px; font-size: 22px; border-bottom: 2px solid var(--primary); padding-bottom: 10px;">
                        <i class="fas fa-suitcase"></i> <?php _e('Travel Packages', 'travel-mountain'); ?>
                    </h3>
                    <ul style="list-style: none; padding: 0;">
                        <?php
                        $packages = get_posts(array('post_type' => 'package', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC'));
                        foreach ($packages as $package) {
                            echo '<li style="margin-bottom: 10px;"><a href="' . get_permalink($package->ID) . '" style="color: var(--dark); text-decoration: none; transition: color 0.3s;">' . $package->post_title . '</a></li>';
                        }
                        ?>
                    </ul>
                </div>

                <!-- Destinations -->
                <div>
                    <h3
                        style="color: var(--primary); margin-bottom: 20px; font-size: 22px; border-bottom: 2px solid var(--primary); padding-bottom: 10px;">
                        <i class="fas fa-map-marker-alt"></i> <?php _e('Destinations', 'travel-mountain'); ?>
                    </h3>
                    <ul style="list-style: none; padding: 0;">
                        <?php
                        $destinations = get_posts(array('post_type' => 'destination', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC'));
                        foreach ($destinations as $destination) {
                            echo '<li style="margin-bottom: 10px;"><a href="' . get_permalink($destination->ID) . '" style="color: var(--dark); text-decoration: none; transition: color 0.3s;">' . $destination->post_title . '</a></li>';
                        }
                        ?>
                    </ul>
                </div>

                <!-- Blog Posts -->
                <div>
                    <h3
                        style="color: var(--primary); margin-bottom: 20px; font-size: 22px; border-bottom: 2px solid var(--primary); padding-bottom: 10px;">
                        <i class="fas fa-blog"></i> <?php _e('Blog Posts', 'travel-mountain'); ?>
                    </h3>
                    <ul style="list-style: none; padding: 0;">
                        <?php
                        $posts = get_posts(array('post_type' => 'post', 'posts_per_page' => 10, 'orderby' => 'date', 'order' => 'DESC'));
                        foreach ($posts as $post) {
                            echo '<li style="margin-bottom: 10px;"><a href="' . get_permalink($post->ID) . '" style="color: var(--dark); text-decoration: none; transition: color 0.3s;">' . $post->post_title . '</a></li>';
                        }
                        ?>
                    </ul>
                </div>

            </div>
        </div>
        <style>
            .travel-sitemap a:hover {
                color: var(--primary) !important;
                padding-left: 5px;
            }
        </style>
        <?php
        return ob_get_clean();
}
add_shortcode('travel_sitemap', 'travel_mountain_html_sitemap');