
// Initialize the website functionality
document.addEventListener('DOMContentLoaded', function() {
    // Mobile menu toggle (if needed in future)
    const mobileMenuToggle = document.querySelector('.mobile-menu-toggle');
    const nav = document.querySelector('.nav');
    
    if (mobileMenuToggle) {
        mobileMenuToggle.addEventListener('click', function() {
            nav.classList.toggle('active');
        });
    }

    // Smooth scrolling for anchor links
    const smoothScrollLinks = document.querySelectorAll('a[href^="#"]');
    smoothScrollLinks.forEach(link => {
        link.addEventListener('click', function(e) {
            e.preventDefault();
            const targetId = this.getAttribute('href').substring(1);
            const targetElement = document.getElementById(targetId);
            
            if (targetElement) {
                targetElement.scrollIntoView({
                    behavior: 'smooth'
                });
            }
        });
    });

    // Add animation class to elements when they come into view
    const animateOnScroll = () => {
        const elements = document.querySelectorAll('.service-card, .brand-slide, .contact-item');
        
        elements.forEach(element => {
            const elementTop = element.getBoundingClientRect().top;
            const elementVisible = 150;
            
            if (elementTop < window.innerHeight - elementVisible) {
                element.classList.add('animate');
            }
        });
    };

    // Run animation check on scroll
    window.addEventListener('scroll', animateOnScroll);
    animateOnScroll(); // Run once on load

    // Phone number click tracking (optional)
    const phoneLinks = document.querySelectorAll('a[href^="tel:"]');
    phoneLinks.forEach(link => {
        link.addEventListener('click', function() {
            console.log('Phone call initiated:', this.href);
            // You can add analytics tracking here if needed
        });
    });

    // WhatsApp link click tracking (optional)
    const whatsappLinks = document.querySelectorAll('a[href^="https://wa.me"]');
    whatsappLinks.forEach(link => {
        link.addEventListener('click', function() {
            console.log('WhatsApp chat initiated:', this.href);
            // You can add analytics tracking here if needed
        });
    });

    // Floating buttons hover effects
    const floatingButtons = document.querySelectorAll('.floating-call, .floating-whatsapp');
    floatingButtons.forEach(button => {
        button.addEventListener('mouseenter', function() {
            this.style.transform = 'scale(1.1)';
        });
        
        button.addEventListener('mouseleave', function() {
            this.style.transform = 'scale(1)';
        });
    });

    // Add CSS for page-specific styles
    addPageSpecificStyles();
});

