/* ================================================================
   LATIN POS — DataTables Modern & Minimalist UI Styles
   Diseño minimalista, soporte para FixedColumns, ColReorder y ColResize
   ================================================================ */

/* ─── 1. WRAPPER Y CONTROLES SUPERIORES ──────────────────────── */
.dataTables_wrapper {
    font-size: 0.85rem;
    color: #374151; /* gray-700 */
    position: relative;
    clear: both;
}

/* Fila de controles superior (longitud, botones, búsqueda) */
.dataTables_wrapper .margin-bottom-20 {
    margin-bottom: 1rem !important;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.dataTables_wrapper .margin-bottom-20 > div {
    display: flex;
    align-items: center;
    float: none !important;
    width: auto !important;
    padding: 0 !important;
}

/* Selector de cantidad de registros */
.dataTables_wrapper .dataTables_length {
    float: left;
}

.dataTables_wrapper .dataTables_length label {
    font-weight: 500;
    color: #6b7280; /* gray-500 */
    margin-bottom: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.dataTables_wrapper .dataTables_length select {
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.35rem 0.65rem;
    font-size: 0.82rem;
    background-color: #f8fafc;
    color: #1e293b;
    outline: none;
    transition: all 0.2s ease;
    cursor: pointer;
}

.dataTables_wrapper .dataTables_length select:focus {
    border-color: #6366f1;
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Buscador global */
.dataTables_wrapper .dataTables_filter {
    float: right;
    text-align: right;
}

.dataTables_wrapper .dataTables_filter label {
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 0;
    position: relative;
    display: inline-flex;
    align-items: center;
}

.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #e2e8f0;
    border-radius: 9999px;
    padding: 0.38rem 1rem;
    font-size: 0.82rem;
    color: #0f172a;
    background-color: #f8fafc;
    width: 210px;
    transition: all 0.2s ease;
    margin-left: 0.5rem;
}

.dataTables_wrapper .dataTables_filter input:focus {
    outline: none;
    border-color: #6366f1;
    background-color: #ffffff;
    width: 260px;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Botones de acción / exportación */
.dataTables_wrapper .dt-buttons {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

.dataTables_wrapper .dt-buttons .tw-dw-btn-outline,
.dataTables_wrapper .dt-buttons .btn {
    border: 1px solid #e2e8f0 !important;
    background-color: #ffffff !important;
    color: #475569 !important;
    border-radius: 0.5rem !important;
    font-size: 0.78rem !important;
    font-weight: 500 !important;
    padding: 0.35rem 0.75rem !important;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03) !important;
    transition: all 0.15s ease !important;
}

.dataTables_wrapper .dt-buttons .tw-dw-btn-outline:hover,
.dataTables_wrapper .dt-buttons .btn:hover {
    background-color: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
}

/* ─── 2. TABLA — CUERPO Y BORDES MINIMALISTAS ────────────────── */
.dataTables_wrapper,
.dataTables_scroll,
.dataTables_scrollHead,
.dataTables_scrollHeadInner,
.dataTables_scrollBody {
    width: 100% !important;
}

/* Sin !important para no pisar el ancho en píxeles que DataTables calcula con
   scrollX (cabecera clonada y cuerpo). Así las columnas quedan alineadas,
   sobre todo en tablas anchas como Clientes/Proveedores. */
table.dataTable {
    width: 100%;
}

table.dataTable {
    border-collapse: collapse !important;
    border-spacing: 0 !important;
    margin-top: 0.5rem !important;
    margin-bottom: 0.75rem !important;
    border: 1px solid #e2e8f0;
    border-radius: 0.6rem;
    background-color: #ffffff;
}

table.dataTable.no-footer {
    border-bottom: 1px solid #e2e8f0 !important;
}

/* Encabezados principales */
table.dataTable thead tr th,
table.dataTable thead tr td {
    background-color: #f8fafc !important;
    color: #475569 !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    padding: 0.75rem 0.85rem !important;
    box-sizing: border-box !important;
    border-top: none !important;
    border-bottom: 1px solid #e2e8f0 !important;
    border-left: none !important;
    border-right: none !important;
    vertical-align: middle !important;
    white-space: nowrap;
    position: relative;
}

/* Espacio suficiente a la derecha para que los iconos de ordenamiento no se sobrepongan al texto */
table.dataTable thead tr th.sorting,
table.dataTable thead tr th.sorting_asc,
table.dataTable thead tr th.sorting_desc {
    padding-right: 28px !important;
}

/* Iconos de ordenamiento limpios */
table.dataTable thead .sorting,
table.dataTable thead .sorting_asc,
table.dataTable thead .sorting_desc {
    cursor: pointer;
}

table.dataTable thead .sorting:after,
table.dataTable thead .sorting_asc:after,
table.dataTable thead .sorting_desc:after {
    font-size: 0.75rem !important;
    opacity: 0.35 !important;
    position: absolute !important;
    top: 50% !important;
    bottom: auto !important;
    transform: translateY(-50%) !important;
    right: 8px !important;
    line-height: 1 !important;
}

table.dataTable thead .sorting_asc:after,
table.dataTable thead .sorting_desc:after {
    opacity: 1 !important;
    color: #4f46e5 !important;
}

/* Cabecera de calibración en scrollBody (altura 0 pero con métricas horizontales intactas) */
.dataTables_scrollBody > table > thead > tr {
    height: 0 !important;
    line-height: 0 !important;
}

.dataTables_scrollBody > table > thead > tr > th,
.dataTables_scrollBody > table > thead > tr > td {
    height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border-top: none !important;
    border-bottom: none !important;
    line-height: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    background: transparent !important;
    color: transparent !important;
    overflow: hidden !important;
}

.dataTables_scrollBody > table > thead > tr > th > div.dataTables_sizing,
.dataTables_scrollBody > table > thead > tr > td > div.dataTables_sizing {
    height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
}

.dataTables_scrollBody table thead th:after,
.dataTables_scrollBody table thead th:before {
    display: none !important;
    content: "" !important;
}

/* Filas y Celdas */
table.dataTable tbody tr {
    background-color: #ffffff;
    transition: background-color 0.12s ease;
}

table.dataTable tbody tr td {
    padding: 0.65rem 0.85rem !important;
    box-sizing: border-box !important;
    border-top: 1px solid #f1f5f9 !important;
    border-bottom: none !important;
    border-left: none !important;
    border-right: none !important;
    color: #334155;
    font-size: 0.83rem;
    vertical-align: middle !important;
}

table.dataTable.table-striped tbody tr:nth-of-type(odd) {
    background-color: #fcfdfe !important;
}

table.dataTable tbody tr:hover,
table.dataTable.table-striped tbody tr:hover {
    background-color: #f1f5f9 !important; /* Slate muy sutil y limpio */
}

table.dataTable tbody tr.selected {
    background-color: #e0e7ff !important; /* indigo suave */
}

/* ─── 3. FIXEDCOLUMNS — ESTILOS COMPATIBLES ──────────────────── */
div.DTFC_LeftHeadWrapper table,
div.DTFC_RightHeadWrapper table {
    background-color: #f8fafc !important;
    border-right: 2px solid #cbd5e1 !important;
    box-shadow: 4px 0 6px -2px rgba(0, 0, 0, 0.05);
}

div.DTFC_LeftBodyWrapper table,
div.DTFC_RightBodyWrapper table {
    background-color: #ffffff !important;
    border-right: 2px solid #cbd5e1 !important;
    box-shadow: 4px 0 6px -2px rgba(0, 0, 0, 0.05);
}

div.DTFC_LeftBodyWrapper table tbody tr td,
div.DTFC_RightBodyWrapper table tbody tr td {
    background-color: #ffffff !important;
}

div.DTFC_LeftBodyWrapper table tbody tr:hover td,
div.DTFC_RightBodyWrapper table tbody tr:hover td {
    background-color: #f1f5f9 !important;
}

/* ─── 4. COLREORDER (Reordenar columnas) ─────────────────────── */
table.dataTable thead th.ColReorder_move {
    opacity: 0.55;
    background-color: #e0e7ff !important;
    cursor: grabbing !important;
}

table.DTCR_clonedTable.dataTable {
    position: absolute !important;
    background-color: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid #6366f1 !important;
    border-radius: 0.375rem !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1) !important;
    z-index: 202 !important;
}

div.DTCR_pointer {
    width: 2px !important;
    background-color: #4f46e5 !important;
    z-index: 201 !important;
}

/* ─── 5. COLRESIZE (Redimensionar columnas) ─────────────────── */
table.dataTable thead th[data-is-resizable=true] {
    border-inline-end: 1px solid #e2e8f0 !important;
    position: relative;
}

table.dataTable thead th.dt-colresizable-hover {
    cursor: col-resize !important;
    background-color: #ede9fe !important; /* purple-100 */
    border-inline-end: 2px solid #6366f1 !important;
}

table.dataTable thead th.dt-colresizable-bound-min, 
table.dataTable thead th.dt-colresizable-bound-max {
    opacity: 0.4;
    cursor: not-allowed !important;
}

/* ─── 6. PAGINACIÓN Y FOOTER ─────────────────────────────────── */
.dataTables_wrapper .dataTables_info {
    font-size: 0.82rem;
    color: #64748b;
    padding-top: 0.85rem;
    font-weight: 500;
}

.dataTables_wrapper .dataTables_paginate {
    padding-top: 0.6rem;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
}

.dataTables_wrapper .dataTables_paginate ul.pagination {
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

.dataTables_wrapper .dataTables_paginate ul.pagination > li {
    display: inline-flex !important;
    margin: 0 !important;
    padding: 0 !important;
}

.dataTables_wrapper .dataTables_paginate ul.pagination > li > a,
.dataTables_wrapper .dataTables_paginate ul.pagination > li > span,
.dataTables_wrapper .dataTables_paginate .paginate_button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    border: 1px solid #e2e8f0 !important;
    padding: 6px 12px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    color: #475569 !important;
    background-color: #ffffff !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03) !important;
    transition: all 0.15s ease !important;
    cursor: pointer !important;
    min-width: 34px !important;
    height: 34px !important;
    text-align: center !important;
    line-height: 1 !important;
    float: none !important;
    margin: 0 !important;
    text-decoration: none !important;
    user-select: none !important;
}

.dataTables_wrapper .dataTables_paginate ul.pagination > li.previous > a,
.dataTables_wrapper .dataTables_paginate ul.pagination > li.next > a {
    font-weight: 600 !important;
    padding: 6px 14px !important;
}

.dataTables_wrapper .dataTables_paginate ul.pagination > li > a:hover,
.dataTables_wrapper .dataTables_paginate ul.pagination > li > span:hover,
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background-color: #f1f5f9 !important;
    color: #1e293b !important;
    border-color: #cbd5e1 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
}

.dataTables_wrapper .dataTables_paginate ul.pagination > li.active > a,
.dataTables_wrapper .dataTables_paginate ul.pagination > li.active > a:hover,
.dataTables_wrapper .dataTables_paginate ul.pagination > li.active > a:focus,
.dataTables_wrapper .dataTables_paginate ul.pagination > li.active > span,
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: linear-gradient(135deg, #6366f1, #4f46e5) !important;
    color: #ffffff !important;
    border-color: #4f46e5 !important;
    font-weight: 700 !important;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.35) !important;
    cursor: default !important;
    transform: none !important;
}

