/**
 * Base data table styles.
 * Shared by display-only tables and Simple-DataTables controls.
 */

.data-table-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--card-bg);
  /* Generic prose spacing (blockquote/p/table/ul/... margin-bottom) targets
     the raw <table> element. Once this wrap clips overflow it forms a new
     block-formatting context, so that margin no longer collapses outward -
     it shows up as visible empty space inside the rounded corners instead.
     Move the spacing to the wrap and zero it on the table below. */
  margin-bottom: 40px;
}

/* Global: whenever anything precedes the table (per-page dropdown, search
   field, filter bar, section heading) keep it clearly off the table head.
   Page-level control rows should not have to add this themselves. */
.data-table-wrap:not(:first-child),
table.data-table:not(:first-child),
table.sdt-table:not(:first-child) {
  margin-top: 16px;
}

.data-table,
.sdt-table {
  width: 100%;
  min-width: 480px;
  margin: 0;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: 15px;
}

.data-table thead,
.sdt-table thead {
  /* Same brand-tinted formula as the zebra row (see below), one step
     stronger, so header/zebra-row/hover are three distinct shades and never
     coincide. */
  background: color-mix(in srgb, var(--primary-blue) 10%, var(--card-bg));
}

.data-table thead th,
.sdt-table thead th {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: normal;
  color: var(--muted-text);
  padding: 14px 16px;
  border-bottom: 1px solid
    color-mix(in srgb, var(--primary-blue) 22%, var(--border-color));
  text-align: center;
  white-space: nowrap;
  position: relative;
  user-select: none;
}

.dt-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.data-table thead th:first-child,
.sdt-table thead th:first-child {
  padding-left: 20px;
}

.data-table thead th:last-child,
.sdt-table thead th:last-child {
  padding-right: 20px;
}

/* Light column separators. */
.data-table thead th:not(:last-child),
.sdt-table thead th:not(:last-child),
.data-table tbody td:not(:last-child),
.sdt-table tbody td:not(:last-child) {
  border-right: 1px solid
    color-mix(in srgb, var(--border-color) 80%, transparent);
}

.data-table tbody td,
.sdt-table tbody td {
  padding: 14px 16px;
  border-bottom: none;
  vertical-align: middle;
  color: var(--text-color);
  transition: background-color 0.15s ease;
}

.data-table tbody tr:nth-child(even),
.sdt-table tbody tr:nth-child(even) {
  /* Brand-tinted zebra stripe, lighter than the header. Neither
     --info-item-bg (a semantic, always-blue token) nor --border-color (some
     projects override this with their own neutral chrome color, unrelated
     to brand - e.g. a cool gray on a warm-branded site) reliably reflect the
     project's actual accent, so mix --primary-blue itself into --card-bg. */
  background: color-mix(in srgb, var(--primary-blue) 5%, var(--card-bg));
}

.data-table tbody tr:hover td,
.sdt-table tbody tr:hover td {
  /* Strongest of the three tints, so hover is always visibly distinct from
     both the header and the zebra row. */
  background: color-mix(in srgb, var(--primary-blue) 14%, var(--card-bg));
}

.data-table thead th:first-child,
.sdt-table thead th:first-child,
.data-table tbody td:first-child,
.sdt-table tbody td:first-child {
  padding-left: 20px;
}

.data-table thead th:last-child,
.sdt-table thead th:last-child,
.data-table tbody td:last-child,
.sdt-table tbody td:last-child {
  padding-right: 20px;
}

/* Data-cell alignment only - header cells always stay centered (see
   ".data-table thead th" above), regardless of a table's alignment class. */
.data-table-align-left tbody td {
  text-align: left;
}

.data-table-align-center tbody td {
  text-align: center;
}

.data-table-align-right tbody td {
  text-align: right;
}

.data-table-cell-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-color);
}

.data-table-cell-muted {
  font-size: 14px;
  color: var(--muted-text);
}

.data-table-cell-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.data-table-cell-image {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.data-table-cell-image img {
  width: 32px;
  height: 32px;
  object-fit: cover;
  flex-shrink: 0;
}

.data-table-empty td,
.data-table-loading td {
  text-align: center;
  padding: 32px 20px;
  color: var(--muted-text);
  font-size: 15px;
}

.data-table-empty td .data-table-empty-icon,
.data-table-loading td .data-table-loading-icon {
  display: block;
  font-size: 28px;
  margin-bottom: 8px;
  opacity: 0.6;
}

.data-table-section {
  margin-bottom: 24px;
}

.data-table-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  color: var(--heading-color);
  margin: 0 0 16px 0;
}

