/* Cambio 064: indicador de carga de las tablas (DataTables) y del cuadro «Procesando…» (waitingDialog).
   Se enlaza despues de @yield('styles') en los layouts con tablas para ganarle al CSS de DataTables que cada vista agrega. */

/* --- Tablas: tarjeta centrada con spinner; la tabla se atenua mientras carga ---
   Los selectores llevan `div.` para igualar la especificidad de dataTables.bootstrap(4).css (div.dataTables_wrapper div.dataTables_processing) y ganar por estar despues. */
div.dataTables_wrapper div.dataTables_processing {
    position: fixed; /* centrada en la ventana (no en la tabla, que puede ser larguisima) */
    top: 50%;
    left: 50%;
    width: auto;
    height: auto;
    margin: 0;
    padding: 14px 22px;
    transform: translate(-50%, -50%);
    z-index: 1040;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .15);
    color: #374151;
    font-size: 15px;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}

/* DataTables lo muestra y oculta con un estilo en linea: solo se pone en flex cuando esta visible */
div.dataTables_wrapper div.dataTables_processing[style*="display: block"] {
    display: flex !important;
    align-items: center;
    gap: 12px;
}

div.dataTables_wrapper div.dataTables_processing::before {
    content: "";
    flex: none;
    width: 22px;
    height: 22px;
    border: 3px solid #dbeafe;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: cargando-giro .8s linear infinite;
}

div.dataTables_wrapper div.dataTables_processing[style*="display: block"] ~ table.dataTable,
div.dataTables_wrapper div.dataTables_processing[style*="display: block"] ~ .dataTables_scroll {
    opacity: .35;
    pointer-events: none;
    transition: opacity .15s;
}

/* --- Cuadro «Procesando la peticion…» de bootstrap-waitingfor (clase modal-m, solo la usa waitingDialog) ---
   Se centra en la ventana: el modal trae un padding-top: 15% en linea que lo dejaba arriba. */
.modal .modal-dialog.modal-m {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 360px; /* con position:absolute el ancho se encogeria a la mitad de la ventana */
    max-width: calc(100vw - 2rem);
    margin: 0;
    transform: translate(-50%, -50%) !important;
}

.modal-dialog.modal-m .modal-content {
    border: 0;
    border-radius: 14px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, .25);
    overflow: hidden;
}

.modal-dialog.modal-m .modal-header {
    border: 0;
    padding: 20px 24px 6px;
}

.modal-dialog.modal-m .modal-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: #374151;
}

.modal-dialog.modal-m .modal-body {
    padding: 8px 24px 22px;
}

.modal-dialog.modal-m .progress {
    height: 6px;
    border-radius: 999px;
    background: #e5e7eb;
}

.modal-dialog.modal-m .progress-bar {
    background: #2563eb;
}

/* --- Indicador global (cargando.js): tarjeta centrada en la pantalla sobre una capa clara que nunca atrapa clics --- */
#cargando-global {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1060;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .5);
    pointer-events: none;
}

#cargando-global .cargando-tarjeta {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 22px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .15);
    color: #374151;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
}

#cargando-global .cargando-spinner {
    flex: none;
    width: 22px;
    height: 22px;
    border: 3px solid #dbeafe;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: cargando-giro .8s linear infinite;
}

@keyframes cargando-giro {
    to { transform: rotate(360deg); }
}

/* quien pide menos movimiento ve el giro lento */
@media (prefers-reduced-motion: reduce) {
    div.dataTables_wrapper div.dataTables_processing::before,
    #cargando-global .cargando-spinner { animation-duration: 2.4s; }
}
