/**
 * Estilos modernos para DataTables
 * Diseño actualizado con colores, sombras y efectos suaves
 */

/* ============================================
   CONTENEDOR PRINCIPAL
   ============================================ */
.dataTables_wrapper {
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ============================================
   TABLA PRINCIPAL
   ============================================ */
#tabla-cuotas {
    border-collapse: separate !important;
    border-spacing: 0;
    width: 100% !important;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    overflow: hidden;
}

/* Encabezado de tabla */
#tabla-cuotas thead {
    background: linear-gradient(135deg, #e53935 0%, #b71c1c 100%);
}

#tabla-cuotas thead th {
    color: #ffffff !important;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 16px 12px !important;
    border: none !important;
    white-space: nowrap;
}

/* Cuerpo de tabla */
#tabla-cuotas tbody td {
    padding: 14px 12px !important;
    vertical-align: middle;
    border-bottom: 1px solid #f0f0f0 !important;
    border-top: none !important;
    font-size: 14px;
    color: #333;
}

/* Filas alternadas */
#tabla-cuotas tbody tr {
    transition: all 0.2s ease;
}

#tabla-cuotas tbody tr:nth-child(even) {
    background-color: #fafafa;
}

#tabla-cuotas tbody tr:hover {
    background-color: #ffebee !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(229, 57, 53, 0.15);
}

/* ============================================
   CONTROLES SUPERIORES (Búsqueda y Longitud)
   ============================================ */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 20px;
}

.dataTables_wrapper .dataTables_filter {
    text-align: right;
}

.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label {
    font-weight: 500;
    color: #555;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dataTables_wrapper .dataTables_filter label {
    justify-content: flex-end;
}

/* Select de registros por página */
.dataTables_wrapper .dataTables_length select {
    padding: 4px 25px 5px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    color: #333;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23e53935' d='M6 9L1 4h10z'/%3E%3C/svg%3E") no-repeat right 10px center;
    background-size: 12px;
    appearance: none;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 70px;
}

.dataTables_wrapper .dataTables_length select:hover {
    border-color: #e53935;
}

.dataTables_wrapper .dataTables_length select:focus {
    outline: none;
    border-color: #e53935;
    box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.1);
}

/* Input de búsqueda */
.dataTables_wrapper .dataTables_filter input {
    padding: 10px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 14px;
    color: #333;
    width: 250px;
    transition: all 0.3s ease;
    background: #fff;
}

.dataTables_wrapper .dataTables_filter input:focus {
    outline: none;
    border-color: #e53935;
    box-shadow: none;
    width: 300px;
}

.dataTables_wrapper .dataTables_filter input::placeholder {
    color: #999;
}

/* ============================================
   INFORMACIÓN Y PAGINACIÓN
   ============================================ */
.dataTables_wrapper .dataTables_info {
    padding: 16px 0;
    color: #666;
    font-size: 14px;
    font-weight: 500;
}

/* Contenedor de paginación */
.dataTables_wrapper .dataTables_paginate {
    padding: 16px 0;
}

.dataTables_wrapper .dataTables_paginate .pagination {
    margin: 0;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* Botones de paginación */
.dataTables_wrapper .dataTables_paginate .page-item .page-link {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    color: #e53935;
    font-weight: 600;
    padding: 8px 14px;
    margin: 0;
    transition: all 0.2s ease;
    background: #fff;
    min-width: 40px;
    text-align: center;
}

.dataTables_wrapper .dataTables_paginate .page-item .page-link:hover {
    background: #ffebee;
    border-color: #e53935;
    color: #e53935;
    transform: translateY(-1px);
}

.dataTables_wrapper .dataTables_paginate .page-item.active .page-link {
    background: linear-gradient(135deg, #e53935 0%, #b71c1c 100%);
    border-color: #e53935;
    color: #fff;
    box-shadow: 0 4px 12px rgba(229, 57, 53, 0.3);
}

.dataTables_wrapper .dataTables_paginate .page-item.disabled .page-link {
    border-color: #f0f0f0;
    color: #ccc;
    background: #fafafa;
    cursor: not-allowed;
}

/* ============================================
   INDICADOR DE PROCESAMIENTO
   ============================================ */
.dataTables_wrapper .dataTables_processing {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 30px 50px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    font-weight: 600;
    color: #e53935;
    z-index: 9999;
    border: 2px solid #e53935;
}

.dataTables_wrapper .dataTables_processing::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 10px;
    border: 3px solid #ffebee;
    border-top-color: #e53935;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   CHECKBOXES PERSONALIZADOS
   ============================================ */
#tabla-cuotas tbody td:first-child {
    text-align: center;
    vertical-align: middle !important;
}

#tabla-cuotas .rn-custom-checkbox {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    padding: 0;
    min-height: 24px;
}

#tabla-cuotas .rn-custom-checkbox .custom-control-input:checked ~ .custom-control-label::before {
    background-color: #e53935;
    border-color: #e53935;
}

#tabla-cuotas .rn-custom-checkbox .custom-control-label {
    margin-bottom: 0;
    line-height: 1;
}

