jQuery(document).ready(function($) {
    // Tab navigation
    $('.aysa-menu li a').on('click', function(e) {
        e.preventDefault();
        
        // Remove active class from all menu items
        $('.aysa-menu li').removeClass('active');
        
        // Add active class to clicked menu item
        $(this).parent().addClass('active');
        
        // Hide all tab content
        $('.aysa-tab-content').removeClass('active');
        
        // Show selected tab content
        $($(this).attr('href')).addClass('active');
    });
    
    // Domain Authority form submission
    $('#domain-authority-form').on('submit', function(e) {
        e.preventDefault();
        
        const domainUrl = $('#domain-url').val();
        const resultsDiv = $('#domain-results');
        
        // Show loading state
        resultsDiv.html('<div class="aysa-loading">Analyzing domain...</div>').show();
        
        // Simulate API call (replace with actual API call)
        setTimeout(() => {
            // Example results
            const results = `
                <div class="aysa-result-card">
                    <h4>Domain Authority Score</h4>
                    <div class="aysa-score">85</div>
                    <div class="aysa-metrics">
                        <div class="aysa-metric">
                            <span class="aysa-metric-label">Backlinks</span>
                            <span class="aysa-metric-value">1,234</span>
                        </div>
                        <div class="aysa-metric">
                            <span class="aysa-metric-label">Referring Domains</span>
                            <span class="aysa-metric-value">456</span>
                        </div>
                        <div class="aysa-metric">
                            <span class="aysa-metric-label">Organic Traffic</span>
                            <span class="aysa-metric-value">10.5K</span>
                        </div>
                    </div>
                </div>
            `;
            
            resultsDiv.html(results);
        }, 1500);
    });
    
    // Responsive menu toggle for mobile
    const menuToggle = $('<button class="aysa-menu-toggle">Menu</button>');
    $('.aysa-header').append(menuToggle);
    
    menuToggle.on('click', function() {
        $('.aysa-sidebar').toggleClass('active');
    });
    
    // Close menu when clicking outside on mobile
    $(document).on('click', function(e) {
        if ($(window).width() <= 768) {
            if (!$(e.target).closest('.aysa-sidebar, .aysa-menu-toggle').length) {
                $('.aysa-sidebar').removeClass('active');
            }
        }
    });
}); 