            </main>
    </div>
    
    <footer class="text-center py-3 mt-4" style="font-size: 0.85rem; color: #6c757d;">
        <hr>
        <p class="mb-0">
            © <?= date('Y') ?> <?= SITE_NAME ?> - Sistema de Laboratorio Clínico
            <br>
            <small>Diseñado By <strong>ControlSys</strong></small>
        </p>
    </footer>

    <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.7.0.min.js"></script>
    <script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.datatables.net/1.13.6/js/dataTables.bootstrap5.min.js"></script>
    <script>
        // Toggle menú móvil
        function toggleSidebar() {
            const sidebar = document.getElementById('sidebarMenu');
            const overlay = document.querySelector('.sidebar-overlay');
            sidebar.classList.toggle('show');
            overlay.classList.toggle('show');
        }
        
        // Colapsar/expandir sidebar en desktop
        function collapseSidebar() {
            const sidebar = document.getElementById('sidebarMenu');
            const main = document.getElementById('mainContent');
            sidebar.classList.toggle('collapsed');
            document.body.classList.toggle('sidebar-collapsed');
            // Guardar estado en localStorage
            const isCollapsed = sidebar.classList.contains('collapsed');
            localStorage.setItem('sidebar_collapsed', isCollapsed ? '1' : '0');
        }
        
        // Restaurar estado del sidebar al cargar la página
        document.addEventListener('DOMContentLoaded', function() {
            const savedState = localStorage.getItem('sidebar_collapsed');
            if (savedState === '1') {
                const sidebar = document.getElementById('sidebarMenu');
                if (sidebar && window.innerWidth >= 768) {
                    sidebar.classList.add('collapsed');
                    document.body.classList.add('sidebar-collapsed');
                }
            }
        });
        
        // Toggle tema oscuro
        function toggleTheme() {
            const current = getCookie('tema_oscuro') || '0';
            const newTheme = current === '1' ? '0' : '1';
            setCookie('tema_oscuro', newTheme, 365);
            location.reload();
        }
        
        function setCookie(name, value, days) {
            const d = new Date();
            d.setTime(d.getTime() + (days * 24 * 60 * 60 * 1000));
            document.cookie = name + "=" + value + ";expires=" + d.toUTCString() + ";path=/";
        }
        
        function getCookie(name) {
            const nameEQ = name + "=";
            const ca = document.cookie.split(';');
            for(let i = 0; i < ca.length; i++) {
                let c = ca[i];
                while (c.charAt(0) == ' ') c = c.substring(1, c.length);
                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
            }
            return null;
        }
        
        // Actualizar icono de tema
        document.addEventListener('DOMContentLoaded', function() {
            const temaOscuro = getCookie('tema_oscuro') === '1';
            const icon = document.getElementById('themeIcon');
            if (icon) {
                icon.className = temaOscuro ? 'bi bi-sun-fill' : 'bi bi-moon-stars-fill';
            }
        });
        
        $(document).ready(function() {
            // Inicializar DataTables
            if ($('.datatable').length) {
                $('.datatable').DataTable({
                    language: {
                        url: '//cdn.datatables.net/plug-ins/1.13.6/i18n/es-ES.json'
                    },
                    pageLength: 25,
                    responsive: true,
                    order: []
                });
            }

            // Auto-ocultar alertas
            setTimeout(function() {
                $('.alert').fadeOut('slow');
            }, 5000);
        });

        // Función para confirmar eliminación
        function confirmDelete(message = '¿Está seguro de eliminar este registro?') {
            return confirm(message);
        }

        // Función para formatear moneda
        function formatMoney(amount) {
            return '<?= CURRENCY ?>' + parseFloat(amount).toFixed(2);
        }
    </script>
</body>
</html>
