/*
 * TABLES.CSS — Opción B: Clean & Minimal
 * Mobile-first, paleta coherente con sidebar/header
 */

/* ------------------------------------------------- */
/* WRAPPER                                           */
/* ------------------------------------------------- */

.dt-wrapper {
    width: 100%;
    max-width: 100dvw;
    overflow-x: hidden;
}

/* ------------------------------------------------- */
/* TABLA BASE                                        */
/* ------------------------------------------------- */

table.dataTable {
    border-collapse: collapse;
    width: 100%;
    max-width: 100%;
    margin-top: 1em;
    border: none;
    color: var(--text-main);
    font-size: 0.9rem;
}

/* ------------------------------------------------- */
/* THEAD — FILA DE TÍTULOS                           */
/* ------------------------------------------------- */

table.dataTable > thead > tr:first-child > th,
table.dataTable > thead > tr:first-child > td {
    background-color: #111;
    color: var(--color-white);
    padding: 12px 12px 10px;
    border-top: none;
    border-bottom: 1px solid #2a2a2a;
    text-align: left;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    white-space: nowrap;
}

/* ------------------------------------------------- */
/* THEAD — FILA DE FILTROS (tr.filters)              */
/* ------------------------------------------------- */

table.dataTable > thead > tr.filters > th {
    background-color: #f4f5f7;
    padding: 6px 8px;
    border-bottom: 1px solid #e0e0e0;
    border-top: none;
}

table.dataTable > thead > tr.filters > th input[type="text"] {
    width: 100%;
    max-width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid #ccc;
    border-radius: 0;
    padding: 4px 2px;
    font-size: 0.82rem;
    color: var(--text-main);
    outline: none;
    margin: 0;
    transition: border-color 0.2s;
    box-sizing: border-box;
    font-family: inherit;
}

table.dataTable > thead > tr.filters > th input[type="text"]::placeholder {
    color: #aaa;
    font-style: italic;
}

table.dataTable > thead > tr.filters > th input[type="text"]:focus {
    border-bottom: 1.5px solid var(--color-red);
}

.filter-date-range {
    display: flex;
    flex-direction: row;
    gap: 4px;
    align-items: center;
}
.filter-date-range .filter-date-sep {
    color: #aaa;
    font-size: 11px;
    flex-shrink: 0;
}
.filter-date-range input[type="date"] {
    flex: 1;
    min-width: 0;
    max-width: 120px !important;
}

table.dataTable > thead > tr.filters > th input[type="date"] {
    width: 100%;
    max-width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid #ccc;
    border-radius: 0;
    padding: 4px 2px;
    font-size: 0.82rem;
    color: var(--text-main);
    outline: none;
    margin: 0;
    transition: border-color 0.2s;
    box-sizing: border-box;
    font-family: inherit;
}

table.dataTable > thead > tr.filters > th input[type="date"]:focus {
    border-bottom: 1.5px solid var(--color-red);
}

table.dataTable > thead > tr.filters > th select {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid #ccc;
    border-radius: 0;
    padding: 4px 2px;
    font-size: 0.82rem;
    color: var(--text-main);
    outline: none;
    cursor: pointer;
    font-family: inherit;
    box-sizing: border-box;
}

table.dataTable > thead > tr.filters > th select:focus {
    border-bottom: 1.5px solid var(--color-red);
}

/* ------------------------------------------------- */
/* TBODY                                             */
/* ------------------------------------------------- */

table.dataTable > tbody > tr > td {
    padding: 9px 12px;
    border-bottom: 1px solid #ebebeb;
    vertical-align: middle;
    background-color: var(--color-white);
}

/* Sin striping — limpio */
table.dataTable > tbody > tr:nth-child(even) > td,
table.dataTable > tbody > tr:nth-child(odd) > td {
    background-color: var(--color-white);
}

table.dataTable > tbody > tr:hover > td {
    background-color: rgba(0, 0, 0, 0.025);
}

/* ------------------------------------------------- */
/* CELDA DE ACCIONES                                 */
/* ------------------------------------------------- */

table.dataTable > tbody > tr > td.actions {
    vertical-align: middle;
}

table.dataTable > tbody > tr > td.actions .actions-wrap,
td.actions .actions-wrap {
    display: flex;
    gap: 8px;
    align-items: center;
    height: 100%;
}

.actions-divider {
    width: 1px;
    height: 22px;
    background-color: #ddd;
    flex-shrink: 0;
    margin: 0 2px;
}

/* Form dentro de actions-wrap: anula los estilos de form-layout.css */
td.actions .actions-wrap form {
    display: flex;
    align-items: center;
    width: auto;
    max-width: none;
    padding: 0;
    margin: 0;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
}

/* ------------------------------------------------- */
/* CONTROLES DATATABLES (SEARCH + LENGTH)            */
/* ------------------------------------------------- */

div.dt-layout-row div.dt-search input[type="search"],
div.dt-layout-row div.dt-length select {
    border: none;
    border-bottom: 1px solid #ccc;
    border-radius: 0;
    padding: 6px 4px;
    background-color: transparent;
    color: var(--text-main);
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color 0.2s;
    height: auto !important;
}

div.dt-layout-row div.dt-search input[type="search"]:focus,
div.dt-layout-row div.dt-length select:focus {
    border-bottom-color: var(--color-black-noir);
    outline: none;
}

