/*
 * Scoped to .edr-contracts-table — every rule below is prefixed, so no other
 * Mantine Table in the portal is affected.
 *
 * Column sizing: table-layout stays `auto`. Every column sizes to its content
 * with a 30px floor and no wrapping — when the columns together outgrow the
 * viewport, the table widens and the wrapper's overflow-x takes over.
 */
/*
 * width: max-content — the table is exactly as wide as its columns' content
 * needs, never squeezed to fit the viewport; the overflow-x wrapper scrolls
 * instead. min-width: 100% keeps it filling the card when content is narrow.
 */
.edr-contracts-table {
  table-layout: auto;
  width: max-content;
  min-width: 100%;
}

.edr-contracts-table th,
.edr-contracts-table td {
  min-width: 40px;
}

/*
 * Mantine Badge caps itself at max-width: 100%; inside an auto-layout table
 * cell that resolves against min-content and clips the label ("General" →
 * "Gen…"). Let the badge size to its text so the column grows to fit it.
 */
.edr-contracts-table .mantine-Badge-root {
  max-width: none;
}

/*
 * Full-width rows (loading / error / empty / expanded step banner) span every
 * column via colspan — leave their wrapping alone.
 */
.edr-contracts-table th,
.edr-contracts-table td:not([colspan]) {
  white-space: nowrap;
}

/*
 * Action column hugs its content: width 1% + nowrap makes the browser give it
 * the minimum width its buttons need and nothing more.
 */
.edr-contracts-table th:last-child,
.edr-contracts-table td:last-child:not([colspan]) {
  width: 1%;
}

/* Sticky header row (moved off the Mantine `styles` prop — see ContractsList). */
.edr-contracts-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

/*
 * Sticky action column. `:not([colspan])` keeps the full-width rows — loading,
 * error, empty state, and the expanded ContractStepBanner row — out of it;
 * those span every column and have no separate action cell to pin.
 */
.edr-contracts-table th:last-child,
.edr-contracts-table td:last-child:not([colspan]) {
  position: sticky;
  right: 0;
  box-shadow: -12px 0 16px -6px rgba(16, 32, 47, 0.3);
}

/*
 * Sticky cells sit above the scrolling ones, so they need their own opaque
 * background or the columns underneath show through. Each state below mirrors
 * the background the row already has.
 */
.edr-contracts-table td:last-child:not([colspan]) {
  /* Very light blue-grey tint sets the action column apart from the rows. */
  background: #f5f8fb;
  z-index: 2;
}

.edr-contracts-table tbody tr:hover td:last-child:not([colspan]) {
  background: #f4fbf8;
}

/* Expanded row: the parent <tr> carries an inline #F4FBF8 background. */
.edr-contracts-table tbody tr[data-expanded="true"] td:last-child:not([colspan]) {
  background: #f4fbf8;
}

/* Header cell is sticky on both axes — it must outrank the body's sticky column. */
.edr-contracts-table th:last-child {
  background: #f8fafc;
  z-index: 3;
}
