        </div>
    </main>
    </div> <!-- Close flex-1 flex-col -->
</div> <!-- Close flex min-h-screen -->

    <!-- Footer -->
    <footer class="bg-gray-900 text-white">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
            
 <div class="flex items-center space-x-3 mb-4">
                        <div class="w-10 h-10 bg-gradient-to-r from-purple-600 to-blue-600 rounded-lg flex items-center justify-center">
                            <i class="fas fa-chart-line text-white text-xl"></i>
                        </div>
                        <span class="text-xl font-bold"><?php echo SITE_NAME; ?></span>
                    </div>

            <!-- Bottom Bar -->
            <div class="border-t border-gray-800 mt-8 pt-8 flex flex-col md:flex-row justify-between items-center">
                <div class="text-gray-400 text-sm mb-4 md:mb-0">
                    &copy; <?php echo date('Y'); ?> <?php echo SITE_NAME; ?>. All rights reserved.
                </div>

                <div class="flex space-x-6 text-sm">
                    <a href="privacy.php" class="text-gray-400 hover:text-white transition-colors">Privacy Policy</a>
                    <a href="terms.php" class="text-gray-400 hover:text-white transition-colors">Terms of Service</a>
                    <a href="cookie-policy.php" class="text-gray-400 hover:text-white transition-colors">Cookie Policy</a>
                    <a href="disclaimer.php" class="text-gray-400 hover:text-white transition-colors">Disclaimer</a>
                </div>
            </div>
        </div>
    </footer>

    <!-- Back to Top Button -->
    <button id="back-to-top" class="fixed bottom-6 right-6 bg-purple-600 hover:bg-purple-700 text-white p-3 rounded-full shadow-lg transition-all duration-300 transform opacity-0 translate-y-4" style="display: none;">
        <i class="fas fa-arrow-up"></i>
    </button>

    <!-- Notification Container -->
    <div id="notification-container" class="fixed top-4 right-4 z-50 space-y-2"></div>

    <!-- Mobile Menu Script -->
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const menuToggle = document.getElementById('menuToggle');
            const sidebar = document.getElementById('sidebar');

            if (menuToggle && sidebar) {
                menuToggle.addEventListener('click', function(event) {
                    event.stopPropagation(); // Prevent click from bubbling to document
                    sidebar.classList.toggle('-translate-x-full');
                });

                document.addEventListener('click', function(event) {
                    const isClickInsideSidebar = sidebar.contains(event.target);
                    const isClickOnToggle = menuToggle.contains(event.target);

                    if (!isClickInsideSidebar && !isClickOnToggle && !sidebar.classList.contains('-translate-x-full')) {
                        sidebar.classList.add('-translate-x-full');
                    }
                });
            }
        });

        // User Notification System
        function fetchUserNotifications() {
            $.ajax({
                url: '../api/user-notifications.php',
                method: 'GET',
                dataType: 'json',
                success: function(response) {
                    if (response.success) {
                        $('#user-notification-list').html(response.html);
                        const count = parseInt(response.unread_count, 10);
                        if (count > 0) {
                            $('#user-notification-count').text(count).show();
                        } else {
                            $('#user-notification-count').hide();
                        }
                    }
                }
            });
        }

        function markUserNotificationsAsRead() {
            const countBadge = $('#user-notification-count');
            if (countBadge.is(':visible')) {
                $.ajax({
                    url: '../api/user-notifications.php',
                    method: 'POST',
                    data: { action: 'mark_read' },
                    success: function() {
                        countBadge.text('0').hide();
                    }
                });
            }
        }

        // Initial fetch for user notifications
        fetchUserNotifications();

        // Back to top functionality
        window.addEventListener('scroll', function() {
            const backToTop = document.getElementById('back-to-top');
            if (window.pageYOffset > 300) {
                backToTop.style.display = 'block';
                setTimeout(() => {
                    backToTop.classList.remove('opacity-0', 'translate-y-4');
                    backToTop.classList.add('opacity-100', 'translate-y-0');
                }, 10);
            } else {
                backToTop.classList.remove('opacity-100', 'translate-y-0');
                backToTop.classList.add('opacity-0', 'translate-y-4');
                setTimeout(() => {
                    backToTop.style.display = 'none';
                }, 300);
            }
        });

        document.getElementById('back-to-top').addEventListener('click', function() {
            window.scrollTo({ top: 0, behavior: 'smooth' });
        });

        // Notification system
        function showNotification(message, type = 'info', duration = 5000) {
            const container = document.getElementById('notification-container');
            const notification = document.createElement('div');
            notification.className = `notification ${type}`;
            notification.innerHTML = `
                <div class="flex items-center">
                    <i class="fas ${getNotificationIcon(type)} mr-2"></i>
                    <span>${message}</span>
                    <button onclick="this.parentElement.parentElement.remove()" class="ml-auto">
                        <i class="fas fa-times"></i>
                    </button>
                </div>
            `;

            container.appendChild(notification);

            setTimeout(() => {
                notification.classList.add('show');
            }, 10);

            if (duration > 0) {
                setTimeout(() => {
                    notification.classList.remove('show');
                    setTimeout(() => {
                        notification.remove();
                    }, 300);
                }, duration);
            }
        }

        function getNotificationIcon(type) {
            const icons = {
                success: 'fa-check-circle',
                error: 'fa-exclamation-circle',
                warning: 'fa-exclamation-triangle',
                info: 'fa-info-circle'
            };
            return icons[type] || 'fa-info-circle';
        }

        // Auto-hide alerts after 5 seconds
        setTimeout(() => {
            const alerts = document.querySelectorAll('.alert');
            alerts.forEach(alert => {
                alert.style.transition = 'opacity 0.5s';
                alert.style.opacity = '0';
                setTimeout(() => alert.remove(), 500);
            });
        }, 5000);

        // CSRF token setup for AJAX requests
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });

        // Global loading state
        let loadingCount = 0;

        function showLoading() {
            loadingCount++;
            if (loadingCount === 1) {
                $('body').append('<div id="loading-overlay" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"><div class="spinner"></div></div>');
            }
        }

        function hideLoading() {
            loadingCount--;
            if (loadingCount <= 0) {
                loadingCount = 0;
                $('#loading-overlay').remove();
            }
        }

        // Form validation helpers
        function validateEmail(email) {
            const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
            return re.test(email);
        }

        function validatePassword(password) {
            return password.length >= 6;
        }

        function formatCurrency(amount) {
            return new Intl.NumberFormat('en-US', {
                style: 'currency',
                currency: 'USD'
            }).format(amount);
        }

        // Auto-submit forms with data-auto-submit attribute
        document.addEventListener('DOMContentLoaded', function() {
            const autoSubmitForms = document.querySelectorAll('form[data-auto-submit]');
            autoSubmitForms.forEach(form => {
                const inputs = form.querySelectorAll('input, select, textarea');
                inputs.forEach(input => {
                    input.addEventListener('change', function() {
                        form.submit();
                    });
                });
            });
        });

        // Initialize tooltips
        $(document).ready(function() {
            $('[data-tooltip]').each(function() {
                const tooltip = $(this).data('tooltip');
                $(this).attr('title', tooltip);
            });
        });
    </script>

    <!-- Alpine.js for reactive components -->
    <script src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js" defer></script>
</body>
</html>
