/*
 * Apariencia global de DataTables para SGO Plus.
 * Mantiene la integración funcional de DataTables con Bootstrap 5.
 */

div.dt-container {
    color: var(--sgo-color-texto, #172033);
}

div.dt-container .dt-layout-row {
    align-items: center;
    margin: 0 0 1rem;
    row-gap: 0.75rem;
}

div.dt-container .dt-layout-row:last-child {
    margin: 1rem 0 0;
}

div.dt-container .dt-length label,
div.dt-container .dt-search label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    color: #4b5563;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

div.dt-container .dt-search {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.65rem;
}

div.dt-container .dt-length select.form-select,
div.dt-container .dt-search input.form-control {
    min-height: 2.25rem;
    margin: 0;
    color: #374151;
    font-size: 0.75rem;
    background-color: #fff;
    border-color: #d1d5db;
    border-radius: 0.5rem;
    box-shadow: none;
}

div.dt-container .dt-length select.form-select {
    width: auto;
    min-width: 4.5rem;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
}

div.dt-container .dt-search input.form-control {
    width: 16rem;
    padding: 0.4rem 0.75rem;
}

/* Hasta 992 px el buscador comparte fila con el largo de página: se ajusta en lugar de estorbar. */
@media (max-width: 991.98px) {
    div.dt-container .dt-search input.form-control {
        width: auto;
        min-width: 0;
        flex: 1 1 auto;
    }
}

div.dt-container .dt-length select.form-select:focus,
div.dt-container .dt-search input.form-control:focus {
    border-color: var(--app-primary, #4f46e5);
    box-shadow: 0 0 0 0.2rem rgba(82, 101, 122, 0.12);
}

div.dt-container table.dataTable {
    width: 100% !important;
    margin: 0 !important;
    border-color: #e5e7eb;
}

div.dt-container table.dataTable thead > tr > th,
div.dt-container table.dataTable thead > tr > td {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    color: #374151;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.025em;
    background: #f8fafc;
    border-bottom: 1px solid #dfe3e8;
    box-shadow: none;
}

/* DataTables invierte el orden en columnas numéricas y deja la flecha a la izquierda.
 * La interfaz usa una sola convención: el indicador de orden siempre al extremo derecho.
 */
div.dt-container table.dataTable thead > tr > th div.dt-column-header,
div.dt-container table.dataTable thead > tr > td div.dt-column-header {
    flex-direction: row !important;
}

div.dt-container table.dataTable thead > tr > th .dt-column-order,
div.dt-container table.dataTable thead > tr > td .dt-column-order {
    flex: 0 0 auto;
    margin-left: auto;
}

div.dt-container table.dataTable tbody > tr > th,
div.dt-container table.dataTable tbody > tr > td {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    color: #374151;
    font-size: 0.75rem;
    vertical-align: middle;
    background-color: #fff;
    border-bottom-color: #edf0f3;
}

div.dt-container table.dataTable.table-hover > tbody > tr:hover > * {
    --bs-table-bg-state: #f8fafc;
    color: #172033;
}

div.dt-container table.dataTable tbody tr:last-child > * {
    border-bottom-width: 0;
}

div.dt-container table.dataTable td.dt-empty {
    padding: 2.5rem 1rem;
    color: #6b7280;
    text-align: center;
}

div.dt-container .dt-info {
    padding-top: 0;
    color: #6b7280;
    font-size: 0.72rem;
}

div.dt-container .pagination {
    flex-wrap: wrap;
    justify-content: flex-end;
    margin: 0;
    gap: 0.25rem;
}

div.dt-container .pagination .page-link {
    display: inline-flex;
    min-width: 2rem;
    min-height: 2rem;
    align-items: center;
    justify-content: center;
    padding: 0.3rem 0.6rem;
    color: #4b5563;
    font-size: 0.78rem;
    line-height: 1;
    background: #fff;
    border: 1px solid #dfe3e8;
    border-radius: 0.45rem !important;
    box-shadow: none;
}

div.dt-container .pagination .page-link:hover {
    color: var(--app-primary, #4f46e5);
    background: #f1f4f7;
    border-color: #cbd5de;
}

div.dt-container .pagination .page-link:focus-visible {
    outline: 0;
    border-color: var(--app-primary, #4f46e5);
    box-shadow: 0 0 0 0.2rem rgba(82, 101, 122, 0.12);
}

div.dt-container .pagination .page-item.active .page-link {
    color: #fff;
    background: var(--app-primary, #4f46e5);
    border-color: var(--app-primary, #4f46e5);
}

div.dt-container .pagination .page-item.disabled .page-link {
    color: #9ca3af;
    background: #f8fafc;
    border-color: #e5e7eb;
    opacity: 0.8;
}

div.dt-container .dt-processing {
    padding: 0.75rem 1rem;
    color: #374151;
    font-size: 0.8125rem;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid #e5e7eb;
    border-radius: 0.6rem;
    box-shadow: 0 0.5rem 1rem rgba(15, 23, 42, 0.08);
}

@media (max-width: 767.98px) {
    div.dt-container .dt-layout-row {
        margin-bottom: 0.85rem;
    }

    div.dt-container .dt-layout-cell,
    div.dt-container .dt-length,
    div.dt-container .dt-search {
        width: 100%;
    }

    div.dt-container .dt-length label {
        width: 100%;
        justify-content: space-between;
    }

    div.dt-container .dt-search {
        justify-content: flex-start;
    }

    div.dt-container .dt-search label {
        width: auto;
        flex: 0 0 auto;
    }

    div.dt-container .dt-search input.form-control {
        width: auto;
        min-width: 0;
        flex: 1 1 auto;
    }

    div.dt-container .dt-info {
        text-align: center;
    }

    div.dt-container .pagination {
        justify-content: center;
    }
}

@media (max-width: 575.98px) {
    /* Los números de página se tocan con el dedo: mínimo cómodo en lugar de 29 px. */
    div.dt-container .pagination .page-link {
        min-width: 2.5rem;
        min-height: 2.5rem;
        padding-inline: 0.6rem;
    }
}

/*
 * Acciones dentro de la fila desplegable (el «+» del complemento adaptable).
 *
 * Esa fila es UNA sola celda que abarca todas las columnas, así que mide lo que mida la tabla; y en
 * pantallas de hasta 991.98 px la tabla de datos conserva un mínimo de 52rem (ver la regla de
 * .table-responsive table[data-tabla] en sistema-visual.css). El grupo de acciones, que en su
 * columna va pegado al extremo derecho, quedaría entonces al final de una celda de 832 px: en un
 * móvil de 393-480 px cae fuera de la parte visible, con el título «Acciones» y un hueco vacío
 * debajo, y hay que desplazar la tabla a lo ancho para encontrarlo.
 *
 * En la fila desplegable no hay columna que ensuciar, así que los botones se alinean al principio,
 * junto a su título, y se ven sin desplazar nada. Dentro de la tabla no cambia nada: ahí el grupo
 * sigue alineado a la derecha (ver la regla de .acciones-tabla en sistema-visual.css).
 */
table.dataTable > tbody > tr.child .acciones-tabla {
    justify-content: flex-start;
    margin-left: 0;
    flex-wrap: wrap;
}
