        </div>
    </main>
    
    <!-- Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    
    <!-- Custom JS -->
    <script>
        function toggleSidebar() {
            const sidebar = document.getElementById('sidebar');
            sidebar.classList.toggle('show');
        }
        
        // Cerrar sidebar al hacer click fuera (solo en móvil)
        document.addEventListener('click', function(e) {
            const sidebar = document.getElementById('sidebar');
            const toggleBtn = document.querySelector('.btn[onclick="toggleSidebar()"]');
            
            if (window.innerWidth < 992 && 
                !sidebar.contains(e.target) && 
                !toggleBtn.contains(e.target) &&
                sidebar.classList.contains('show')) {
                sidebar.classList.remove('show');
            }
        });
        
        // Auto-hide alerts
        setTimeout(function() {
            const alerts = document.querySelectorAll('.alert:not(.alert-permanent)');
            alerts.forEach(function(alert) {
                if (alert) {
                    alert.classList.remove('show');
                    setTimeout(function() {
                        alert.remove();
                    }, 150);
                }
            });
        }, 5000);
        
        // Confirmación para acciones destructivas
        function confirmAction(message) {
            return confirm(message || '¿Estás seguro de realizar esta acción?');
        }
        
        // Funciones de utilidad para tablas
        function toggleAllCheckboxes(source) {
            const checkboxes = document.querySelectorAll('input[type="checkbox"][name="selected[]"]');
            checkboxes.forEach(function(checkbox) {
                checkbox.checked = source.checked;
            });
        }
        
        function updateBulkActions() {
            const selected = document.querySelectorAll('input[type="checkbox"][name="selected[]"]:checked');
            const bulkActions = document.querySelector('.bulk-actions');
            
            if (bulkActions) {
                if (selected.length > 0) {
                    bulkActions.style.display = 'block';
                } else {
                    bulkActions.style.display = 'none';
                }
            }
        }
        
        // Filtros dinámicos
        function applyFilters() {
            const form = document.querySelector('#filterForm');
            if (form) {
                form.submit();
            }
        }
    </script>
    
    <?php if (isset($additional_js)): ?>
        <?php echo $additional_js; ?>
    <?php endif; ?>
</body>
</html>