// Function to add page-specific styles
function addPageSpecificStyles() {
    const currentPage = window.location.pathname.split('/').pop();
    
    // Add styles for about page
    if (currentPage === 'about.html' || currentPage === '') {
        const aboutStyles = `
            .about-section {
                padding: 4rem 0;
                background: linear-gradient(135deg, #f9fafb, #e5e7eb);
            }
            
            .about-section h1 {
                text-align: center;
                font-size: 2.5rem;
                margin-bottom: 3rem;
                color: #374151;
            }
            
            .about-content {
                max-width: 800px;
                margin: 0 auto;
            }
            
            .about-text p {
                font-size: 1.1rem;
                line-height: 1.8;
                margin-bottom: 2rem;
                color: #4b5563;
            }
            
            .features-section h2 {
                font-size: 2rem;
                margin-bottom: 2rem;
                color: #374151;
            }
            
            .features-grid {
                display: grid;
                grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
                gap: 1rem;
                margin-bottom: 3rem;
            }
            
            .feature-item {
                display: flex;
                align-items: center;
                gap: 1rem;
                font-size: 1.1rem;
                color: #4b5563;
            }
            
            .check {
                font-size: 1.2rem;
            }
            
            .closing-text p {
                font-size: 1.1rem;
                line-height: 1.8;
                margin-bottom: 2rem;
                color: #4b5563;
            }
            
            .contact-highlight {
                background: #e0f2fe;
                padding: 2rem;
                border-radius: 1rem;
                border-left: 4px solid #2563eb;
            }
            
            .contact-highlight p {
                color: #1e40af;
                font-size: 1.2rem;
                margin-bottom: 1rem;
            }
        `;
        
        addStylesToHead(aboutStyles);
    }
    
    // Add styles for services page
    if (currentPage === 'services.html') {
        const servicesStyles = `
            .services-detail {
                padding: 4rem 0;
                background: #f9fafb;
            }
            
            .services-detail h1 {
                text-align: center;
                font-size: 2.5rem;
                margin-bottom: 3rem;
                color: #374151;
            }
            
            .service-category {
                margin-bottom: 4rem;
                background: white;
                padding: 3rem;
                border-radius: 1rem;
                box-shadow: 0 4px 20px rgba(0,0,0,0.1);
            }
            
            .service-category h2 {
                font-size: 2rem;
                margin-bottom: 2rem;
                color: #374151;
                text-align: center;
            }
            
            .service-images-grid {
                display: grid;
                grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
                gap: 2rem;
            }
            
            .service-image-item {
                text-align: center;
                background: #f9fafb;
                padding: 1.5rem;
                border-radius: 1rem;
                transition: transform 0.3s;
            }
            
            .service-image-item:hover {
                transform: translateY(-5px);
            }
            
            .service-image-item img {
                width: 100%;
                height: 200px;
                object-fit: cover;
                border-radius: 0.5rem;
                margin-bottom: 1rem;
            }
            
            .service-image-item h3 {
                font-size: 1.3rem;
                margin-bottom: 1rem;
                color: #374151;
            }
            
            .service-image-item p {
                color: #6b7280;
                line-height: 1.6;
            }
        `;
        
        addStylesToHead(servicesStyles);
    }
    
    // Add styles for contact page
    if (currentPage === 'contact.html') {
        const contactStyles = `
            .contact-section {
                padding: 4rem 0;
                background: linear-gradient(135deg, #e0f2fe, #f0f9ff);
            }
            
            .contact-section h1 {
                text-align: center;
                font-size: 2.5rem;
                margin-bottom: 3rem;
                color: #374151;
            }
            
            .contact-grid {
                display: grid;
                grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
                gap: 3rem;
                max-width: 1200px;
                margin: 0 auto;
            }
            
            .contact-info-card {
                background: white;
                padding: 2rem;
                border-radius: 1rem;
                box-shadow: 0 4px 20px rgba(0,0,0,0.1);
            }
            
            .contact-info-card h2 {
                font-size: 1.8rem;
                margin-bottom: 2rem;
                color: #374151;
            }
            
            .contact-item {
                display: flex;
                align-items: flex-start;
                gap: 1rem;
                margin-bottom: 2rem;
            }
            
            .contact-item .icon {
                font-size: 2rem;
                min-width: 2rem;
            }
            
            .contact-item h3 {
                font-size: 1.2rem;
                margin-bottom: 0.5rem;
                color: #374151;
            }
            
            .contact-item p {
                color: #6b7280;
            }
            
            .phone-link {
                color: #2563eb;
                text-decoration: none;
                font-size: 1.3rem;
                font-weight: 600;
            }
            
            .phone-link:hover {
                color: #1d4ed8;
            }
            
            .quick-booking {
                background: #e0f2fe;
                padding: 2rem;
                border-radius: 1rem;
                margin-top: 2rem;
            }
            
            .quick-booking h3 {
                color: #1e40af;
                margin-bottom: 1rem;
            }
            
            .quick-booking p {
                color: #374151;
                margin-bottom: 1.5rem;
            }
            
            .booking-btn {
                background: #2563eb;
                color: white;
                padding: 1rem 2rem;
                text-decoration: none;
                border-radius: 0.5rem;
                font-weight: 600;
                display: inline-flex;
                align-items: center;
                gap: 0.5rem;
                transition: background 0.3s;
            }
            
            .booking-btn:hover {
                background: #1d4ed8;
            }
            
            .service-showcase {
                background: white;
                padding: 2rem;
                border-radius: 1rem;
                box-shadow: 0 4px 20px rgba(0,0,0,0.1);
            }
            
            .service-showcase h2 {
                font-size: 1.8rem;
                margin-bottom: 2rem;
                color: #374151;
            }
            
            .main-image {
                width: 100%;
                height: 250px;
                object-fit: cover;
                border-radius: 1rem;
                margin-bottom: 1.5rem;
            }
            
            .showcase-content h3 {
                font-size: 1.3rem;
                margin-bottom: 1rem;
                color: #374151;
            }
            
            .showcase-content p {
                color: #6b7280;
                line-height: 1.6;
                margin-bottom: 2rem;
            }
            
            .service-gallery {
                display: grid;
                grid-template-columns: 1fr 1fr;
                gap: 1rem;
                margin-bottom: 2rem;
            }
            
            .service-gallery img {
                width: 100%;
                height: 120px;
                object-fit: cover;
                border-radius: 0.5rem;
            }
            
            .why-choose {
                background: #ecfdf5;
                padding: 1.5rem;
                border-radius: 1rem;
            }
            
            .why-choose h4 {
                color: #059669;
                margin-bottom: 1rem;
            }
            
            .why-choose ul {
                list-style: none;
                color: #047857;
            }
            
            .why-choose ul li {
                margin-bottom: 0.5rem;
                font-size: 0.9rem;
            }
        `;
        
        addStylesToHead(contactStyles);
    }
}

// Helper function to add styles to head
function addStylesToHead(styles) {
    const styleElement = document.createElement('style');
    styleElement.textContent = styles;
    document.head.appendChild(styleElement);
}
