/* =========================================================
   Large data table
   Builds on the existing BMC2 color and component variables
   ========================================================= */

.data-table-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

/* Header */

.data-table-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 30px;
  padding: 28px 30px;
  border-bottom: 1px solid var(--border);
  background:
    linear-gradient(
      105deg,
      rgba(0, 39, 76, 0.035),
      rgba(47, 101, 167, 0.07)
    );
}

.data-table-header h2 {
  margin-bottom: 8px;
}

.data-table-header p:last-child {
  max-width: 700px;
  margin: 0;
  color: var(--muted);
}

.data-table-header-actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Toolbar */

.table-toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(180px, 220px) 150px;
  gap: 18px;
  align-items: end;
  padding: 22px 30px;
  background: var(--white);
}

.table-search label,
.table-filter label {
  display: block;
  margin-bottom: 7px;
  color: var(--navy);
  font-size: 0.88rem;
  font-weight: 800;
}

.search-control {
  position: relative;
}

.search-control input,
.table-filter select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #9DAABD;
  border-radius: 6px;
  color: var(--text);
  background: var(--white);
}

.search-control input {
  padding: 9px 12px 9px 42px;
}

.table-filter select {
  padding: 9px 35px 9px 12px;
}

.search-control input:hover,
.table-filter select:hover {
  border-color: var(--blue);
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 14px;
  color: var(--gray);
  font-size: 1.3rem;
  transform: translateY(-52%);
  pointer-events: none;
}

.table-summary {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 30px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: #F8FAFC;
}

.table-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 0.91rem;
}

.text-button {
  padding: 4px;
  border: 0;
  color: var(--blue);
  background: transparent;
  cursor: pointer;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Scrolling table region */

.table-scroll-region {
  max-width: 100%;
  max-height: 650px;
  overflow: auto;
  background: var(--white);
  scrollbar-color: #8797AA #EDF1F5;
  scrollbar-width: thin;
}

.table-scroll-region:focus-visible {
  position: relative;
  z-index: 2;
  outline: 3px solid var(--focus);
  outline-offset: -3px;
}

.table-scroll-region::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.table-scroll-region::-webkit-scrollbar-track {
  background: #EDF1F5;
}

.table-scroll-region::-webkit-scrollbar-thumb {
  border: 3px solid #EDF1F5;
  border-radius: 20px;
  background: #8797AA;
}

.data-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--text);
  font-size: 0.92rem;
}

.data-table th,
.data-table td {
  padding: 15px 17px;
  border-bottom: 1px solid #E1E6ED;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  padding-top: 0;
  padding-bottom: 0;
  color: var(--white);
  background: var(--navy);
  box-shadow: inset 0 -3px 0 var(--red);
}

.data-table thead th:first-child {
  left: 0;
  z-index: 7;
}

.data-table tbody th[scope="row"] {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 245px;
  /* background: var(--white); */
  box-shadow: 1px 0 0 #E1E6ED;
}

.data-table tbody tr:nth-child(even) td,
.data-table tbody tr:nth-child(even) th[scope="row"] {
  /* background: #F8FAFC; */
}

.data-table tbody tr:hover td,
.data-table tbody tr:hover th[scope="row"] {
  /* background: #EDF4FB; */
}

.data-table tbody tr:last-child th,
.data-table tbody tr:last-child td {
  border-bottom: 0;
}

/* Sorting */

.sort-button {
  width: 100%;
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  margin: 0;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
  font-weight: 800;
  text-align: left;
  white-space: nowrap;
}

