/* ── Viewport lock — only when a data table is on the page ────── */

.data-table input[type="search"]::-webkit-search-cancel-button {
  cursor: pointer;
}

body:has(.data-table-fullscreen) {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

body:has(.data-table-fullscreen) > div:has(.sidebar) > main {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body:has(.data-table-fullscreen) > div:has(.sidebar) > main > .container,
body:has(.data-table-fullscreen) > div:has(.sidebar) > main > .container-fluid {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ── Data Table — flex fill layout (fullscreen only) ───────────── */

.data-table-fullscreen {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.data-table-fullscreen .data-table-results {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.data-table-fullscreen .card {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.data-table-fullscreen .table-responsive {
  flex: 1 1 0;
  overflow-y: auto;
}

/* ── Table styling ─────────────────────────────────────────────── */

.data-table .table {
  font-size: 0.875rem;
  margin-bottom: 0;
}

.data-table .table thead th {
  position: sticky;
  top: 0;
  background: var(--bs-body-bg);
  z-index: 1;
  border-bottom: 2px solid var(--bs-border-color);
  padding: 0.625rem 0.75rem;
}

.data-table .table tbody td {
  padding: 0.625rem 0.75rem;
  vertical-align: middle;
}

.data-table .table tbody tr:hover {
  background-color: var(--bs-primary-bg-subtle);
}

/* ── Sortable header button ──────────────────────────────────── */

.data-table-sort-btn {
  background: none;
  border: none;
  padding: 0;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--bs-secondary-color);
  cursor: pointer;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table-sort-btn:hover {
  color: var(--bs-primary);
}

.data-table-sort-btn .fa-sort,
.data-table-sort-btn .fa-sort-up,
.data-table-sort-btn .fa-sort-down {
  font-size: 0.625rem;
  margin-left: 0.25rem;
}

/* ── Info line ────────────────────────────────────────────────── */

.data-table-info {
  font-size: 0.8125rem;
  color: var(--bs-secondary-color);
}

/* ── Search highlight ─────────────────────────────────────────── */

.data-table mark {
  background-color: var(--bs-warning-bg-subtle);
  color: inherit;
  padding: 0.1em 0.2em;
  border-radius: 0.2em;
}

/* ── Empty state ──────────────────────────────────────────────── */

.data-table-empty {
  text-align: center;
  padding: 4.5rem 1rem;
  background-color: var(--bs-body-bg);
}

.data-table-empty .empty-state-content {
  max-width: 400px;
  margin: 0 auto;
}

.data-table-empty .empty-state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background-color: var(--bs-secondary-bg);
  color: var(--bs-secondary-color);
  margin-bottom: 1.25rem;
}

.data-table-empty .empty-state-icon i {
  font-size: 1.5rem;
}

.data-table-empty .empty-state-title {
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--bs-heading-color);
}

.data-table-empty .empty-state-description {
  margin: 0;
  font-size: 0.875rem;
  color: var(--bs-secondary-color);
}

/* ── Filter panel (dropdown overlay) ──────────────────────────── */

.data-table-filter-panel {
  position: absolute;
  top: calc(100% + 0.375rem);
  left: 0;
  z-index: 10;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  padding: 0.625rem 0.75rem;
  box-shadow: var(--bs-box-shadow-sm);
}

/* ── Select filters ───────────────────────────────────────────── */

.data-table .form-select {
  width: auto;
  font-weight: 500;
  color: var(--bs-secondary-color);
  border-color: var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  cursor: pointer;
}

.data-table .form-select:focus {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.15);
}

/* ── Pagination ───────────────────────────────────────────────── */

.data-table .card-footer {
  border-top: 1px solid var(--bs-border-color);
}

.data-table .pagination {
  gap: 0.25rem;
}

.data-table .page-item .page-link {
  border: none;
  border-radius: var(--bs-border-radius);
  color: var(--bs-secondary-color);
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.375rem 0.7rem;
  min-width: 2rem;
  text-align: center;
  background: transparent;
  transition: all 0.15s ease;
}

.data-table .page-item .page-link:hover {
  background-color: var(--bs-tertiary-bg);
  color: var(--bs-body-color);
}

.data-table .page-item.active .page-link {
  background-color: var(--bs-primary);
  color: var(--bs-white);
}

.data-table .page-item.disabled .page-link {
  background: transparent;
  color: var(--bs-secondary-color);
}

/* Loading state */
.data-table:has(.htmx-request) .table-responsive {
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.data-table:has(.htmx-request) .data-table-toolbar {
  pointer-events: none;
  opacity: 0.7;
}
