/* Responsive Table - Estilos comunes para tablas colapsables en móvil */

/* Estilos básicos de la tabla */
.responsive-table {
    width: 100%;
    margin-bottom: 1rem;
}

.responsive-table thead th {
    background-color: #f8f9fa;
    font-weight: 600;
    border-bottom: 2px solid #dee2e6;
    padding: 0.75rem;
    vertical-align: middle;
}

.responsive-table tbody td {
    padding: 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid #dee2e6;
}

/* Hover effect para las filas */
.responsive-table tbody tr:hover {
    background-color: #f8f9fa;
}

/* Responsive: En móviles convertir la tabla en tarjetas colapsables */
@media screen and (max-width: 768px) {
    /* Ocultar el thead */
    .responsive-table thead {
        display: none;
    }

    /* Convertir cada fila en una tarjeta colapsable */
    .responsive-table tbody tr {
        display: block;
        margin-bottom: 0.75rem;
        border: 1px solid #dee2e6;
        border-radius: 0.375rem;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        background-color: #fff;
        position: relative;
    }

    .responsive-table tbody tr:hover {
        box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    }    /* Primera celda (nombre/título) siempre visible */
    .responsive-table tbody td:first-child {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem;
        border-bottom: 1px solid #dee2e6;
        cursor: pointer !important;
        user-select: none;
        position: relative;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        touch-action: manipulation; /* Mejor respuesta táctil */
    }
    
    /* Hacer que todos los elementos internos también sean clickeables */
    .responsive-table tbody td:first-child * {
        cursor: pointer !important;
        pointer-events: auto;
    }
    
    /* Feedback visual al tocar en móvil */
    .responsive-table tbody td:first-child:active {
        background-color: #e9ecef;
    }

    .responsive-table tbody td:first-child:before {
        display: none;
    }

    /* Icono de expandir/colapsar */
    .responsive-table tbody td:first-child:after {
        content: '\f078'; /* fa-chevron-down */
        font-family: "Font Awesome 5 Free";
        font-weight: 900;
        margin-left: auto;
        padding-left: 1rem;
        color: #6c757d;
        transition: transform 0.3s ease;
        flex-shrink: 0;
        pointer-events: none; /* Permitir que los clicks pasen a través */
    }

    .responsive-table tbody tr.expanded td:first-child:after {
        transform: rotate(180deg);
    }

    /* Resto de celdas ocultas por defecto */
    .responsive-table tbody td:not(:first-child) {
        display: none;
        padding: 0.5rem 0.75rem;
        border: none;
        position: relative;
    }

    /* Mostrar celdas cuando la fila está expandida */
    .responsive-table tbody tr.expanded td:not(:first-child) {
        display: block;
    }

    /* Agregar el label antes de cada celda (excepto primera) */
    .responsive-table tbody td:not(:first-child):before {
        content: attr(data-label);
        font-weight: 600;
        display: block;
        margin-bottom: 0.25rem;
        color: #495057;
        font-size: 0.875rem;
    }

    /* Estilos especiales para la columna de acciones (última celda) */
    .responsive-table tbody td:last-child {
        border-top: 1px solid #dee2e6;
        margin-top: 0.5rem;
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }

    .responsive-table tbody td:last-child:before {
        display: none; /* No mostrar label para acciones */
    }

    /* Centrar los botones de acciones en móvil */
    .responsive-table tbody td:last-child .action-buttons {
        display: flex;
        justify-content: center;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    /* Ajustar tamaño de texto en móvil */
    .responsive-table tbody td {
        font-size: 0.9rem;
    }

    .responsive-table tbody td strong {
        font-size: 1rem;
    }

    /* Eliminar el cursor pointer del tr completo en móvil */
    .responsive-table tbody tr {
        cursor: default !important;
    }
}

/* Tablet: Mostrar tabla pero con tamaños ajustados */
@media screen and (min-width: 769px) and (max-width: 991px) {
    .responsive-table thead th,
    .responsive-table tbody td {
        padding: 0.5rem;
        font-size: 0.875rem;
    }

    .responsive-table tbody td strong {
        font-size: 0.95rem;
    }
}

/* Desktop: Tamaños normales - SOLUCIÓN SIMPLE */
@media screen and (min-width: 992px) {
    /* Contenedor con scroll horizontal */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Tabla básica sin restricciones */
    .responsive-table {
        width: 100%;
        table-layout: auto;
    }
    
    /* Celdas básicas con wrap */
    .responsive-table th,
    .responsive-table td {
        padding: 0.75rem;
        vertical-align: top;
        white-space: normal;
        word-wrap: break-word;
    }
    
    /* Columna de acciones sin wrap */
    .responsive-table th:last-child,
    .responsive-table td:last-child {
        white-space: nowrap;
        text-align: center;
    }

    /* Columna de acciones con ancho fijo */
    .responsive-table .actions-col {
        width: 110px;
    }

    /* Utility for inline label minimum width used in contract detail */
    .label-min {
        min-width: 120px;
        display: inline-block;
    }

    /* Filas clicables en escritorio */
    .responsive-table tbody tr.clickable-row {
        cursor: pointer;
    }
}

/* Mejoras visuales generales */
.responsive-table .text-muted.small {
    font-size: 0.875rem;
    color: #6c757d !important;
}

/* Estilos para los enlaces de contacto */
.responsive-table a {
    color: #0d6efd;
    text-decoration: none;
}

.responsive-table a:hover {
    text-decoration: underline;
}
