    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

<script>
    // Sidebar toggle for mobile
    document.getElementById('sidebarToggle')?.addEventListener('click', function() {
        document.querySelector('.sidebar').classList.toggle('show');
    });

    // Close sidebar when clicking outside on mobile
    document.addEventListener('click', function(event) {
        const sidebar = document.querySelector('.sidebar');
        const toggle = document.getElementById('sidebarToggle');
        
        if (window.innerWidth <= 768) {
            if (!sidebar.contains(event.target) && !toggle?.contains(event.target)) {
                sidebar.classList.remove('show');
            }
        }
    });

    // Format currency
    function formatCurrency(amount) {
        return new Intl.NumberFormat('en-PH', {
            style: 'currency',
            currency: 'PHP'
        }).format(amount);
    }

    // Format date
    function formatDate(dateString) {
        const options = { year: 'numeric', month: 'short', day: 'numeric' };
        return new Date(dateString).toLocaleDateString('en-US', options);
    }

    // Show success alert
    function showSuccess(message) {
        const alertHtml = `
            <div class="alert alert-success alert-dismissible fade show" role="alert">
                <i class="fas fa-check-circle"></i> ${message}
                <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
            </div>
        `;
        insertAlert(alertHtml);
    }

    // Show error alert
    function showError(message) {
        const alertHtml = `
            <div class="alert alert-danger alert-dismissible fade show" role="alert">
                <i class="fas fa-exclamation-circle"></i> ${message}
                <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
            </div>
        `;
        insertAlert(alertHtml);
    }

    // Show info alert
    function showInfo(message) {
        const alertHtml = `
            <div class="alert alert-info alert-dismissible fade show" role="alert">
                <i class="fas fa-info-circle"></i> ${message}
                <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
            </div>
        `;
        insertAlert(alertHtml);
    }

    // Insert alert at top of main content
    function insertAlert(alertHtml) {
        const mainContent = document.querySelector('.main-content');
        const tempDiv = document.createElement('div');
        tempDiv.innerHTML = alertHtml;
        mainContent.insertBefore(tempDiv.firstElementChild, mainContent.firstChild);
    }

    // Confirm delete
    function confirmDelete(message = 'Are you sure you want to delete this record?') {
        return confirm(message);
    }

    // Print function
    function printPage() {
        window.print();
    }

    // Export to CSV
    function exportToCSV(filename, data) {
        let csv = '';
        let headers = Object.keys(data[0]);
        
        // Add headers
        csv += headers.join(',') + '\n';
        
        // Add data
        data.forEach(row => {
            csv += headers.map(header => {
                let value = row[header];
                if (typeof value === 'string' && value.includes(',')) {
                    value = '"' + value + '"';
                }
                return value;
            }).join(',') + '\n';
        });
        
        // Create blob and download
        const blob = new Blob([csv], { type: 'text/csv' });
        const link = document.createElement('a');
        link.href = window.URL.createObjectURL(blob);
        link.download = filename + '.csv';
        link.click();
    }
</script>

</body>
</html>
