����JFIF��`�`�����Viewing File: /home/u820193700/domains/throtllr.com/public_html/js/pages/TourDetails.js
const { useState, useEffect, useRef } = React;
const { useParams, useNavigate, useLocation } = ReactRouterDOM;

const getYouTubeEmbedUrl = (url) => {
    if (!url) return '';
    if (url.includes('youtube.com/embed/')) return url;
    let videoId = '';
    if (url.includes('v=')) {
        videoId = url.split('v=')[1].split('&')[0];
    } else if (url.includes('youtu.be/')) {
        videoId = url.split('youtu.be/')[1].split('?')[0];
    } else if (url.includes('shorts/')) {
        videoId = url.split('shorts/')[1].split('?')[0];
    }
    return videoId ? `https://www.youtube.com/embed/${videoId}` : url;
};

function TourDetails() {
    const { id } = useParams();
    const navigate = useNavigate();
    const location = useLocation();
    const [tour, setTour] = useState(null);
    const [loading, setLoading] = useState(true);
    const [error, setError] = useState('');
    const [booking, setBooking] = useState(false);
    const [activeTab, setActiveTab] = useState('itinerary');
    const [fullscreenMedia, setFullscreenMedia] = useState(null);
    const mapRef = useRef(null);

    const userStr = sessionStorage.getItem('throtllr_user');
    const user = userStr ? JSON.parse(userStr) : null;

    useEffect(() => {
        window.scrollTo(0, 0);
        window.fetchAPI(`/tours.php?id=${id}`)
            .then(res => {
                setTour(res.data);
                setLoading(false);
            })
            .catch(err => {
                setError(err.message);

                // Fallback details for featured tours
                const fallbacks = {
                    'f1': {
                        id: 'f1',
                        title: 'Spiti Valley Expedition',
                        description: 'Embark on a soul-stirring journey through the rugged terrains of the Spiti Valley. This 12-day expedition takes you through high-altitude cold deserts, ancient monasteries, and some of the world\'s highest inhabited villages. Experience the raw beauty of the Himalayas on your Royal Enfield.',
                        start_location: 'Shimla',
                        end_location: 'Kaza',
                        duration_days: 12,
                        start_date: '2026-08-05',
                        price: 45000,
                        bike_eligibility: 'Himalayan / Interceptor 650',
                        max_riders: 12,
                        showroom_name: 'Avahan Delhi Royal',
                        dealer_location: 'New Delhi',
                        dealer_email: 'delhi@avahan.com',
                        image_url: 'https://images.unsplash.com/photo-1591154665854-01dbaf614bd8?w=1600',
                        route_image_url: 'assets/img/tours/spiti-route.png',
                        route_details: 'Day 1: Shimla Arrival & Briefing\nDay 2: Shimla to Sarahan\nDay 3: Sarahan to Sangla\nDay 4: Sangla to Chitkul\nDay 5: Sangla to Kalpa\nDay 6: Kalpa to Nako\nDay 7: Nako to Tabo\nDay 8: Tabo to Dhankar to Kaza\nDay 9: Kaza Local Sightseeing\nDay 10: Kaza to Key Monastery to Kibber\nDay 11: Kaza to Langza & Hikkim\nDay 12: Departure from Kaza',
                        media: [
                            { id: 1, media_type: 'youtube', media_url: 'https://www.youtube.com/embed/dQw4w9WgXcQ', title: 'Route Overview' },
                            { id: 2, media_type: 'image', media_url: 'https://images.unsplash.com/photo-1599940778173-e276d4acb2bb?w=400', title: 'Scenic Turn' }
                        ],
                        blogs: [
                            { id: 1, title: 'Conquering Spiti Valley', excerpt: 'A detailed account of my 12-day journey.', author_name: 'Rahul', media_type: 'image', media_url: 'https://images.unsplash.com/photo-1558981403-c5f9899a28bc?w=800', published_date: '2025-10-15' }
                        ]
                    },
                    'f2': {
                        id: 'f2',
                        title: 'Desert Storm: Rajasthan',
                        description: 'Ride through the golden sands and royal heritage of Rajasthan. This tour covers the famous desert circuit, staying in royal palaces and luxury desert camps. A perfect blend of adventure and royalty.',
                        start_location: 'Jaipur',
                        end_location: 'Jaisalmer',
                        duration_days: 8,
                        start_date: '2026-11-20',
                        price: 28000,
                        bike_eligibility: 'Classic 350 / Meteor 350',
                        max_riders: 15,
                        showroom_name: 'Avahan Delhi Royal',
                        dealer_location: 'New Delhi',
                        dealer_email: 'delhi@avahan.com',
                        image_url: 'https://images.unsplash.com/photo-1599940778173-e276d4acb2bb?w=1600',
                        route_details: 'Day 1: Jaipur Welcome Ride\nDay 2: Jaipur to Bikaner\nDay 3: Bikaner to Jaisalmer\nDay 4: Jaisalmer Desert Experience\nDay 5: Jaisalmer to Jodhpur\nDay 6: Jodhpur City Tour\nDay 7: Jodhpur to Pushkar\nDay 8: Pushkar to Jaipur',
                        media: [
                            { id: 3, media_type: 'image', media_url: 'https://images.unsplash.com/photo-1587582423116-ec07293f0395?w=400', title: 'Desert Camp' }
                        ],
                        blogs: [
                            { id: 2, title: 'Desert Storm Adventure', excerpt: 'Riding the golden sands of Rajasthan.', author_name: 'Anita', media_type: 'image', media_url: 'https://images.unsplash.com/photo-1599940778173-e276d4acb2bb?w=800', published_date: '2025-11-02' }
                        ]
                    },
                    'f3': {
                        id: 'f3',
                        title: 'Sikkim Silk Route',
                        description: 'Challenge yourself with the 32 hairpin turns of the Zuluk Silk Route. Experience the mystical beauty of East Sikkim, frozen lakes, and panoramic views of Mt. Kanchenjunga.',
                        start_location: 'Siliguri',
                        end_location: 'Gangtok',
                        duration_days: 7,
                        start_date: '2026-05-10',
                        price: 32000,
                        bike_eligibility: 'Himalayan / Scram 411',
                        max_riders: 10,
                        showroom_name: 'Avahan BLR Adventure',
                        dealer_location: 'Bengaluru',
                        dealer_email: 'blr@avahan.com',
                        image_url: 'https://images.unsplash.com/photo-1587582423116-ec07293f0395?w=1600',
                        route_details: 'Day 1: Arrival in Siliguri\nDay 2: Siliguri to Aritar\nDay 3: Aritar to Zuluk (The Silk Route)\nDay 4: Zuluk to Nathang Valley\nDay 5: Nathang to Gangtok\nDay 6: Gangtok Local Tour\nDay 7: Departure from Gangtok',
                        media: [
                            { id: 4, media_type: 'youtube', media_url: 'https://www.youtube.com/embed/tgbNymZ7vqY', title: 'Sightseeing' }
                        ],
                        blogs: []
                    }
                };

                if (fallbacks[id]) {
                    setTour(fallbacks[id]);
                    setError(''); // Clear error if we have fallback
                }
                setLoading(false);
            });
    }, [id]);

    // Handle autobooking after login
    useEffect(() => {
        if (!loading && tour && user && user.role === 'rider') {
            // HashRouters place query properties inside the hash, so location.search might fail. Parsing hash directly:
            const hashParts = window.location.hash.split('?');
            if (hashParts.length > 1) {
                const queryParams = new URLSearchParams(hashParts[1]);
                if (queryParams.get('autoBook') === 'true') {
                    // Clean the URL without refreshing and trigger booking
                    navigate(`/tour/${id}`, { replace: true });
                    handleBook();
                }
            }
        }
    }, [loading, tour, user]);

    // Handle smooth scrolling and active tab state
    useEffect(() => {
        const handleScroll = () => {
            const sections = ['itinerary', 'route-map', 'details'];
            const scrollPos = window.scrollY + 150; // Offset for sticky nav

            for (const section of sections) {
                const el = document.getElementById(section);
                if (el) {
                    const rect = el.getBoundingClientRect();
                    const top = rect.top + window.pageYOffset;
                    if (scrollPos >= top && scrollPos < top + el.offsetHeight) {
                        setActiveTab(section);
                        break;
                    }
                }
            }
        };

        window.addEventListener('scroll', handleScroll);
        return () => window.removeEventListener('scroll', handleScroll);
    }, []);

    const scrollToSection = (id) => {
        const el = document.getElementById(id);
        if (el) {
            const yOffset = -100; // Offset for sticky nav
            const y = el.getBoundingClientRect().top + window.pageYOffset + yOffset;
            window.scrollTo({
                top: y,
                behavior: 'smooth'
            });
            setActiveTab(id);
        }
    };

    const handleBook = () => {
        // Navigate to the Booking Options page (Step 1), passing the tour as state to avoid a re-fetch.
        // Guests are allowed to reach Step 1; login is handled in BookingOptions.js if they proceed to payment.
        navigate(`/book/${tour.id || id}`, { state: { tour } });
    };

    const downloadMedia = (e, url) => {
        e.stopPropagation();
        fetch(url)
            .then(response => response.blob())
            .then(blob => {
                const blobUrl = window.URL.createObjectURL(blob);
                const a = document.createElement('a');
                a.style.display = 'none';
                a.href = blobUrl;
                a.download = url.split('/').pop() || 'download';
                document.body.appendChild(a);
                a.click();
                window.URL.revokeObjectURL(blobUrl);
                document.body.removeChild(a);
            })
            .catch(() => {
                const a = document.createElement('a');
                a.href = url;
                a.download = url.split('/').pop() || 'download';
                a.target = '_blank';
                document.body.appendChild(a);
                a.click();
                document.body.removeChild(a);
            });
    };

    if (loading) return <div className="container mt-5 text-center" style={{ height: '100vh', display: 'flex', alignItems: 'center', justifyContent: 'center' }}><i className="fa-solid fa-circle-notch fa-spin fa-3x" style={{ color: 'var(--primary-color)' }}></i></div>;
    if (error) return <div className="container mt-5" style={{ minHeight: '60vh' }}><div className="card p-4 text-center text-danger" style={{ border: '1px solid currentColor' }}>{error}</div></div>;
    if (!tour) return null;

    // Parse route details into an array if it contains 'Day' markers, otherwise create a simple array
    const itineraries = tour.route_details.split(/(?=Day \d+:)/i).filter(Boolean);

    return (
        <div style={{ backgroundColor: 'var(--bg-dark)' }}>
            {/* Immersive Hero Section with Title & Description Overlay */}
            <div style={{
                minHeight: '550px',
                background: `linear-gradient(to bottom, rgba(0,0,0,0.2) 0%, rgba(18, 18, 18, 1) 100%), url(${tour.image_url || 'https://images.unsplash.com/photo-1558981403-c5f9899a28bc?w=1600'})`,
                backgroundPosition: 'center',
                backgroundSize: 'cover',
                width: '100%',
                position: 'relative',
                display: 'flex',
                alignItems: 'flex-end',
                paddingBottom: '40px'
            }}>
                <div className="container">
                    <div style={{ maxWidth: '900px' }}>
                         {tour.package_id && (
                            <div style={{ display: 'inline-block', backgroundColor: 'var(--success)', color: 'white', padding: '3px 10px', fontWeight: 'bold', letterSpacing: '0.5px', borderRadius: '4px', fontSize: '0.75rem', textTransform: 'uppercase', marginBottom: '15px' }}>
                                <i className="fa-solid fa-circle-check"></i> Verified Package
                            </div>
                        )}
                        <h1 style={{ fontSize: 'clamp(3rem, 8vw, 5rem)', fontWeight: '900', margin: '0 0 15px 0', textTransform: 'uppercase', lineHeight: '1', color: 'white' }}>
                            {tour.title}
                        </h1>
                        <div style={{ display: 'flex', gap: '25px', flexWrap: 'wrap', marginBottom: '20px' }}>
                            <p style={{ fontSize: '1.2rem', color: 'rgba(255,255,255,0.9)', fontWeight: '600', display: 'flex', alignItems: 'center', gap: '10px', margin: 0 }}>
                                <i className="fa-solid fa-map-location-dot" style={{ color: 'var(--primary-color)' }}></i>
                                {tour.start_location} <i className="fa-solid fa-arrow-right" style={{ fontSize: '0.7rem', opacity: 0.6 }}></i> {tour.end_location}
                            </p>
                            <p style={{ fontSize: '1.2rem', color: 'rgba(255,255,255,0.9)', fontWeight: '600', display: 'flex', alignItems: 'center', gap: '10px', margin: 0 }}>
                                <i className="fa-regular fa-calendar" style={{ color: 'var(--primary-color)' }}></i>
                                {new Date(tour.start_date).toLocaleDateString('en-GB', { month: 'long', year: 'numeric' })}
                            </p>
                        </div>
                        <p style={{ fontSize: '0.9rem', color: 'rgba(255,255,255,0.7)', maxWidth: '600px', lineHeight: '1.5', margin: 0, fontWeight: '400' }}>
                            {tour.description}
                        </p>
                    </div>
                </div>
            </div>

            {/* Main Content Area - Single Column overlapping the hero */}
            <div className="container" style={{ position: 'relative', zIndex: 10, marginTop: '40px', paddingBottom: '60px' }}>

                {/* Compact Edelweiss-style Facts Box */}
                <div className="card" style={{
                    backgroundColor: '#1e1e1e', // Darker background to match SS
                    border: 'none',
                    boxShadow: '0 10px 30px rgba(0,0,0,0.8)',
                    padding: '20px 30px',
                    marginBottom: '30px',
                    borderRadius: '4px' // Straighter edges
                }}>
                    <h2 style={{ fontSize: '1rem', borderBottom: '1px solid rgba(255,255,255,0.05)', paddingBottom: '10px', marginBottom: '20px', textTransform: 'uppercase', letterSpacing: '1px', fontWeight: '800' }}>Tour Facts</h2>

                    <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(180px, 1fr))', gap: '20px', marginBottom: '15px' }}>
                        <div>
                            <div style={{ fontSize: '0.65rem', color: '#888', textTransform: 'uppercase', letterSpacing: '0.5px', marginBottom: '4px' }}>Duration</div>
                            <div style={{ fontWeight: 'bold', fontSize: '1rem', marginBottom: '2px' }}>{tour.duration_days} Days</div>
                            <div style={{ fontSize: '0.75rem', color: '#888' }}>{tour.duration_days - 1} Nights</div>
                        </div>

                        <div>
                            <div style={{ fontSize: '0.65rem', color: '#888', textTransform: 'uppercase', letterSpacing: '0.5px', marginBottom: '4px' }}>Riding Level</div>
                            <div style={{ display: 'flex', gap: '3px', alignItems: 'center' }}>
                                {[1, 2, 3, 4, 5].map(star => (
                                    <i key={star} className="fa-solid fa-circle" style={{ fontSize: '0.5rem', color: star <= (tour.difficulty || 3) ? 'var(--primary-color)' : '#333' }}></i>
                                ))}
                                <span style={{ marginLeft: '6px', fontWeight: 'bold', fontSize: '1rem' }}>{tour.difficulty ? parseFloat(tour.difficulty).toFixed(1) : '3.0'} / 5</span>
                            </div>
                        </div>

                        <div>
                            <div style={{ fontSize: '0.65rem', color: '#888', textTransform: 'uppercase', letterSpacing: '0.5px', marginBottom: '4px' }}>Bikes</div>
                            <div style={{ fontWeight: 'bold', fontSize: '1rem' }}>{tour.bike_eligibility}</div>
                        </div>

                        <div>
                            <div style={{ fontSize: '0.65rem', color: '#888', textTransform: 'uppercase', letterSpacing: '0.5px', marginBottom: '4px' }}>Departure Dates</div>
                            <div style={{ fontWeight: 'bold', fontSize: '1rem', marginBottom: '2px' }}>{new Date(tour.start_date).toLocaleDateString('en-GB')}</div>
                            <div style={{ fontSize: '0.75rem', color: 'var(--success)' }}>{tour.available_slots} slots open</div>
                        </div>
                    </div>

                    <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-end', borderTop: '1px solid rgba(255,255,255,0.05)', paddingTop: '15px', flexWrap: 'wrap', gap: '15px' }}>
                        <div>
                            <div style={{ fontSize: '0.65rem', color: '#888', textTransform: 'uppercase', letterSpacing: '0.5px', marginBottom: '4px' }}>Tour Price</div>
                            <div style={{ fontSize: '1.8rem', fontWeight: '900', color: 'white', lineHeight: '1' }}>₹{parseFloat(tour.price).toLocaleString()}</div>
                        </div>
                        <button
                            className="btn"
                            style={{ padding: '10px 30px', fontSize: '0.95rem', fontWeight: 'bold', borderRadius: '3px', backgroundColor: 'var(--primary-color)', color: 'white', border: 'none', textTransform: 'uppercase', letterSpacing: '1px' }}
                            onClick={handleBook}
                            disabled={booking}
                        >
                            {booking ? <><i className="fa-solid fa-spinner fa-spin"></i> ...</> : 'Book Now'}
                        </button>
                    </div>
                </div>

                {/* Interactive Tabs Menu */}
                <div style={{ display: 'flex', borderBottom: '1px solid rgba(255,255,255,0.1)', marginBottom: '30px', gap: '40px' }}>
                    <div
                        onClick={() => setActiveTab('itinerary')}
                        style={{ padding: '10px 0', cursor: 'pointer', fontWeight: 'bold', textTransform: 'uppercase', fontSize: '0.95rem', borderBottom: activeTab === 'itinerary' ? '2px solid var(--primary-color)' : '2px solid transparent', color: activeTab === 'itinerary' ? 'var(--primary-color)' : 'var(--text-muted)', transition: 'all 0.2s' }}>
                        Itinerary
                    </div>
                    <div
                        onClick={() => setActiveTab('route-map')}
                        style={{ padding: '10px 0', cursor: 'pointer', fontWeight: 'bold', textTransform: 'uppercase', fontSize: '0.95rem', borderBottom: activeTab === 'route-map' ? '2px solid var(--primary-color)' : '2px solid transparent', color: activeTab === 'route-map' ? 'var(--primary-color)' : 'var(--text-muted)', transition: 'all 0.2s' }}>
                        Route Map
                    </div>
                    <div
                        onClick={() => setActiveTab('details')}
                        style={{ padding: '10px 0', cursor: 'pointer', fontWeight: 'bold', textTransform: 'uppercase', fontSize: '0.95rem', borderBottom: activeTab === 'details' ? '2px solid var(--primary-color)' : '2px solid transparent', color: activeTab === 'details' ? 'var(--primary-color)' : 'var(--text-muted)', transition: 'all 0.2s' }}>
                        Host & Details
                    </div>
                </div>

                {/* Tab Content Area */}
                <div style={{ minHeight: '200px' }}>

                    {/* Itinerary Tab Content */}
                    {activeTab === 'itinerary' && (
                        <div style={{ position: 'relative', paddingLeft: '30px', borderLeft: '2px solid rgba(255,255,255,0.1)' }}>
                            {itineraries.length > 0 ? itineraries.map((day, idx) => (
                                <div key={idx} style={{ marginBottom: '30px', position: 'relative' }}>
                                    <div style={{ position: 'absolute', left: '-35px', top: '5px', width: '10px', height: '10px', borderRadius: '50%', backgroundColor: 'var(--primary-color)' }}></div>
                                    <h4 style={{ fontSize: '1rem', color: 'var(--text-muted)', marginBottom: '10px' }}>Day {idx + 1}</h4>
                                    <p style={{ margin: 0, fontSize: '1.05rem', lineHeight: '1.6' }}>{day.replace(new RegExp(`Day ${idx + 1}:`, 'i'), '').trim()}</p>
                                </div>
                            )) : (
                                <p style={{ fontSize: '1.05rem', lineHeight: '1.6' }}>{tour.route_details}</p>
                            )}
                        </div>
                    )}

                    {/* Route Map Tab Content */}
                    {activeTab === 'route-map' && (
                        <div>
                            <img
                                src={tour.route_image_url || (tour.image_url || 'https://images.unsplash.com/photo-1558981403-c5f9899a28bc?w=1600')}
                                alt="Route Map"
                                style={{ width: '100%', maxHeight: '800px', objectFit: 'contain', borderRadius: '8px', marginBottom: '25px', display: 'block', border: '1px solid rgba(255,255,255,0.1)' }}
                            />
                            <p style={{ fontSize: '1.1rem', lineHeight: '1.8', color: '#d4d4d8', marginBottom: '30px', maxWidth: '100%' }}>
                                {tour.route_description || `The route from ${tour.start_location} to ${tour.end_location} offers a mix of scenic highways and challenging terrains. Expect technical bends, high-altitude passes, and breathtaking vistas.`}
                            </p>

                            <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(200px, 1fr))', gap: '20px', backgroundColor: 'var(--bg-card)', padding: '30px', borderRadius: '8px', border: '1px solid rgba(255,255,255,0.05)' }}>
                                <div>
                                    <div style={{ color: 'var(--text-muted)', fontSize: '0.8rem', textTransform: 'uppercase', letterSpacing: '1px', marginBottom: '5px' }}>Tarmac</div>
                                    <div style={{ fontWeight: 'bold', fontSize: '1.4rem', color: 'var(--primary-color)' }}>{tour.tarmac_pc !== null && tour.tarmac_pc !== undefined ? tour.tarmac_pc : 70}%</div>
                                </div>
                                <div>
                                    <div style={{ color: 'var(--text-muted)', fontSize: '0.8rem', textTransform: 'uppercase', letterSpacing: '1px', marginBottom: '5px' }}>Off-road</div>
                                    <div style={{ fontWeight: 'bold', fontSize: '1.4rem', color: 'var(--primary-color)' }}>{tour.offroad_pc !== null && tour.offroad_pc !== undefined ? tour.offroad_pc : 30}%</div>
                                </div>
                                <div>
                                    <div style={{ color: 'var(--text-muted)', fontSize: '0.8rem', textTransform: 'uppercase', letterSpacing: '1px', marginBottom: '5px' }}>Max Altitude</div>
                                    <div style={{ fontWeight: 'bold', fontSize: '1.4rem', color: 'var(--primary-color)' }}>{tour.max_altitude || '14,500 ft'}</div>
                                </div>
                            </div>
                        </div>
                    )}

                    {/* Details Tab Content */}
                    {activeTab === 'details' && (
                        <div style={{ maxWidth: '600px' }}>
                            <div style={{ backgroundColor: 'var(--bg-card)', padding: '30px', borderRadius: '8px', borderLeft: '4px solid var(--primary-color)', border: '1px solid rgba(255,255,255,0.05)', borderLeftWidth: '4px', borderLeftColor: 'var(--primary-color)' }}>
                                <h3 style={{ fontSize: '1.2rem', marginBottom: '20px', textTransform: 'uppercase', letterSpacing: '1px' }}>Hosted By</h3>
                                <div style={{ display: 'flex', alignItems: 'flex-start', gap: '20px', marginBottom: '15px' }}>
                                    <i className="fa-solid fa-store" style={{ fontSize: '1.5rem', color: 'var(--text-muted)', paddingTop: '5px' }}></i>
                                    <div>
                                        <div style={{ fontWeight: '900', fontSize: '1.2rem', marginBottom: '5px' }}>{tour.showroom_name || tour.dealer_name || 'Dealer'}</div>
                                        <div style={{ color: 'var(--text-muted)', fontSize: '0.95rem' }}>Authorized Host</div>
                                    </div>
                                </div>
                                <div style={{ display: 'flex', alignItems: 'center', gap: '20px', marginBottom: '15px' }}>
                                    <i className="fa-solid fa-location-dot" style={{ fontSize: '1.2rem', color: 'var(--text-muted)', width: '24px', textAlign: 'center' }}></i>
                                    <span style={{ fontSize: '0.95rem' }}>{tour.dealer_location}</span>
                                </div>
                                <div style={{ display: 'flex', alignItems: 'center', gap: '20px' }}>
                                    <i className="fa-solid fa-envelope" style={{ fontSize: '1.2rem', color: 'var(--text-muted)', width: '24px', textAlign: 'center' }}></i>
                                    <span style={{ fontSize: '0.95rem' }}>{tour.dealer_email || 'Official Host'}</span>
                                </div>
                            </div>

                            <h3 style={{ fontSize: '1.2rem', marginTop: '40px', marginBottom: '20px', textTransform: 'uppercase', letterSpacing: '1px' }}>Available Add-Ons</h3>
                            {tour.addons && tour.addons.length > 0 ? (
                                <div style={{ display: 'flex', flexWrap: 'wrap', gap: '10px', marginBottom: '30px' }}>
                                    {tour.addons.map(a => (
                                        <div key={a.id} style={{ display: 'flex', alignItems: 'center', gap: '8px', padding: '6px 15px', background: 'rgba(255,255,255,0.05)', borderRadius: '20px', border: '1px solid rgba(255,255,255,0.1)', fontSize: '0.85rem' }}>
                                            <i className={`fa-solid ${a.icon || 'fa-plus-circle'}`} style={{ color: 'var(--primary-color)' }}></i>
                                            <span style={{ fontWeight: '600' }}>{a.label}</span>
                                            <span style={{ color: 'var(--text-muted)' }}>+₹{parseFloat(a.price).toLocaleString()}</span>
                                        </div>
                                    ))}
                                </div>
                            ) : (
                                <p style={{ color: 'var(--text-muted)', marginBottom: '30px' }}>No additional add-ons listed for this tour.</p>
                            )}

                            <h3 style={{ fontSize: '1.2rem', marginTop: '40px', marginBottom: '20px', textTransform: 'uppercase', letterSpacing: '1px' }}>Additional Info</h3>
                        </div>
                    )}

                </div>

                {/* Media Section - Render dummy data if API returns empty */}
                <div style={{ marginTop: '30px', borderTop: '1px solid rgba(255,255,255,0.05)', paddingTop: '25px' }}>
                    <h2 style={{ fontSize: '1.4rem', marginBottom: '20px', textTransform: 'uppercase' }}>Media</h2>
                    <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(250px, 1fr))', gap: '20px' }}>
                        {(tour.media && tour.media.length > 0) ? tour.media.map(mediaItem => (
                            <div key={mediaItem.id} style={{ borderRadius: '8px', overflow: 'hidden', backgroundColor: 'var(--bg-card)', border: '1px solid rgba(255,255,255,0.05)' }}>
                                {mediaItem.media_type === 'youtube' ? (
                                    <div style={{ position: 'relative', paddingTop: '56.25%', cursor: 'pointer' }} onClick={() => setFullscreenMedia({ type: 'youtube', url: mediaItem.media_url })}>
                                        <div style={{ position: 'absolute', top: 0, left: 0, width: '100%', height: '100%', zIndex: 10 }}></div>
                                        <iframe
                                            src={getYouTubeEmbedUrl(mediaItem.media_url)}
                                            title={mediaItem.title || 'YouTube Video'}
                                            style={{ position: 'absolute', top: 0, left: 0, width: '100%', height: '100%', border: 0 }}
                                            allowFullScreen
                                        ></iframe>
                                    </div>
                                ) : mediaItem.media_type === 'local_video' ? (
                                    <div style={{ position: 'relative', cursor: 'pointer' }} onClick={() => setFullscreenMedia({ type: 'local_video', url: mediaItem.media_url })}>
                                        <video controls width="100%" style={{ display: 'block' }}>
                                            <source src={mediaItem.media_url} type="video/mp4" />
                                            Your browser does not support HTML video.
                                        </video>
                                        <div style={{ position: 'absolute', top: '10px', right: '10px', backgroundColor: 'rgba(0,0,0,0.6)', padding: '6px 10px', borderRadius: '4px', color: 'white', zIndex: 20 }} onClick={(e) => downloadMedia(e, mediaItem.media_url)} title="Download Video">
                                            <i className="fa-solid fa-download"></i>
                                        </div>
                                    </div>
                                ) : (
                                    <div style={{ position: 'relative', cursor: 'pointer' }} onClick={() => setFullscreenMedia({ type: 'image', url: mediaItem.media_url })}>
                                        <img src={mediaItem.media_url} alt={mediaItem.title || 'Tour Media'} style={{ width: '100%', height: 'auto', display: 'block', objectFit: 'cover', aspectRatio: '16/9' }} />
                                        <div style={{ position: 'absolute', top: '10px', right: '10px', backgroundColor: 'rgba(0,0,0,0.6)', padding: '6px 10px', borderRadius: '4px', color: 'white', zIndex: 20 }} onClick={(e) => downloadMedia(e, mediaItem.media_url)} title="Download Image">
                                            <i className="fa-solid fa-download"></i>
                                        </div>
                                    </div>
                                )}
                                {mediaItem.title && (
                                    <div style={{ padding: '15px' }}>
                                        <h4 style={{ margin: 0, fontSize: '1rem', color: 'var(--text-main)' }}>{mediaItem.title}</h4>
                                    </div>
                                )}
                            </div>
                        )) : (
                            /* DUMMY TEXT / MEDIA as requested by user */
                            <>
                                <div style={{ borderRadius: '8px', overflow: 'hidden', backgroundColor: 'var(--bg-card)', border: '1px solid rgba(255,255,255,0.05)', cursor: 'pointer', position: 'relative' }} onClick={() => setFullscreenMedia({ type: 'image', url: 'https://images.unsplash.com/photo-1599940778173-e276d4acb2bb?w=400' })}>
                                    <img src="https://images.unsplash.com/photo-1599940778173-e276d4acb2bb?w=400" alt="Dummy Image" style={{ width: '100%', height: 'auto', display: 'block', objectFit: 'cover', aspectRatio: '16/9' }} />
                                    <div style={{ position: 'absolute', top: '10px', right: '10px', backgroundColor: 'rgba(0,0,0,0.6)', padding: '6px 10px', borderRadius: '4px', color: 'white', zIndex: 20 }} onClick={(e) => downloadMedia(e, 'https://images.unsplash.com/photo-1599940778173-e276d4acb2bb?w=400')} title="Download Image">
                                        <i className="fa-solid fa-download"></i>
                                    </div>
                                    <div style={{ padding: '15px' }}>
                                        <h4 style={{ margin: 0, fontSize: '1rem', color: 'var(--text-main)' }}>Dummy Image Media</h4>
                                        <p style={{ margin: '5px 0 0 0', fontSize: '0.85rem', color: '#888' }}>This is placeholder text for an image.</p>
                                    </div>
                                </div>
                                <div style={{ borderRadius: '8px', overflow: 'hidden', backgroundColor: 'var(--bg-card)', border: '1px solid rgba(255,255,255,0.05)', cursor: 'pointer' }} onClick={() => setFullscreenMedia({ type: 'youtube', url: 'https://www.youtube.com/embed/dQw4w9WgXcQ' })}>
                                    <div style={{ height: '200px', backgroundColor: '#333', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
                                        <i className="fa-brands fa-youtube fa-3x" style={{ color: '#ff0000' }}></i>
                                    </div>
                                    <div style={{ padding: '15px' }}>
                                        <h4 style={{ margin: 0, fontSize: '1rem', color: 'var(--text-main)' }}>Dummy YouTube Video</h4>
                                        <p style={{ margin: '5px 0 0 0', fontSize: '0.85rem', color: '#888' }}>Sample YouTube Embed Box</p>
                                    </div>
                                </div>
                                <div style={{ borderRadius: '8px', overflow: 'hidden', backgroundColor: 'var(--bg-card)', border: '1px solid rgba(255,255,255,0.05)', cursor: 'pointer', position: 'relative' }} onClick={() => setFullscreenMedia({ type: 'local_video', url: 'assets/vid/dummy.mp4' })}>
                                    <div style={{ height: '200px', backgroundColor: '#222', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
                                        <i className="fa-solid fa-file-video fa-3x" style={{ color: '#888' }}></i>
                                    </div>
                                    <div style={{ position: 'absolute', top: '10px', right: '10px', backgroundColor: 'rgba(0,0,0,0.6)', padding: '6px 10px', borderRadius: '4px', color: 'white', zIndex: 20 }} onClick={(e) => downloadMedia(e, 'assets/vid/dummy.mp4')} title="Download Video">
                                        <i className="fa-solid fa-download"></i>
                                    </div>
                                    <div style={{ padding: '15px' }}>
                                        <h4 style={{ margin: 0, fontSize: '1rem', color: 'var(--text-main)' }}>Dummy Local Video</h4>
                                        <p style={{ margin: '5px 0 0 0', fontSize: '0.85rem', color: '#888' }}>Sample Local Video Player Box</p>
                                    </div>
                                </div>
                            </>
                        )}
                    </div>
                </div>

                {/* Travel Blog Section - Render dummy data if API returns empty */}
                <div style={{ marginTop: '60px', borderTop: '1px solid rgba(255,255,255,0.05)', paddingTop: '40px' }}>
                    <div style={{ display: 'flex', justifyContent: 'center', marginBottom: '40px' }}>
                        <div className="section-header-standard" style={{ textAlign: 'center' }}>
                            <h2 className="section-title-standard">THROTLLR Diaries</h2>
                            <div className="section-divider-standard" style={{ margin: '15px auto' }}></div>
                            <p className="section-subtitle-standard">Real stories from real riders. Share your journey.</p>
                        </div>
                    </div>
                    <div style={{ position: 'relative' }}>
                        <button className="btn-slider-prev" onClick={() => {
                            document.getElementById('throtllr-diaries-grid').scrollLeft -= 400;
                        }}><i className="fa-solid fa-chevron-left"></i></button>

                        <div id="throtllr-diaries-grid" className="road-diaries-grid">
                            {(tour.blogs && tour.blogs.length > 0) ? tour.blogs.map(blog => (
                                <div key={blog.id} className="vlog-card" style={{ flex: '0 0 min(380px, 85vw)', display: 'flex', flexDirection: 'column', backgroundColor: 'var(--bg-card)', border: '1px solid rgba(255,255,255,0.05)', borderRadius: '8px', overflow: 'hidden' }}>
                                    {/* Blog Media */}
                                    {blog.media_url && (
                                        <div style={{ width: '100%', backgroundColor: '#000', display: 'flex', minHeight: '250px', position: 'relative' }}>
                                            {blog.media_type === 'youtube' ? (
                                                <div style={{ position: 'relative', width: '100%', height: '100%', cursor: 'pointer' }} onClick={() => setFullscreenMedia({ type: 'youtube', url: blog.media_url })}>
                                                    <div style={{ position: 'absolute', top: 0, left: 0, width: '100%', height: '100%', zIndex: 10 }}></div>
                                                    <iframe
                                                        width="100%"
                                                        height="100%"
                                                        style={{ minHeight: '250px', border: 'none' }}
                                                        src={getYouTubeEmbedUrl(blog.media_url)}
                                                        title="YouTube Video"
                                                        allowFullScreen
                                                    ></iframe>
                                                </div>
                                            ) : blog.media_type === 'local_video' ? (
                                                <div style={{ position: 'relative', width: '100%', height: '100%', cursor: 'pointer' }} onClick={() => setFullscreenMedia({ type: 'local_video', url: blog.media_url })}>
                                                    <video controls width="100%" style={{ display: 'block', height: '250px', objectFit: 'contain', backgroundColor: '#000' }}>
                                                        <source src={blog.media_url} type="video/mp4" />
                                                    </video>
                                                    <div style={{ position: 'absolute', top: '10px', right: '10px', backgroundColor: 'rgba(0,0,0,0.6)', padding: '6px 10px', borderRadius: '4px', color: 'white', zIndex: 20 }} onClick={(e) => downloadMedia(e, blog.media_url)} title="Download Video">
                                                        <i className="fa-solid fa-download"></i>
                                                    </div>
                                                </div>
                                            ) : (
                                                <div style={{ position: 'relative', width: '100%', height: '100%', cursor: 'pointer' }} onClick={() => setFullscreenMedia({ type: 'image', url: blog.media_url })}>
                                                    <img src={blog.media_url} alt="Blog Media" style={{ width: '100%', height: '250px', objectFit: 'cover' }} />
                                                    <div style={{ position: 'absolute', top: '10px', right: '10px', backgroundColor: 'rgba(0,0,0,0.6)', padding: '6px 10px', borderRadius: '4px', color: 'white', zIndex: 20 }} onClick={(e) => downloadMedia(e, blog.media_url)} title="Download Image">
                                                        <i className="fa-solid fa-download"></i>
                                                    </div>
                                                </div>
                                            )}
                                        </div>
                                    )}
                                    <div style={{ padding: '20px', display: 'flex', flexDirection: 'column', flex: '1 1 auto' }}>
                                        <h3 style={{ fontSize: '1.2rem', margin: '0 0 10px 0', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>{blog.title}</h3>
                                        <p style={{ color: 'var(--text-muted)', fontSize: '0.9rem', margin: '0 0 15px 0', display: '-webkit-box', WebkitLineClamp: 2, WebkitBoxOrient: 'vertical', overflow: 'hidden' }}>{blog.excerpt}</p>
                                        <div style={{ display: 'flex', alignItems: 'center', gap: '12px', marginTop: 'auto', paddingTop: '15px', borderTop: '1px solid rgba(255,255,255,0.1)' }}>
                                            {blog.author_avatar ? (
                                                <img src={blog.author_avatar} alt={blog.author_name} style={{ width: '40px', height: '40px', borderRadius: '50%', objectFit: 'cover' }} />
                                            ) : (
                                                <div style={{ width: '40px', height: '40px', borderRadius: '50%', backgroundColor: 'var(--primary-color)', display: 'flex', alignItems: 'center', justifyContent: 'center', color: 'black', fontWeight: 'bold' }}>
                                                    {blog.author_name ? blog.author_name[0] : 'U'}
                                                </div>
                                            )}
                                            <div>
                                                <div style={{ fontWeight: 'bold', fontSize: '0.9rem' }}>{blog.author_name}</div>
                                                <div style={{ color: 'var(--text-muted)', fontSize: '0.8rem' }}>{new Date(blog.published_date).toLocaleDateString('en-GB')}</div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            )) : (
                                /* DUMMY TEXT / BLOG as requested by user */
                                <div className="vlog-card" style={{ flex: '0 0 min(380px, 85vw)', display: 'flex', flexDirection: 'column', backgroundColor: 'var(--bg-card)', border: '1px solid rgba(255,255,255,0.05)', borderRadius: '8px', overflow: 'hidden' }}>
                                    <div style={{ position: 'relative', cursor: 'pointer' }} onClick={() => setFullscreenMedia({ type: 'image', url: 'https://images.unsplash.com/photo-1558981403-c5f9899a28bc?w=800' })}>
                                        <img src="https://images.unsplash.com/photo-1558981403-c5f9899a28bc?w=800" alt="Dummy Blog" style={{ width: '100%', height: '250px', objectFit: 'cover' }} />
                                        <div style={{ position: 'absolute', top: '10px', right: '10px', backgroundColor: 'rgba(0,0,0,0.6)', padding: '6px 10px', borderRadius: '4px', color: 'white', zIndex: 20 }} onClick={(e) => downloadMedia(e, 'https://images.unsplash.com/photo-1558981403-c5f9899a28bc?w=800')} title="Download Image">
                                            <i className="fa-solid fa-download"></i>
                                        </div>
                                    </div>
                                    <div style={{ padding: '25px', flex: 1, display: 'flex', flexDirection: 'column' }}>
                                        <h3 style={{ fontSize: '1.3rem', marginBottom: '10px', lineHeight: '1.4' }}>Dummy Travel Blog Title Example</h3>
                                        <p style={{ color: 'var(--text-muted)', fontSize: '1rem', lineHeight: '1.6', flex: 1 }}>This is a placeholder excerpt for a dummy travel diary. The actual text will be fetched from the database when it goes live.</p>
                                        <div style={{ display: 'flex', alignItems: 'center', gap: '15px', marginTop: '20px', paddingTop: '20px', borderTop: '1px solid rgba(255,255,255,0.1)' }}>
                                            <div style={{ width: '40px', height: '40px', borderRadius: '50%', backgroundColor: 'var(--primary-color)', display: 'flex', alignItems: 'center', justifyContent: 'center', color: 'black', fontWeight: 'bold' }}>
                                                D
                                            </div>
                                            <div>
                                                <div style={{ fontWeight: 'bold', fontSize: '0.9rem' }}>Dummy Author</div>
                                                <div style={{ color: 'var(--text-muted)', fontSize: '0.8rem' }}>01/01/2026</div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            )}
                        </div>

                        <button className="btn-slider-next" onClick={() => {
                            document.getElementById('throtllr-diaries-grid').scrollLeft += 400;
                        }}><i className="fa-solid fa-chevron-right"></i></button>
                    </div>
                </div>
            </div>

            {/* Fullscreen Media Overlay */}
            {fullscreenMedia && (
                <div 
                    style={{ position: 'fixed', top: 0, left: 0, width: '100vw', height: '100vh', backgroundColor: 'rgba(0,0,0,0.9)', zIndex: 99999, display: 'flex', justifyContent: 'center', alignItems: 'center', cursor: 'zoom-out' }}
                    onClick={() => setFullscreenMedia(null)}
                >
                    {fullscreenMedia.type === 'youtube' ? (
                        <iframe
                            src={getYouTubeEmbedUrl(fullscreenMedia.url)}
                            title="Fullscreen YouTube Video"
                            style={{ width: '90vw', height: '90vh', maxWidth: '1200px', maxHeight: '675px', border: 0 }}
                            allowFullScreen
                        ></iframe>
                    ) : fullscreenMedia.type === 'local_video' ? (
                        <video controls style={{ maxWidth: '95vw', maxHeight: '95vh', objectFit: 'contain' }} autoPlay onClick={(e) => e.stopPropagation()}>
                            <source src={fullscreenMedia.url} type="video/mp4" />
                            Your browser does not support HTML video.
                        </video>
                    ) : (
                        <img src={fullscreenMedia.url} alt="Fullscreen View" style={{ maxWidth: '95vw', maxHeight: '95vh', objectFit: 'contain' }} />
                    )}
                    
                    <div style={{ position: 'absolute', top: '20px', right: '30px', display: 'flex', gap: '20px', zIndex: 100000 }}>
                        {/* Download Button */}
                        {fullscreenMedia.type !== 'youtube' && (
                            <button
                                style={{ background: 'transparent', color: 'white', border: 'none', fontSize: '2rem', cursor: 'pointer' }}
                                onClick={(e) => downloadMedia(e, fullscreenMedia.url)}
                                title="Download"
                            >
                                <i className="fa-solid fa-download"></i>
                            </button>
                        )}
                        <button 
                            style={{ background: 'transparent', color: 'white', border: 'none', fontSize: '3rem', cursor: 'pointer', lineHeight: '1' }}
                            onClick={(e) => { e.stopPropagation(); setFullscreenMedia(null); }}
                            title="Close"
                        >
                            &times;
                        </button>
                    </div>
                </div>
            )}
        </div>
    );
}
Back to Directory �������}�!1AQa"q2���#B��R��$3br� %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz�������������������������������������������������������������������������������� ������w�!1AQaq"2�B���� #3R�br� $4�%�&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz������������������������������������������������������������������������ ��?��_��+��?��(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(�����