#tabla-cuotas .rn-custom-checkbox .custom-control-label::before {
    border-radius: 4px;
    border: 2px solid #ddd;
    transition: all 0.2s ease;
    top: 0;
}

#tabla-cuotas .rn-custom-checkbox .custom-control-label::after {
    top: 0;
}

#tabla-cuotas .rn-custom-checkbox .custom-control-input:focus ~ .custom-control-label::before {
    box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.15);
}

/* ============================================
   MENSAJES DE TABLA VACÍA
   ============================================ */
.dataTables_wrapper .dataTables_empty {
    padding: 40px 20px !important;
    text-align: center;
    color: #999;
    font-size: 15px;
    font-weight: 500;
}

.dataTables_wrapper .dataTables_empty::before {
    content: '📋';
    display: block;
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */
@media screen and (max-width: 768px) {
    /* Hacer la tabla scrollable horizontalmente */
    .section-table .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Mostrar todas las columnas en mobile */
    #tabla-cuotas th.d-none.d-lg-table-cell,
    #tabla-cuotas td.d-none.d-lg-table-cell {
        display: table-cell !important;
    }
    
    /* Asegurar ancho mínimo de la tabla */
    #tabla-cuotas {
        min-width: 900px;
        font-size: 12px;
    }
    
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        text-align: center;
        margin-bottom: 15px;
    }
    
    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        max-width: 100%;
    }
    
    .dataTables_wrapper .dataTables_paginate {
        text-align: center;
    }
    
    .dataTables_wrapper .dataTables_paginate .pagination {
        justify-content: center;
    }
    
    #tabla-cuotas thead th {
        font-size: 10px;
        padding: 8px 4px !important;
        white-space: nowrap;
    }
    
    #tabla-cuotas tbody td {
        padding: 8px 4px !important;
        font-size: 11px;
    }
    
    /* Hacer el checkbox más pequeño en mobile */
    #tabla-cuotas tbody td:first-child {
        padding: 4px 2px !important;
    }
    
    .rn-custom-checkbox .custom-control-label::before,
    .rn-custom-checkbox .custom-control-label::after {
        width: 16px;
        height: 16px;
    }
}

/* ============================================
   ANIMACIONES SUAVES
   ============================================ */
#tabla-cuotas tbody tr {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   MEJORAS DE ACCESIBILIDAD
   ============================================ */
.dataTables_wrapper .dataTables_length select:focus,
.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_paginate .page-link:focus {
    outline: 2px solid #e53935;
    outline-offset: 2px;
}

/* ============================================
   SCROLLBAR PERSONALIZADA
   ============================================ */
.dataTables_wrapper .dataTables_scrollBody::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.dataTables_wrapper .dataTables_scrollBody::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.dataTables_wrapper .dataTables_scrollBody::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #e53935 0%, #b71c1c 100%);
    border-radius: 10px;
}

.dataTables_wrapper .dataTables_scrollBody::-webkit-scrollbar-thumb:hover {
    background: #e53935;
}
/* ============================================
   CHECKBOXES DESHABILITADOS
   ============================================ */
/* Estilo para checkboxes deshabilitados/bloqueados */
.rn-custom-checkbox input[type="checkbox"]:disabled + .rn-custom-checkbox-label {
    cursor: not-allowed;
    opacity: 0.4;
}

.rn-custom-checkbox input[type="checkbox"]:disabled + .rn-custom-checkbox-label::before {
    background-color: #e0e0e0;
    border-color: #ccc;
    cursor: not-allowed;
}

/* Tooltip para mostrar motivo de bloqueo */
.rn-custom-checkbox[title]:hover {
    position: relative;
}

/* Fila con cuota bloqueada */
tr.cuota-bloqueada {
    background-color: #fafafa !important;
    opacity: 0.7;
}

tr.cuota-bloqueada td {
    color: #999 !important;
}

/* ============================================
   SPINNER DE TOTALES
   ============================================ */
#spinner-totales {
    padding: 10px 0;
    animation: fadeIn 0.3s ease-in;
}

#spinner-totales .spinner-border {
    width: 1.5rem;
    height: 1.5rem;
    border-width: 0.2em;
}

#spinner-totales small {
    font-size: 0.875rem;
    margin-top: 5px;
    color: #666;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ============================================
   CUADRO "PROCESANDO..." DE DATATABLES
   ============================================ */
.dataTables_processing {
    position: fixed !important;
    top: 60% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 400px !important;
    height: auto !important;
    padding: 40px 30px !important;
    margin: 0 !important;
    background: white !important;
    border: 2px solid #e53935 !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3) !important;
    font-size: 20px !important;
    font-weight: 500 !important;
    color: #e53935 !important;
    text-align: center !important;
    z-index: 9999 !important;
}

/* Overlay oscuro detrás del cuadro de procesando */
.dataTables_wrapper.dataTables_processing::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
}
.rn-custom-checkbox-label::after{
    left: -10px;
    top: -11px !important;
}
.rn-custom-checkbox-label::before{
    left: -10px;
    top: -11px !important;
}