.dataTables_wrapper .dataTables_paginate ul.pagination > li.disabled > a,
.dataTables_wrapper .dataTables_paginate ul.pagination > li.disabled > a:hover,
.dataTables_wrapper .dataTables_paginate ul.pagination > li.disabled > a:focus,
.dataTables_wrapper .dataTables_paginate ul.pagination > li.disabled > span,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:active {
    color: #94a3b8 !important;
    background-color: #f8fafc !important;
    border-color: #f1f5f9 !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
    transform: none !important;
    opacity: 0.65 !important;
}

/* Indicador de procesamiento / carga */
.dataTables_wrapper .dataTables_processing {
    background: rgba(255, 255, 255, 0.92) !important;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
    color: #4338ca;
    font-weight: 600;
    font-size: 0.88rem;
    padding: 1rem 1.5rem;
    z-index: 100;
}

/* ─── 7. SCROLLBAR MINIMALISTA ────────────────────────────────── */
div.dataTables_scrollBody::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}

div.dataTables_scrollBody::-webkit-scrollbar-track {
    background: #f8fafc;
}

div.dataTables_scrollBody::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 9999px;
}

div.dataTables_scrollBody::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ─── 8. RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .dataTables_wrapper .margin-bottom-20 {
        flex-direction: column;
        align-items: stretch;
    }
    .dataTables_wrapper .dataTables_filter input {
        width: 100%;
        margin-left: 0;
        margin-top: 0.35rem;
    }
    .dataTables_wrapper .dataTables_paginate {
        justify-content: center;
        width: 100%;
    }
}

