/* Filter row: reuse app theming (let table/card styles apply) */
.table-filters-row {
  background-color: inherit;
}

.table-filter-cell {
  padding: 4px !important;
  vertical-align: middle;
  background-color: inherit;
  width: auto !important;
  position: relative;
  min-width: 0;
}

/* Wrapper para etiquetas + input (comportamiento de "input con chips" inline) */
.tf-filter-wrapper {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  width: 100%;
  gap: 2px;
  padding: 2px 6px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  background-color: #fff;
  cursor: text;
}

.tf-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.tf-chip {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  cursor: default;
}

.tf-chip-label {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tf-chip-remove {
  cursor: pointer;
  font-weight: bold;
}

/* Asegurar que todos los inputs y selects dentro de las celdas ocupen el 100% del ancho */
.table-filter-cell input,
.table-filter-cell select,
.table-filter-cell .form-control {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  margin: 0 !important;
  display: block;
}

.table-column-filter {
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
  flex: 1 1 40px;
  width: auto !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  min-width: 60px;
  border: none !important;
  box-shadow: none !important;
  padding: 2px 0;
  background: transparent;
}

.table-column-filter::placeholder {
  opacity: 0.6;
  font-size: 11px;
}

/* Fixed headers when scrolling - Only applied if enabled */
body.table-filters-sticky-enabled .dataTables_wrapper .dataTables_scrollHead {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: inherit;
}

body.table-filters-sticky-enabled
  .dataTables_wrapper
  .dataTables_scrollHead
  thead {
  position: sticky;
  top: 0;
  z-index: 11;
  background-color: inherit;
}

body.table-filters-sticky-enabled
  .dataTables_wrapper
  .dataTables_scrollHead
  .table-filters-row {
  position: sticky;
  top: 0;
  z-index: 12;
}

/* For tables without scroll, apply sticky directly to thead */
body.table-filters-sticky-enabled .table-responsive {
  max-height: none;
  overflow: visible; /* allow sticky */
}

body.table-filters-sticky-enabled .dataTables_wrapper {
  overflow: visible; /* allow sticky */
}

body.table-filters-sticky-enabled .table-responsive table thead {
  position: sticky;
  top: 0;
  z-index: 20;
  background-color: inherit;
}

body.table-filters-sticky-enabled
  .table-responsive
  table
  thead
  tr:first-child
  th {
  position: sticky;
  top: 0;
  z-index: 21;
  background-color: inherit;
}

body.table-filters-sticky-enabled
  .table-responsive
  table
  thead
  .table-filters-row
  th {
  position: sticky;
  top: var(--tf-header-height, 42px);
  z-index: 22;
  background-color: inherit;
  border: 0px !important;
}

/* Keep app defaults for thead (colors/borders come from theme) */

/* Ensure that the headers have a solid background */
.dataTables_wrapper table thead th {
  position: relative;
}

/* Adjustments for responsive */
@media (max-width: 768px) {
  .table-column-filter {
    font-size: 11px;
    padding: 2px 0;
  }

  .table-filter-cell {
    padding: 2px !important;
  }

  .table-filter-cell input,
  .table-filter-cell select {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* Reglas adicionales para asegurar que los inputs se ajusten al ancho de la columna */
table.dataTable thead .table-filter-cell {
  width: auto !important;
  min-width: 0;
}

table.dataTable thead .table-filter-cell input,
table.dataTable thead .table-filter-cell select {
  width: calc(100% - 0px) !important;
  max-width: 100% !important;
}

/* Style for number inputs */
.table-column-filter[type="number"] {
  text-align: right;
}

/* Ensure that the headers remain visible during scroll */
.dataTables_scrollBody {
  overflow-y: auto;
}

.dataTables_scrollHead {
  overflow: visible !important;
}

/* ============================================
   Floating header for tables with display:block + overflow-x
   Alternative to CSS sticky when table is its own scroll container
   ============================================ */

.tf-floating-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  visibility: hidden;
  z-index: 100;
  pointer-events: auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  background-color: #fff;
}

.tf-floating-inner {
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.tf-floating-inner::-webkit-scrollbar {
  display: none;
}

.tf-floating-inner table {
  display: table;
  table-layout: auto;
  margin: 0;
  border-collapse: collapse;
}
