/* Table Styles - Premium Modern Design */
.record-table-wrapper {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-light);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0;
  margin-bottom: 2rem;
  /* Performance: contain layout to prevent reflows affecting parent */
  contain: layout style;
}

/* Tablet and up */
@media (min-width: 768px) {
  .record-table-wrapper {
    border-radius: var(--radius-xl);
    margin: 0 -1rem;
  }
}

.record-table-wrapper table {
  width: 100%;
  background: transparent;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
  table-layout: fixed;
}

.record-table-wrapper table thead {
  background: var(--color-text);
  color: white;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.record-table-wrapper table thead th {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  white-space: nowrap;
  padding: 1.125rem 1.25rem;
  border-bottom: none;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  text-align: left;
  vertical-align: middle;
  color: rgba(255, 255, 255, 0.95);
}

.record-table-wrapper table thead th:first-child {
  padding-left: 1.5rem;
  width: 80px;
  min-width: 80px;
}

.record-table-wrapper table thead th:last-child {
  border-right: none;
  text-align: center;
  width: 180px;
}

.record-table-wrapper table td {
  padding: 1.25rem 1.25rem;
  border-bottom: none;
  color: var(--color-text);
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.875rem;
  line-height: 1.5;
}

.record-table-wrapper table td:first-child {
  padding-left: 1.5rem;
  font-weight: 600;
  color: var(--color-accent);
  font-size: 0.8125rem;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}

.record-table-wrapper table tbody tr {
  background: var(--color-surface) !important;
  border-bottom: none;
  /* Performance: Only transition specific properties, not 'all' */
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  margin-bottom: 4px;
}

/* Override Bootstrap's default striping */
.record-table-wrapper table tbody tr:nth-of-type(odd) {
  background: var(--color-surface) !important;
}

.record-table-wrapper table tbody tr:nth-of-type(even) {
  background: var(--color-surface) !important;
}

.record-table-wrapper table tbody tr:hover {
  background: var(--color-bg-elevated) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.record-table-wrapper table th:last-child,
.record-table-wrapper table td:last-child {
  position: sticky;
  right: 0;
  background: var(--color-surface);
  z-index: 5;
  text-align: center;
  padding: 0.875rem 1.25rem;
}

.record-table-wrapper table thead th:last-child {
  background: var(--color-text);
  z-index: 15;
}

.record-table-wrapper table tbody tr:hover td:last-child {
  background: var(--color-surface) !important;
}

/* Ensure action column cells match row background */
.record-table-wrapper table tbody tr:nth-of-type(odd) td:last-child {
  background: var(--color-surface) !important;
}

.record-table-wrapper table tbody tr:nth-of-type(even) td:last-child {
  background: var(--color-surface) !important;
}

.record-table-wrapper table td:last-child {
  white-space: nowrap;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
}

.record-table-wrapper table td:last-child .btn {
  margin: 0;
  font-size: 0.8125rem;
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-sm);
  /* Performance: Specific transitions only */
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

/* Performance: Use content-visibility for off-screen rows */
.record-table-wrapper tbody tr {
  content-visibility: auto;
  contain-intrinsic-size: auto 60px;
}

/* ========== MOBILE TABLE OPTIMIZATIONS ========== */
/* Hide less important columns on mobile */
@media (max-width: 768px) {
  .record-table-wrapper table {
    font-size: 0.8rem;
  }

  .record-table-wrapper table thead th {
    padding: 0.75rem 0.5rem;
    font-size: 0.65rem;
  }

  .record-table-wrapper table td {
    padding: 0.75rem 0.5rem;
    font-size: 0.8rem;
  }

  /* Hide columns: Cemetery, Burial No., Sex, Age */
  .record-table-wrapper table th:nth-child(4),
  .record-table-wrapper table td:nth-child(4),
  .record-table-wrapper table th:nth-child(5),
  .record-table-wrapper table td:nth-child(5),
  .record-table-wrapper table th:nth-child(6),
  .record-table-wrapper table td:nth-child(6),
  .record-table-wrapper table th:nth-child(7),
  .record-table-wrapper table td:nth-child(7) {
    display: none;
  }

  .record-table-wrapper table thead th:first-child {
    width: 50px;
    min-width: 50px;
  }

  .record-table-wrapper table thead th:last-child {
    width: 80px;
  }

  .record-table-wrapper table td:last-child .btn {
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
  }

  /* Only show "Show" button, hide "Edit" on mobile */
  .record-table-wrapper table td:last-child .btn:not(:first-child) {
    display: none;
  }
}

@media (max-width: 480px) {
  .record-table-wrapper table {
    font-size: 0.75rem;
  }

  .record-table-wrapper table thead th {
    padding: 0.625rem 0.375rem;
    font-size: 0.6rem;
  }

  .record-table-wrapper table td {
    padding: 0.625rem 0.375rem;
    font-size: 0.75rem;
  }

  /* Also hide Time Period and Material on very small screens */
  .record-table-wrapper table th:nth-child(8),
  .record-table-wrapper table td:nth-child(8),
  .record-table-wrapper table th:nth-child(9),
  .record-table-wrapper table td:nth-child(9) {
    display: none;
  }

  .record-table-wrapper table thead th:first-child {
    width: 40px;
    min-width: 40px;
    padding-left: 0.5rem;
  }

  .record-table-wrapper table td:first-child {
    padding-left: 0.5rem;
  }

  .record-table-wrapper table thead th:last-child {
    width: 70px;
  }

  .record-table-wrapper table td:last-child .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
  }
}