/* ─── 9. DRAG TO SCROLL (Arrastre con clic en contenedor de items) ─── */
.dataTables_scrollBody,
.table-responsive,
.dataTables_wrapper table.dataTable tbody {
    cursor: grab;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.dataTables_scrollBody.dt-drag-scrolling,
.table-responsive.dt-drag-scrolling,
body.dt-drag-active,
body.dt-drag-active * {
    cursor: grabbing !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}

.dataTables_scrollBody img,
.table-responsive img,
.dataTables_wrapper table.dataTable img {
    -webkit-user-drag: none;
    user-drag: none;
    pointer-events: none;
}

.dataTables_scrollBody input,
.dataTables_scrollBody textarea,
.table-responsive input,
.table-responsive textarea,
.dataTables_wrapper table.dataTable input,
.dataTables_wrapper table.dataTable textarea {
    -webkit-user-select: text !important;
    user-select: text !important;
    cursor: text !important;
}

.dataTables_scrollBody a,
.dataTables_scrollBody button,
.dataTables_scrollBody select,
.dataTables_scrollBody label,
.dataTables_scrollBody .btn,
.dataTables_scrollBody .tw-dw-btn,
.dataTables_scrollBody .dropdown-toggle,
.table-responsive a,
.table-responsive button,
.table-responsive select,
.table-responsive label,
.table-responsive .btn,
.table-responsive .tw-dw-btn {
    cursor: pointer !important;
}

/* ─── 6. CONTROLES RESPONSIVE (MÓVIL) ─────────────────────────── */
@media (max-width: 767.98px) {
    /* Aire interno para que controles y tabla no queden pegados al contenedor. */
    .dataTables_wrapper {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    /* El dom de DataTables usa una .row con márgenes negativos que saca los
       controles del contenedor en pantallas pequeñas. */
    .dataTables_wrapper .row.margin-bottom-20 {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .dataTables_wrapper .row.margin-bottom-20 > div {
        width: 100% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-bottom: 0.75rem;
    }

    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        float: none !important;
        text-align: left !important;
        width: 100% !important;
    }

    .dataTables_wrapper .dataTables_filter label {
        display: flex !important;
        width: 100% !important;
        margin: 0 !important;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        box-sizing: border-box;
    }

    .dataTables_wrapper .dt-buttons {
        justify-content: flex-start;
    }
}

/* Paginación: evitar saltos raros de línea en móvil (DataTables default y Bootstrap) */
@media (max-width: 767.98px) {
    .dataTables_wrapper .dataTables_info {
        text-align: center !important;
        float: none !important;
        width: 100% !important;
        padding: 0 0 8px 0 !important;
        font-size: 12.5px !important;
        font-weight: 500 !important;
        color: #64748b !important;
    }

    .dataTables_wrapper .dataTables_paginate {
        display: flex !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
        float: none !important;
        gap: 0.25rem !important;
        padding-top: 0.4rem !important;
        padding-bottom: 0.6rem !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: thin;
        scrollbar-color: #cbd5e1 transparent;
    }

    .dataTables_wrapper .dataTables_paginate::-webkit-scrollbar {
        height: 4px;
    }

    .dataTables_wrapper .dataTables_paginate::-webkit-scrollbar-track {
        background: transparent;
    }

    .dataTables_wrapper .dataTables_paginate::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 9999px;
    }

    .dataTables_wrapper .dataTables_paginate > span,
    .dataTables_wrapper .dataTables_paginate > div {
        display: flex !important;
        flex-wrap: nowrap !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 0.2rem !important;
    }

    .dataTables_wrapper .dataTables_paginate ul.pagination {
        display: inline-flex !important;
        flex-wrap: nowrap !important;
        justify-content: center !important;
        gap: 4px !important;
        margin: 0 auto !important;
        padding: 2px 4px !important;
    }

    .dataTables_wrapper .dataTables_paginate ul.pagination > li > a,
    .dataTables_wrapper .dataTables_paginate ul.pagination > li > span,
    .dataTables_wrapper .dataTables_paginate .paginate_button {
        margin: 0 !important;
        float: none !important;
        padding: 4px 8px !important;
        min-width: 30px !important;
        height: 30px !important;
        font-size: 12px !important;
        border-radius: 7px !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }

    .dataTables_wrapper .dataTables_paginate ul.pagination > li.previous > a,
    .dataTables_wrapper .dataTables_paginate ul.pagination > li.next > a {
        padding: 4px 10px !important;
        font-size: 11.5px !important;
    }
}
