/**
 * Tables — canonical, token-driven.
 *
 * Promoted from DriverReports as the canonical shared table styling: neutral,
 * token-driven headers (not brand-filled) and token borders. The scroll
 * wrappers and the in-table input reset are kept from the previous
 * Intranet-sourced file so consumers keep working.
 */

/* ============================================================================
   BASE TABLE ELEMENT
   ============================================================================ */

table {
  width: 100%;
  min-width: 100%;
  margin-bottom: var(--spacing-lg);
  border-collapse: collapse;
  background-color: var(--bg-white);
  font-size: var(--font-size-base);
}

thead {
  background-color: var(--bg-light);
  border-bottom: 2px solid var(--border-color);
}

th {
  padding: var(--spacing-sm);
  font-weight: var(--font-weight-semibold);
  text-align: left;
  color: var(--text-dark);
  border-bottom: 1px solid var(--border-color);
}

td {
  padding: var(--spacing-sm);
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

tbody tr:hover {
  background-color: var(--bg-light);
}

tbody tr:last-child td {
  border-bottom: 2px solid var(--border-color);
}

/* Reset field spacing when inputs sit inside table cells (inline editing). */
table tbody input[type='text'],
table tbody input[type='number'],
table tbody input[type='email'],
table tbody input[type='password'],
table tbody input[type='url'],
table tbody input[type='date'],
table tbody select,
table tbody textarea {
  margin-bottom: 0;
}

/* ============================================================================
   INLINE EDITING
   ============================================================================ */

tbody tr.editing {
  background-color: var(--surface-editing);
  border: 2px solid var(--brand-primary);
}

tbody tr .edit-mode input,
tbody tr .edit-mode textarea {
  width: 100%;
  padding: 0.25rem var(--spacing-sm);
  font-size: var(--font-size-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
}

tbody tr .edit-mode input:focus,
tbody tr .edit-mode textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: var(--focus-glow);
}

/* ============================================================================
   CELL UTILITIES
   ============================================================================ */

td.action-buttons {
  white-space: nowrap;
}

td.action-buttons .btn {
  margin-right: 0.25rem;
  margin-bottom: 0.25rem;
}

td.no-data {
  text-align: center;
  font-style: italic;
  color: var(--text-light);
}

/* ============================================================================
   SCROLL WRAPPERS
   ============================================================================ */

.table-wrapper {
  position: relative;
}

.table-wrapper > div {
  max-width: 100%;
  overflow: auto;
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 768px) and (max-width: 991px) {
  table {
    font-size: var(--font-size-sm);
  }
}
