/**
 * DataTables + Bootstrap 5 integration aligned to app design tokens.
 * Loaded globally from _Layout so all list pages pick up the same shell.
 */

.app-shell .dataTables_wrapper {
  font-size: var(--text-sm);
  color: hsl(var(--foreground));
  margin-bottom: var(--space-4);
  max-width: 100%;
  overflow-x: visible;
}

.app-shell .dataTables_wrapper .dataTables_scrollBody {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.app-shell .dataTables_wrapper .dataTables_length,
.app-shell .dataTables_wrapper .dataTables_filter,
.app-shell .dataTables_wrapper .dataTables_info,
.app-shell .dataTables_wrapper .dataTables_processing {
  padding: var(--space-2) 0;
  color: hsl(var(--muted-foreground));
}

.app-shell .dataTables_wrapper .dataTables_length label,
.app-shell .dataTables_wrapper .dataTables_filter label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 0;
  font-weight: 500;
}

.app-shell div.dataTables_wrapper div.dataTables_filter input {
  margin-left: 0.5em;
  border-radius: var(--radius-md);
  border: 1px solid hsl(var(--input));
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  padding: 0.35rem 0.65rem;
  font-size: var(--text-sm);
}

.app-shell div.dataTables_wrapper div.dataTables_filter input:focus {
  border-color: var(--color-primary-400);
  box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--color-primary-400) 22%, transparent);
  outline: none;
}

.app-shell div.dataTables_wrapper div.dataTables_length select {
  border-radius: var(--radius-md);
  border: 1px solid hsl(var(--input));
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  padding: 0.35rem 2rem 0.35rem 0.65rem;
  font-size: var(--text-sm);
}

.app-shell table.dataTable {
  width: 100% !important;
  margin-top: var(--space-2) !important;
  margin-bottom: var(--space-2) !important;
  border-collapse: separate !important;
  border-spacing: 0;
}

.app-shell table.dataTable thead th,
.app-shell table.dataTable thead td {
  background-color: hsl(var(--muted) / 0.45);
  color: hsl(var(--foreground));
  border-bottom: 1px solid hsl(var(--border));
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.65rem 0.75rem;
  vertical-align: middle;
}

.app-shell table.dataTable tbody th,
.app-shell table.dataTable tbody td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid hsl(var(--border));
  vertical-align: middle;
  background-color: hsl(var(--card));
  color: hsl(var(--card-foreground));
}

.app-shell table.dataTable.table-striped > tbody > tr.odd > * {
  box-shadow: inset 0 0 0 9999px hsl(var(--muted) / 0.22);
}

.app-shell table.dataTable.table-hover > tbody > tr:hover > * {
  box-shadow: inset 0 0 0 9999px hsl(var(--accent) / 0.35);
}

.app-shell table.dataTable.stripe tbody tr.odd,
.app-shell table.dataTable.display tbody tr.odd {
  background-color: hsl(var(--muted) / 0.12);
}

.app-shell table.dataTable.hover tbody tr:hover,
.app-shell table.dataTable.display tbody tr:hover {
  background-color: hsl(var(--accent) / 0.25);
}

.app-shell .dataTables_wrapper .dataTables_paginate {
  margin-top: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px solid hsl(var(--border));
}

.app-shell .dataTables_wrapper .dataTables_paginate .pagination {
  margin-bottom: 0;
  gap: 0.15rem;
}

.app-shell .dataTables_wrapper .dataTables_paginate .page-link {
  color: hsl(var(--primary));
  background-color: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm) !important;
  padding: 0.35rem 0.65rem;
  font-size: var(--text-sm);
  margin: 0;
}

.app-shell .dataTables_wrapper .dataTables_paginate .page-item.active .page-link {
  color: hsl(var(--primary-foreground));
  background-color: hsl(var(--primary));
  border-color: hsl(var(--primary));
}

.app-shell .dataTables_wrapper .dataTables_paginate .page-item.disabled .page-link {
  color: hsl(var(--muted-foreground));
  background-color: hsl(var(--muted));
  border-color: hsl(var(--border));
  opacity: 0.75;
}

.app-shell .dataTables_wrapper .dataTables_paginate .page-link:hover:not(.disabled) {
  background-color: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  border-color: hsl(var(--border));
}

.app-shell .dataTables_wrapper .dataTables_info {
  padding-top: var(--space-3);
  font-size: var(--text-xs);
}

.app-shell .dt-buttons {
  margin-bottom: var(--space-2);
}

.app-shell .dt-buttons .btn,
.app-shell .dt-button {
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}

.app-shell table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before,
.app-shell table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control:before {
  color: hsl(var(--primary));
  border-color: hsl(var(--border));
}

/* Responsive extension: child detail rows */
.app-shell table.dataTable > tbody > tr.child ul.dtr-details {
  margin: 0;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: hsl(var(--foreground));
}

.app-shell table.dataTable > tbody > tr.child ul.dtr-details li {
  border-bottom: 1px solid hsl(var(--border));
  padding: var(--space-2) 0;
}

.app-shell table.dataTable > tbody > tr.child span.dtr-title {
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  min-width: 30%;
  display: inline-block;
  vertical-align: top;
}

@media (max-width: 480px) {
  .app-shell .dataTables_wrapper .dataTables_paginate .pagination {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem;
  }

  .app-shell .dataTables_wrapper .dataTables_length,
  .app-shell .dataTables_wrapper .dataTables_filter {
    width: 100%;
  }

  .app-shell .dataTables_wrapper .dataTables_filter label {
    flex-direction: column;
    align-items: stretch;
  }

  .app-shell div.dataTables_wrapper div.dataTables_filter input {
    margin-left: 0;
    margin-top: var(--space-2);
    width: 100%;
  }
}