.data-table-section-title .fa,
.data-table-section-title .fas {
  color: var(--primary-blue);
  font-size: 20px;
}

/* Simple-DataTables layout controls */
.sdt-wrapper .dt-layout-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 16px 20px;
  gap: 12px;
  flex-wrap: wrap;
}

/* Top controls (per-page + search) sit above the head - keep them clearly
   separated from it. */
.sdt-wrapper .dt-layout-row:first-child {
  padding-bottom: 18px;
}

.sdt-wrapper .dt-layout-row:first-child + .data-table-wrap,
.sdt-wrapper .dt-layout-row:first-child + table,
.sdt-wrapper > table,
.sdt-wrapper .data-table-wrap {
  margin-top: 4px;
}

/* Bottom row (info + pagination) gets a divider and matching room. */
.sdt-wrapper .sdt-controls {
  margin-top: 4px;
  padding-top: 18px;
  border-top: 1px solid var(--border-color);
}

.sdt-wrapper .dt-layout-cell {
  display: flex;
  align-items: center;
}

.sdt-wrapper .dt-layout-start {
  justify-content: flex-start;
}

.sdt-wrapper .dt-layout-end {
  justify-content: flex-end;
  margin-left: auto;
}

.dt-info {
  margin: 0;
  color: var(--muted-text);
  font-size: 14px;
}

.dt-paging nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.dt-paging-button {
  min-width: 34px;
  height: 34px;
  padding: 0 12px;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color) !important;
  background: var(--card-bg) !important;
  color: var(--text-color) !important;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  border-radius: 999px;
  transition:
    border-color 0.18s ease,
    color 0.18s ease,
    background 0.18s ease;
}

.dt-paging-button:hover:not(.disabled):not(.current) {
  border-color: var(--primary-blue) !important;
  background: color-mix(
    in srgb,
    var(--primary-blue) 14%,
    transparent
  ) !important;
  color: var(--primary-blue) !important;
}

.dt-paging-button--icon {
  width: 34px;
  min-width: 34px;
  padding: 0;
}

.dt-paging-button--icon i {
  font-size: 12px;
  line-height: 1;
}

.dt-paging-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-blue) 22%, transparent);
}

.dt-paging-button.current {
  border-color: transparent !important;
  background: var(--primary-blue) !important;
  color: #ffffff !important;
  font-weight: 700;
}

.dt-paging-button.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  color: var(--muted-text) !important;
  background: transparent !important;
  border-color: var(--border-color) !important;
  pointer-events: none;
}

/* Sortable column indicators */
table.sdt-table thead th.is-orderable {
  cursor: pointer;
}

table.sdt-table thead .dt-order-toggle {
  display: none !important;
}

table.sdt-table thead .dt-order-indicator {
  display: none;
  width: 0;
  height: 0;
  margin-left: 6px;
  flex-shrink: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
}

table.sdt-table thead .dt-order-indicator.is-asc,
table.sdt-table thead .dt-order-indicator.is-desc {
  display: inline-block;
}

table.sdt-table thead .dt-order-indicator.is-asc {
  border-bottom: 6px solid var(--primary-blue);
}

table.sdt-table thead .dt-order-indicator.is-desc {
  border-top: 6px solid var(--primary-blue);
}

@media (max-width: 767px) {
  .data-table-mobile-cards.data-table-wrap {
    overflow-x: auto;
    min-width: 0;
  }

  .data-table-mobile-cards .data-table,
  .data-table-mobile-cards .sdt-table {
    min-width: 720px;
  }

  .sdt-wrapper .dt-layout-row {
    display: block;
    padding: 0 12px;
  }

  .sdt-wrapper .dt-layout-cell {
    display: block;
    text-align: center;
    margin: 0.5em 0;
  }

  .dt-paging nav {
    justify-content: center;
    flex-wrap: wrap;
  }
}

.data-table code,
.sdt-table code {
  background: var(--input-bg);
  color: var(--primary-blue);
  padding: 4px 8px;
  border-radius: 4px;
  font-family: ui-monospace, 'Monaco', 'Menlo', monospace;
  font-size: 12px;
}

.data-table tbody tr.table-warning td,
.sdt-table tbody tr.table-warning td {
  background: color-mix(
    in srgb,
    var(--warning-color, #ffc107) 12%,
    transparent
  );
}

body.theme-dark .data-table tbody tr.table-warning td,
body.theme-dark .sdt-table tbody tr.table-warning td {
  background: color-mix(
    in srgb,
    var(--warning-color, #ffc107) 18%,
    transparent
  );
}
