/* High-specificity DataTables contrast overrides
   Ensures table body text is readable against dark theme backgrounds.
   Light text on dark backgrounds (dark mode).
   Dark text on light backgrounds (light mode).
*/

/* FIRST: Light mode rules that check actual background colors (not dependent on body class) */
#datatable-container table.dataTable tbody td,
#datatable-container .dataTables_wrapper table.dataTable tbody td,
.ots-table-card table.dataTable tbody td,
.ots-table-card table.dataTable tbody td * {
  color: var(--color-text-primary) !important;
  opacity: 1 !important;
}

#datatable-container table.dataTable thead th,
.ots-table-card table.dataTable thead th,
#datatable-container table.dataTable thead th * {
  color: var(--color-text-secondary) !important;
  opacity: 1 !important;
  background-color: var(--color-surface) !important;
}

#datatable-container table.dataTable tbody tr.table-success td,
#datatable-container table.dataTable tbody tr.success td,
#datatable-container table.dataTable tbody tr.selected td,
#datatable-container table.dataTable tbody tr.highlight td {
  background-color: rgba(16, 185, 129, 0.1) !important;
  color: var(--color-text-primary) !important;
}

#datatable-container table.dataTable tbody td .btn,
#datatable-container table.dataTable tbody td .badge,
#datatable-container table.dataTable tbody td .dropdown-toggle {
  color: var(--color-text-primary) !important;
}

#datatable-container table.dataTable tbody tr {
  background-color: transparent !important;
}

#datatable-container table.dataTable tbody tr:nth-child(even) {
  background-color: var(--color-surface-elevated) !important;
}

#datatable-container table.dataTable tbody tr:hover {
  background-color: rgba(37, 99, 235, 0.06) !important;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_paginate .paginate_button {
  color: var(--color-text-primary) !important;
  background: var(--color-surface) !important;
  border-color: var(--color-border) !important;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_paginate {
  color: var(--color-text-primary) !important;
}

/* SECOND: Explicit light mode class overrides for when .ots-light-mode is present */
body.ots-light-mode #datatable-container table.dataTable tbody td,
body.ots-light-mode #datatable-container .dataTables_wrapper table.dataTable tbody td,
body.ots-light-mode .ots-table-card table.dataTable tbody td,
body.ots-light-mode .ots-table-card table.dataTable tbody td * {
  color: #0f172a !important;
  opacity: 1 !important;
}

body.ots-light-mode #datatable-container table.dataTable thead th,
body.ots-light-mode .ots-table-card table.dataTable thead th,
body.ots-light-mode #datatable-container table.dataTable thead th * {
  color: #334155 !important;
  opacity: 1 !important;
  background-color: #f1f5f9 !important;
}

body.ots-light-mode #datatable-container table.dataTable tbody tr.table-success td,
body.ots-light-mode #datatable-container table.dataTable tbody tr.success td,
body.ots-light-mode #datatable-container table.dataTable tbody tr.selected td,
body.ots-light-mode #datatable-container table.dataTable tbody tr.highlight td {
  background-color: rgba(16, 185, 129, 0.1) !important;
  color: #0f172a !important;
}

body.ots-light-mode #datatable-container table.dataTable tbody td .btn,
body.ots-light-mode #datatable-container table.dataTable tbody td .badge,
body.ots-light-mode #datatable-container table.dataTable tbody td .dropdown-toggle {
  color: #0f172a !important;
}

body.ots-light-mode #datatable-container table.dataTable tbody tr {
  background-color: transparent !important;
}

body.ots-light-mode #datatable-container table.dataTable tbody tr:nth-child(even) {
  background-color: #f1f5f9 !important;
}

body.ots-light-mode #datatable-container table.dataTable tbody tr:hover {
  background-color: rgba(37, 99, 235, 0.06) !important;
}

body.ots-light-mode .dataTables_wrapper .dataTables_filter input,
body.ots-light-mode .dataTables_wrapper .dataTables_length select,
body.ots-light-mode .dataTables_wrapper .dataTables_paginate .paginate_button {
  color: #0f172a !important;
  background: #ffffff !important;
  border-color: #e2e8f0 !important;
}

body.ots-light-mode .dataTables_wrapper .dataTables_info,
body.ots-light-mode .dataTables_wrapper .dataTables_filter,
body.ots-light-mode .dataTables_wrapper .dataTables_length,
body.ots-light-mode .dataTables_wrapper .dataTables_paginate {
  color: #0f172a !important;
}

#datatable-container table.dataTable tbody td img,
#datatable-container table.dataTable tbody td svg {
  filter: none !important;
}

#datatable-container table.dataTable thead th.sorting:after,
#datatable-container table.dataTable thead th.sorting_asc:after,
#datatable-container table.dataTable thead th.sorting_desc:after {
  color: rgba(255,255,255,0.7) !important;
}

.ots-table-card table.dataTable tbody tr td,
.ots-table-card table.dataTable tbody tr td * {
  -webkit-text-fill-color: var(--color-text-primary) !important;
}