/* ------------------------------------------------- */
/* PAGINACIÓN — Estilo minimal                       */
/* ------------------------------------------------- */

div.dt-layout-row div.dt-paging {
    float: right;
    padding-top: 0.85em;
    margin: 0;
}

div.dt-layout-row div.dt-paging button.dt-paging-button {
    padding: 0.4em 0.7em;
    margin-left: 2px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 4px;
    color: var(--text-main);
    font-size: 0.875rem;
    min-width: 32px;
    text-align: center;
    transition: background 0.15s, color 0.15s;
}

div.dt-layout-row div.dt-paging button.dt-paging-button:not(.current):not(.disabled):hover {
    background-color: rgba(255, 16, 16, 0.07);
    color: var(--color-red);
}

div.dt-layout-row div.dt-paging button.dt-paging-button.current,
div.dt-layout-row div.dt-paging button.dt-paging-button.current:hover {
    background-color: var(--color-black-noir) !important;
    color: var(--color-white) !important;
    border-radius: 4px;
}

div.dt-layout-row div.dt-paging button.dt-paging-button.disabled {
    color: #bbb !important;
    background: transparent;
    cursor: default;
}

/* ------------------------------------------------- */
/* ICONOS DE ORDENACIÓN (SORT)                       */
/* Solo color/opacity — DataTables gestiona content  */
/* y posición para evitar el bug del 3er click       */
/* ------------------------------------------------- */

/* Estado base: ambas flechas visibles pero tenues */
table.dataTable thead > tr > th span.dt-column-order:before,
table.dataTable thead > tr > th span.dt-column-order:after,
table.dataTable thead > tr > td span.dt-column-order:before,
table.dataTable thead > tr > td span.dt-column-order:after {
    color: var(--color-white) !important;
    opacity: 0.3 !important;
    transition: color 0.15s, opacity 0.15s !important;
}

/* Hover: un poco más visible */
table.dataTable thead > tr > th:hover span.dt-column-order:before,
table.dataTable thead > tr > th:hover span.dt-column-order:after,
table.dataTable thead > tr > td:hover span.dt-column-order:before,
table.dataTable thead > tr > td:hover span.dt-column-order:after {
    color: var(--color-white) !important;
    opacity: 0.65 !important;
}

/* Flecha activa ASC: up arrow roja a plena opacidad */
table.dataTable thead > tr > th.dt-ordering-asc span.dt-column-order:before,
table.dataTable thead > tr > td.dt-ordering-asc span.dt-column-order:before {
    color: var(--color-red) !important;
    opacity: 1 !important;
}

/* Flecha activa DESC: down arrow roja a plena opacidad */
table.dataTable thead > tr > th.dt-ordering-desc span.dt-column-order:after,
table.dataTable thead > tr > td.dt-ordering-desc span.dt-column-order:after {
    color: var(--color-red) !important;
    opacity: 1 !important;
}

/* 3er click (sin orden): ambas flechas vuelven al estado base (0.3) — manejado por la regla base */

/* ------------------------------------------------- */
/* RESPONSIVE — Control expandir/colapsar            */
/* ------------------------------------------------- */

table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control {
    white-space: nowrap !important;
    text-align: left !important;
    vertical-align: middle !important;
}

table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control::before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control::before {
    display: inline-block !important;
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    aspect-ratio: 1 !important;
    border-radius: 50% !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    background-color: #111 !important;
    border-top: none !important;
    border-right: none !important;
    border-bottom: none !important;
    border-left: none !important;
    color: var(--color-white) !important;
    content: "+" !important;
    text-align: center !important;
    line-height: 18px !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    box-shadow: none !important;
    vertical-align: middle !important;
    margin-right: 6px !important;
}

table.dataTable.dtr-inline.collapsed > tbody > tr.dtr-expanded > td.dtr-control::before,
table.dataTable.dtr-inline.collapsed > tbody > tr.dtr-expanded > th.dtr-control::before {
    content: "\2212" !important; /* − */
    background-color: var(--color-red) !important;
}

/* ------------------------------------------------- */
/* BOTÓN LIMPIAR FILTROS                             */
/* ------------------------------------------------- */

table.dataTable > thead > tr.filters > th:has(.btn-clear-filters) {
    text-align: center;
    vertical-align: middle;
}

.btn-clear-filters {
    background: transparent;
    border: 1px solid #ccc;
    color: #aaa;
    cursor: pointer;
    padding: 3px 7px;
    font-size: 11px;
    border-radius: 3px;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    font-family: inherit;
    white-space: nowrap;
    line-height: 1.4;
}

.btn-clear-filters:hover {
    color: var(--color-red);
    border-color: var(--color-red);
    background: rgba(255, 16, 16, 0.06);
}

/* ------------------------------------------------- */
/* TRUNCAR COLUMNA PRINCIPAL EN MÓVIL                */
/* Asignar className:'col-principal' en columnDefs   */
/* max-width:0 es el truco estándar para que         */
/* text-overflow funcione en celdas de tabla          */
/* ------------------------------------------------- */

@media (max-width: 600px) {
    table.dataTable td.col-principal {
        max-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* ------------------------------------------------- */
/* TABLE.SHOW (tablas simples sin DataTables)        */
/* ------------------------------------------------- */

table.show {
    text-align: left;
}
