/*
 * BGMS system-wide legacy table upgrader.
 * Explicit data-bgms-collection tables keep their page-specific implementation.
 */

.bgms-auto-table-toolbar {
  display: grid;
  grid-template-columns: minmax(250px, 1fr) minmax(175px, 240px) auto auto;
  align-items: end;
  gap: 12px;
  margin: 0 0 14px;
}

.bgms-auto-table-search {
  position: relative;
  display: block;
  min-width: 0;
}

.bgms-auto-table-search svg {
  position: absolute;
  top: 50%;
  right: 13px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.bgms-auto-table-search input {
  width: 100%;
  min-height: 44px;
  padding-right: 42px;
}

.bgms-auto-table-filter {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.bgms-auto-table-filter > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.bgms-auto-table-filter select {
  width: 100%;
  min-height: 44px;
}

.bgms-auto-table-count {
  align-self: center;
  white-space: nowrap;
}

.bgms-auto-table-scroll {
  width: 100%;
  max-height: 430px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface, #fff);
  -webkit-overflow-scrolling: touch;
}

.bgms-auto-table-scroll:focus-within {
  outline: 3px solid rgba(37, 99, 235, 0.16);
  outline-offset: 2px;
}

table.bgms-auto-table {
  min-width: 760px;
  margin: 0;
}

table.bgms-auto-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--surface-subtle, #f8fafc);
  box-shadow: inset 0 -1px 0 var(--line);
}

table.bgms-auto-table tbody tr[hidden] {
  display: none;
}

.bgms-auto-table-no-results {
  margin-top: 12px;
}

@media (max-width: 900px) {
  .bgms-auto-table-toolbar {
    grid-template-columns: minmax(0, 1fr) minmax(160px, 210px);
  }

  .bgms-auto-table-toolbar .bgms-auto-table-reset,
  .bgms-auto-table-toolbar .bgms-auto-table-count {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .bgms-auto-table-toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .bgms-auto-table-scroll {
    max-height: 390px;
  }

  table.bgms-auto-table {
    min-width: 680px;
  }
}
