/* Controles DataTables dentro de cards sin padding */
.card-body.p-0 > .dataTables_wrapper,
.table-responsive > .dataTables_wrapper {
    padding: 0.75rem 1rem 1rem;
    max-width: 100%;
    overflow: hidden; /* el scroll vive en .dataTables_scrollBody */
}

/* Contener DataTables al ancho del panel (no expandir la página) */
.dataTables_wrapper {
    max-width: 100%;
}

.card .dataTables_wrapper .dataTables_scroll {
    width: 100% !important;
    max-width: 100%;
    margin: 0;
}

.dataTables_wrapper .dataTables_scrollHead,
.dataTables_wrapper .dataTables_scrollBody {
    width: 100% !important;
}

.dataTables_wrapper .dataTables_scrollBody {
    overflow-x: auto !important;
    overflow-y: visible !important;
}

/* Tablas internas pueden ser más anchas; el body hace scroll */
.dataTables_wrapper .dataTables_scrollBody table.dataTable,
.dataTables_wrapper .dataTables_scrollHead table.dataTable {
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
}

/* Tablas sin scrollX (fallback): pegar al borde de la card */
.card-body.p-0 > .dataTables_wrapper > table.dataTable {
    margin-left: -1rem;
    margin-right: -1rem;
    width: calc(100% + 2rem) !important;
}

/* nowrap en todas las DataTables: evita que columnas se aplasten y habilita scrollX */
.dataTables_wrapper table.dataTable th,
.dataTables_wrapper table.dataTable td {
    white-space: nowrap;
}

table.js-datatable th,
table.js-datatable td {
    white-space: nowrap;
}

.dataTables_wrapper table.dataTable .dt-col-clip {
    max-width: 10rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dataTables_wrapper table.dataTable .dt-col-clip-wide {
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dataTables_wrapper .dt-actions-wrap {
    min-height: 2.5rem;
}

.dataTables_wrapper .dt-actions-wrap .dt-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin: 0;
}

.dataTables_wrapper .dt-actions-wrap .dataTables_filter {
    margin: 0;
}

.dataTables_wrapper .dt-actions-wrap .dataTables_filter label {
    display: flex;
    align-items: center;
    margin: 0;
    gap: 0.35rem;
}

.dataTables_wrapper .dt-buttons .btn {
    margin: 0;
}

/* Botón principal Exportar */
.dataTables_wrapper .dt-buttons .btn-export-dropdown,
.dataTables_wrapper .dt-buttons .buttons-collection.btn-export-dropdown {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-height: 2.5rem;
    padding: 0.55rem 1.15rem !important;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    color: #fff !important;
    background: linear-gradient(180deg, #1a73e8 0%, #1558b0 100%) !important;
    border: 1px solid #1558b0 !important;
    border-radius: 0.5rem !important;
    box-shadow: 0 2px 6px rgba(26, 115, 232, 0.35);
    text-shadow: none;
}

.dataTables_wrapper .dt-buttons .btn-export-dropdown:hover,
.dataTables_wrapper .dt-buttons .btn-export-dropdown:focus,
.dataTables_wrapper .dt-buttons .buttons-collection.btn-export-dropdown:hover {
    color: #fff !important;
    background: linear-gradient(180deg, #1967d2 0%, #124a96 100%) !important;
    box-shadow: 0 3px 10px rgba(26, 115, 232, 0.45);
}

.dataTables_wrapper .dt-buttons .btn-export-dropdown .export-caret {
    font-size: 0.7rem;
    opacity: 0.9;
}

/* Menú desplegable de formatos */
div.dt-button-collection {
    min-width: 220px;
    padding: 0.4rem !important;
    border: 1px solid #e8eaed !important;
    border-radius: 0.65rem !important;
    box-shadow: 0 8px 24px rgba(32, 33, 36, 0.16) !important;
    background: #fff !important;
}

div.dt-button-collection .dt-button,
div.dt-button-collection .btn,
div.dt-button-collection .dt-export-item {
    display: flex !important;
    align-items: center;
    width: 100% !important;
    margin: 0.15rem 0 !important;
    padding: 0.65rem 0.85rem !important;
    border: 0 !important;
    border-radius: 0.45rem !important;
    background: transparent !important;
    color: #202124 !important;
    font-weight: 600 !important;
    font-size: 0.95rem !important;
    text-align: left !important;
    box-shadow: none !important;
}

div.dt-button-collection .dt-button:hover,
div.dt-button-collection .btn:hover,
div.dt-button-collection .dt-export-item:hover {
    background: #e8f0fe !important;
    color: #1a73e8 !important;
}

div.dt-button-collection .bi-filetype-csv { color: #5f6368; }
div.dt-button-collection .bi-file-earmark-excel { color: #1e8e3e; }
div.dt-button-collection .bi-file-earmark-pdf { color: #d93025; }
div.dt-button-collection .dt-button:hover .bi,
div.dt-button-collection .btn:hover .bi {
    opacity: 1;
}

.dataTables_wrapper .dataTables_filter input {
    margin-left: 0.5rem;
}

.dataTables_wrapper table.dataTable {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 0.15rem 0.35rem;
}
