/* SOLUCIÓN MÍNIMA PARA DROPDOWNS EN TABLAS - NO AFECTA RESPONSIVIDAD */

/* 1. Solo afectar a dropdowns dentro de tablas cuando están ABIERTOS */
.table .dropdown.show {
    position: relative;
    z-index: 1000;
}

/* 2. El menú dropdown debe mostrarse correctamente */
.table .dropdown.show .dropdown-menu {
    position: absolute !important;
    z-index: 1050 !important;
    right: 0 !important;
    left: auto !important;
}

/* 3. Para el modo oscuro */
.dark-theme .table .dropdown.show .dropdown-menu {
    background-color: #343a40 !important;
    border-color: #495057 !important;
}

/* 4. IMPORTANTE: NO modificar el comportamiento de table-responsive */
.table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
}

/* 5. Solo cuando un dropdown está abierto, permitir que se vea */
/* Usando :has() selector (soporte moderno) */
.table-responsive:has(.dropdown.show) {
    overflow: visible !important;
}

/* 6. Fallback para navegadores que no soportan :has() */
/* Se aplicará dinámicamente via JavaScript */
.table-responsive.dropdown-open {
    overflow: visible !important;
}

/* 7. Solución para móviles */
@media (max-width: 768px) {
    .table .dropdown.show .dropdown-menu {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 90% !important;
        max-width: 300px !important;
        z-index: 9999 !important;
    }
    
    .dropdown-overlay-mobile {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9998;
        display: none;
    }
    
    .dropdown.show + .dropdown-overlay-mobile {
        display: block;
    }
}

/* 8. Estilos específicos para el botón de acciones */
.table td.text-center .dropdown .btn-link {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 9. Asegurar que las tablas mantengan scroll horizontal */
.table-responsive > .table {
    min-width: 600px;
}

@media (max-width: 768px) {
    .table-responsive > .table {
        min-width: 500px;
    }
}

@media (max-width: 576px) {
    .table-responsive > .table {
        min-width: 400px;
    }
}
