/* ============================================================
 *  DIBAL UIX v1.0 – DataTables + Bootstrap4 + Responsive + FixedHeader
 * ============================================================ */

/* ===========================
 *  CONTROLES SUPERIORES (length, filter)
 * =========================== */

.dibal-theme div.dataTables_wrapper div.dataTables_length label {
    font-weight: 500;
    color: var(--dibal-gray-700);
    font-size: .85rem;
}

.dibal-theme div.dataTables_wrapper div.dataTables_length select {
    display: inline-block;
    width: auto;
    border-radius: var(--dibal-radius-pill);
    border: 1px solid var(--dibal-gray-300);
    font-size: .85rem;
    padding: .2rem .6rem;
}

/* Buscador */
.dibal-theme div.dataTables_wrapper div.dataTables_filter {
    text-align: right;
}

.dibal-theme div.dataTables_wrapper div.dataTables_filter label {
    font-weight: 500;
    color: var(--dibal-gray-700);
    white-space: nowrap;
    font-size: .85rem;
}

.dibal-theme div.dataTables_wrapper div.dataTables_filter input {
    margin-left: .5em;
    display: inline-block;
    width: auto;
    border-radius: var(--dibal-radius-pill);
    border: 1px solid var(--dibal-gray-300);
    padding: .25rem .8rem;
    font-size: .85rem;
    outline: none !important;
}

.dibal-theme div.dataTables_wrapper div.dataTables_filter input:focus {
    border-color: var(--dibal-primary);
}

/* Info + paginación */
.dibal-theme div.dataTables_wrapper div.dataTables_info {
    padding-top: .7rem;
    font-size: .8rem;
    color: var(--dibal-gray-500);
}

.dibal-theme div.dataTables_wrapper div.dataTables_paginate {
    margin: 0;
    text-align: right;
}

/* ===========================
 *  TABLA
 * =========================== */

.dibal-theme table.dataTable {
    margin-top: 6px !important;
    margin-bottom: 6px !important;
    border-collapse: separate !important;
    border-spacing: 0;
}

/* Cabecera */
.dibal-theme table.dataTable > thead > tr > th {
    background-color: var(--dibal-gray-100);
    color: var(--dibal-gray-700);
    font-weight: 600;
    border-bottom: 1px solid var(--dibal-gray-300);
    font-size: .85rem;
}

/* Hover filas */
.dibal-theme table.dataTable tbody tr:hover {
    background-color: var(--dibal-gray-100);
}

/* Celdas */
.dibal-theme table.dataTable td,
.dibal-theme table.dataTable th {
    font-size: .85rem;
}

/* Empty */
.dibal-theme table.dataTable td.dataTables_empty,
.dibal-theme table.dataTable th.dataTables_empty {
    text-align: center;
    color: var(--dibal-gray-500);
}

/* ===========================
 *  ORDENAMIENTO (iconos ↑↓)
 * =========================== */

.dibal-theme table.dataTable > thead .sorting,
.dibal-theme table.dataTable > thead .sorting_asc,
.dibal-theme table.dataTable > thead .sorting_desc,
.dibal-theme table.dataTable > thead .sorting_asc_disabled,
.dibal-theme table.dataTable > thead .sorting_desc_disabled {
    cursor: pointer;
    position: relative;
}

.dibal-theme table.dataTable > thead .sorting:before,
.dibal-theme table.dataTable > thead .sorting:after,
.dibal-theme table.dataTable > thead .sorting_asc:before,
.dibal-theme table.dataTable > thead .sorting_asc:after,
.dibal-theme table.dataTable > thead .sorting_desc:before,
.dibal-theme table.dataTable > thead .sorting_desc:after,
.dibal-theme table.dataTable > thead .sorting_asc_disabled:before,
.dibal-theme table.dataTable > thead .sorting_asc_disabled:after,
.dibal-theme table.dataTable > thead .sorting_desc_disabled:before,
.dibal-theme table.dataTable > thead .sorting_desc_disabled:after {
    opacity: .35;
    color: var(--dibal-gray-500);
}

.dibal-theme table.dataTable > thead .sorting_asc:before,
.dibal-theme table.dataTable > thead .sorting_desc:after {
    opacity: 1;
    color: var(--dibal-primary-dark);
}

/* ===========================
 *  PAGINACIÓN (Bootstrap pagination)
 * =========================== */

.dibal-theme div.dataTables_wrapper div.dataTables_paginate ul.pagination {
    margin: .15rem 0;
    justify-content: flex-end;
}

/* Botones */
.dibal-theme .dataTables_wrapper .dataTables_paginate .paginate_button.page-item .page-link {
    border-radius: var(--dibal-radius-pill);
    border: 1px solid transparent;
    padding: .3rem .7rem;
    font-size: .8rem;
    color: var(--dibal-gray-700);
}

.dibal-theme .dataTables_wrapper .dataTables_paginate .page-item.active .page-link,
.dibal-theme .dataTables_wrapper .dataTables_paginate .page-item .page-link:hover {
    background-color: var(--dibal-primary);
    border-color: var(--dibal-primary);
    color: #ffffff;
}

