/*
  SFS tables: plain HTML table surfaces.
  Tabulator and admin grid-specific rules stay in admin/grid owner files.
  Docs: _deploy/css-compartmentalisation-readable-map-20260704.md
  Related: _deploy/css-compartmentalisation-worklog-20260704.md; _deploy/css-compartmentalisation-verification-20260704.md
*/

/* Tables: dense, structured, calm. */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 12px 0 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

th,
td {
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line-soft);
}

th {
  background: var(--surface-soft);
  color: #4f5964;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: #fbfcfd;
}

table a {
  font-weight: 600;
  text-decoration: none;
}

table a:hover {
  text-decoration: underline;
}

/* Dark-mode table contrast fixes. */
@media (prefers-color-scheme: dark) {
  tbody tr:hover td {
    background: #20231f;
    color: var(--text);
  }

  tbody tr:hover a {
    color: var(--brand-strong);
  }

  th {
    background: #1d211d;
    color: #9fb0bd;
  }

  table {
    background: var(--surface);
    border-color: var(--line);
  }

  td {
    border-bottom-color: var(--line-soft);
  }
}

/* Dense volume table mode. */
table {
  font-size: 13px;
  margin-top: 10px;
  margin-bottom: 18px;
}

th,
td {
  padding: 6px 8px;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  font-size: 11px;
  line-height: 1.2;
}

td {
  font-size: 13px;
  line-height: 1.28;
}

/* Make identifiers and timestamps compact. */
td:first-child,
th:first-child {
  width: 1%;
  white-space: nowrap;
}

td:nth-child(3),
td:nth-child(4),
td:nth-child(5),
td:nth-child(6),
td:nth-child(7),
td:nth-child(8) {
  white-space: nowrap;
}

/* Let filenames/details use the remaining width and wrap only when needed. */
td:nth-child(2) {
  min-width: 220px;
  max-width: 520px;
  overflow-wrap: anywhere;
}

/* Admin event/details tables need details to wrap instead of forcing huge width. */
td:last-child {
  max-width: 620px;
  overflow-wrap: anywhere;
}

/* Links inside dense tables should be easy to scan but not visually noisy. */
table a,
table a:visited {
  color: var(--text);
  font-weight: 520;
  text-decoration: none;
}

table a:hover,
table a:focus {
  color: var(--brand-strong);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* Compact empty rows. */
td[colspan] {
  color: var(--muted);
  padding: 10px 8px;
}

/* Dark-mode sticky table headers should remain readable while scrolling. */
@media (prefers-color-scheme: dark) {
  th {
    background: #1b1f1b;
  }

  table a,
  table a:visited {
    color: #e4e7e1;
    font-weight: 500;
  }

  table a:hover,
  table a:focus {
    color: var(--brand-strong);
  }
}

/* On smaller screens, keep table usable rather than pretty. */
@media (max-width: 900px) {
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  td:last-child {
    max-width: none;
  }
}