.sort-button:hover {
  color: #FFFFFF;
  text-decoration: underline;
  text-decoration-color: var(--coral);
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

.sort-indicator {
  color: #B9CBE0;
  font-size: 0.85rem;
}

.sort-button[aria-sort="ascending"] .sort-indicator,
.sort-button[aria-sort="descending"] .sort-indicator {
  color: var(--coral);
}

.sort-button[aria-sort="ascending"] .sort-indicator::before {
  content: "↑";
  font-size: 1rem;
}

.sort-button[aria-sort="descending"] .sort-indicator::before {
  content: "↓";
  font-size: 1rem;
}

.sort-button[aria-sort] .sort-indicator {
  font-size: 0;
}

/* Cells and links */

.numeric-column {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}

.numeric-column .sort-button {
  justify-content: flex-end;
}

.file-link {
  color: var(--blue);
  font-weight: 800;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.cell-secondary {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

.count-link {
  display: inline-flex;
  min-width: 27px;
  min-height: 27px;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  font-weight: 900;
  text-decoration: none;
}

.error-count {
  color: var(--error);
  background: var(--error-bg);
}

.warning-count {
  color: var(--warning);
  background: var(--warning-bg);
}

.action-column {
  position: sticky;
  right: 0;
  z-index: 2;
  min-width: 90px;
  text-align: right !important;
  background: var(--white);
  box-shadow: -1px 0 0 #E1E6ED;
}

.data-table thead .action-column {
  z-index: 7;
  background: var(--navy);
}

.data-table tbody tr:nth-child(even) .action-column {
  background: #F8FAFC;
}

.data-table tbody tr:hover .action-column {
  background: #EDF4FB;
}

.row-action {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 5px 11px;
  border: 1px solid #AFC1D7;
  border-radius: 5px;
  color: var(--navy);
  background: var(--white);
  font-size: 0.85rem;
  font-weight: 800;
  text-decoration: none;
}

.row-action:hover {
  color: var(--white);
  border-color: var(--blue);
  background: var(--blue);
}

/* Status badges */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 850;
  line-height: 1.15;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-complete {
  color: var(--success);
  border-color: #A9D9BF;
  background: var(--success-bg);
}

.status-warning {
  color: var(--warning);
  border-color: #E8C773;
  background: var(--warning-bg);
}

.status-failed {
  color: var(--error);
  border-color: #ECB3BB;
  background: var(--error-bg);
}

.status-processing {
  color: var(--indigo);
  border-color: #BBC2E6;
  background: #EEF0FC;
}

.status-processing .status-dot {
  animation: status-pulse 1.6s infinite ease-in-out;
}

@keyframes status-pulse {
  0%,
  100% {
    opacity: 0.35;
  }

  50% {
    opacity: 1;
  }
}

/* Empty state */

.table-empty-state {
  padding: 55px 25px;
  color: var(--muted);
  text-align: center;
}

.table-empty-state strong {
  display: block;
  margin-bottom: 5px;
  color: var(--navy);
  font-size: 1.15rem;
}

.table-empty-state p {
  margin: 0;
}

/* Footer and pagination */

.table-footer {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 25px;
  padding: 14px 30px;
  border-top: 1px solid var(--border);
  background: #F8FAFC;
}

.table-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.pagination,
.page-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pagination-button {
  min-width: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 11px;
  border: 1px solid #B2BECD;
  border-radius: 5px;
  color: var(--navy);
  background: var(--white);
  cursor: pointer;
  font-weight: 800;
}

.pagination-button:hover:not(:disabled) {
  color: var(--white);
  border-color: var(--blue);
  background: var(--blue);
}

.pagination-button.active,
.pagination-button[aria-current="page"] {
  color: var(--white);
  border-color: var(--navy);
  background: var(--navy);
}

.pagination-button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

/* Responsive adjustments */

@media (max-width: 900px) {
  .data-table-header {
    flex-direction: column;
  }

  .table-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .table-search {
    grid-column: 1 / -1;
  }
}

@media (max-width: 650px) {
  .data-table-header,
  .table-toolbar,
  .table-summary,
  .table-footer {
    padding-right: 18px;
    padding-left: 18px;
  }

  .data-table-header-actions {
    width: 100%;
  }

  .data-table-header-actions .button {
    flex: 1;
  }

  .table-toolbar {
    grid-template-columns: 1fr;
  }

  .table-search {
    grid-column: auto;
  }

  .table-summary,
  .table-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .pagination {
    width: 100%;
    justify-content: space-between;
  }

  .page-buttons {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .status-processing .status-dot {
    animation: none;
  }
}