/* Disabled */
.dibal-theme .dataTables_wrapper .dataTables_paginate .page-item.disabled .page-link {
    color: var(--dibal-gray-400);
    border-color: transparent;
    background-color: transparent;
}

/* ===========================
 *  PROCESSING (spiner “Procesando”)
 * =========================== */

.dibal-theme div.dataTables_wrapper div.dataTables_processing {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 220px;
    margin-left: -110px;
    margin-top: -26px;
    padding: .6rem .5rem;
    text-align: center;
    border-radius: var(--dibal-radius-base);
    background: rgba(255,255,255,.95);
    box-shadow: 0 10px 25px rgba(15,23,42,.12);
    color: var(--dibal-gray-700);
    font-size: .85rem;
}

.dibal-theme .dibal-dt-processing i {
    margin-right: .35rem;
    color: var(--dibal-primary);
}

/* ===========================
 *  FIXED HEADER
 * =========================== */

.dibal-theme table.dataTable.fixedHeader-floating,
.dibal-theme table.dataTable.fixedHeader-locked {
    background-color: #ffffff;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.dibal-theme table.dataTable.fixedHeader-floating > thead > tr > th,
.dibal-theme table.dataTable.fixedHeader-locked > thead > tr > th {
    background-color: var(--dibal-gray-100);
    border-bottom: 1px solid var(--dibal-gray-300);
}

/* ===========================
 *  RESPONSIVE (dtr-control + modal)
 * =========================== */

/* Botón “+” en filas responsive (dtr-inline) */
.dibal-theme table.dataTable.dtr-inline.collapsed > tbody > tr[role="row"] > td.dtr-control:before,
.dibal-theme table.dataTable.dtr-inline.collapsed > tbody > tr[role="row"] > th.dtr-control:before {
    background-color: var(--dibal-primary);
    border: 2px solid #ffffff;
    box-shadow: 0 0 3px rgba(15,23,42,.45);
}

/* Cuando está abierto (parent) → color de peligro */
.dibal-theme table.dataTable.dtr-inline.collapsed > tbody > tr.parent > td.dtr-control:before,
.dibal-theme table.dataTable.dtr-inline.collapsed > tbody > tr.parent > th.dtr-control:before {
    background-color: #ef4444;
}

/* Variante dtr-column (icono centrado en la columna) */
.dibal-theme table.dataTable.dtr-column > tbody > tr > td.control:before,
.dibal-theme table.dataTable.dtr-column > tbody > tr > th.control:before {
    background-color: var(--dibal-primary);
    border: 2px solid #ffffff;
    box-shadow: 0 0 3px rgba(15,23,42,.45);
}

.dibal-theme table.dataTable.dtr-column > tbody > tr.parent td.control:before,
.dibal-theme table.dataTable.dtr-column > tbody > tr.parent th.control:before {
    background-color: #ef4444;
}

/* Filas hijas (detalle) */
.dibal-theme table.dataTable > tbody > tr.child {
    padding: .35rem .75rem;
    background: #f9fafb;
}

.dibal-theme table.dataTable > tbody > tr.child ul.dtr-details > li {
    border-bottom: 1px solid #e5e7eb;
    padding: .35rem 0;
    font-size: .8rem;
}

.dibal-theme table.dataTable > tbody > tr.child span.dtr-title {
    min-width: 90px;
    font-weight: 600;
    color: var(--dibal-gray-700);
}

/* Modal responsive “Detalles” */
.dibal-theme div.dtr-modal div.dtr-modal-display {
    background-color: #f9fafb;
    border-radius: .75rem;
    border: 1px solid rgba(15,23,42,.12);
    box-shadow: 0 12px 30px rgba(15,23,42,.45);
}

.dibal-theme div.dtr-modal div.dtr-modal-content {
    padding: 1rem;
    font-size: .85rem;
    color: var(--dibal-gray-800);
}

/* Botón cerrar del modal responsive */
.dibal-theme div.dtr-modal div.dtr-modal-close {
    border-radius: var(--dibal-radius-pill);
    border: 1px solid #e5e7eb;
    background-color: #ffffff;
}

.dibal-theme div.dtr-modal div.dtr-modal-close:hover {
    background-color: var(--dibal-primary-light);
}

/* ===========================
 *  RESPONSIVE – AJUSTES MOBILE
 * =========================== */

@media screen and (max-width: 767.98px) {
    .dibal-theme div.dataTables_wrapper div.dataTables_length,
    .dibal-theme div.dataTables_wrapper div.dataTables_filter,
    .dibal-theme div.dataTables_wrapper div.dataTables_info,
    .dibal-theme div.dataTables_wrapper div.dataTables_paginate {
        text-align: center;
    }

    .dibal-theme div.dataTables_wrapper div.dataTables_paginate ul.pagination {
        justify-content: center !important;
    }
}
