/* Core table styling unified with high-priority overrides */
table,
.table,
table.table,
div table,
.paragraph-text table {
  border-collapse: collapse !important;
  border-radius: 10px !important;
  border: none !important;
  overflow: hidden !important;
  font-family: var(--font-family-body) !important;
  font-size: var(--font-size-sm) !important;
  font-weight: var(--font-weight-normal) !important;
  margin: var(--space-lg) 0 !important;
  width: 100% !important;
  color: var(--textColor) !important;
  background-color: transparent !important;
}

.table a {
  color: var(--textColor);
}

table td,
table th,
.table td,
.table th,
table.table td,
table.table th,
div table td,
div table th,
.paragraph-text table td,
.paragraph-text table th {
  border: 1px solid var(--white) !important;
  padding: var(--space-sm) var(--space-md) !important;
  background-color: var(--greyLight) !important;
  box-shadow: none !important;
  line-height: 1.2 !important;
  font-weight: 500 !important;
}

table tbody td,
.table tbody td,
table.table tbody td,
div table tbody td,
.paragraph-text table tbody td {
  background-color: var(--greyLight) !important;
}


/* Darker table header - higher specificity to override Bootstrap */
table thead th,
table thead td,
.table thead th,
.table thead td,
table.table thead th,
table.table thead td,
div table thead th,
div table thead td,
.paragraph-text table thead th,
.paragraph-text table thead td {
  background-color: var(--greyHeader) !important;
  color: var(--white) !important;
  font-weight: var(--font-weight-bold) !important;
  border: 1px solid var(--white) !important;
}

/* Borders removed on borderless tables */
.table-borderless th,
.table-borderless td {
  border: none !important;
  background-color: transparent !important;
}

.table-blank tr {
  background-color: transparent !important;
}

/* Legacy markup support */
table[align],
div table[align] {
  border-collapse: collapse !important;
  border: none !important;
}

table[align] td,
table[align] th {
  border: 1px solid var(--white) !important;
}

/* Webform Likert tables */
.webform-likert-table[data-likert-answers-count="2"] th:first-child {
  width: 75%;
}

.webform-likert-table[data-likert-answers-count="2"] th {
  width: 12.5%;
}

.webform-likert-table tr {
  background: transparent;
  background-color: rgba(72, 81, 99, 0.06) !important;
  border: none !important;
}

.webform-likert-table td,
.webform-likert-table th {
  border: none !important;
}

.webform-likert-table thead th {
  color: var(--white) !important;
  font-family: var(--font-family-body);
  font-weight: var(--font-weight-bold) !important;
  text-align: center;
  background-color: var(--greyHeader) !important;
  padding: var(--space-md) !important;
  border-bottom: 1px solid var(--white) !important;
}

.webform-likert-table thead th:first-child {
  text-align: left;
}

.webform-likert-table tr.odd {
  background-color: var(--greyLight) !important;
}

.webform-likert-table tr.even {
  background-color: var(--greyLighter) !important;
}

/* Reduce padding in likert table body cells for tighter row spacing */
.webform-likert-table tbody tr td {
  padding: var(--space-sm) var(--space-md);
}

/* Remove vertical margin from form items within likert table cells */
.webform-likert-table tbody tr td .form-item {
  margin-block: 0;
}

/* Remove vertical margin from labels within likert table cells */
.webform-likert-table tbody tr td .form-item__label {
  margin-block: 0;
}

/* Fix sticky header positioning after patches */
.webform-likert-table.sticky-header thead {
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Ensure proper spacing when header is sticky */
.webform-likert-table.sticky-header tbody tr:first-child td {
  border-top: none;
}

/* Bootstrap table component neutralisers */
table.table,
.table {
  --bs-table-color: var(--textColor) !important;
  --bs-table-bg: transparent !important;
  --bs-table-border-color: transparent !important;
  --bs-table-striped-color: var(--textColor) !important;
  --bs-table-striped-bg: transparent !important;
  --bs-table-hover-color: var(--textColor) !important;
  --bs-table-hover-bg: transparent !important;
  color: var(--textColor) !important;
  background-color: transparent !important;
  border-color: transparent !important;
}

/* Ensure consistent cell spacing and remove Bootstrap shadows */
.table > :not(caption) > * > *,
table.table > :not(caption) > * > * {
  background-color: transparent !important;
  box-shadow: none !important;
  padding: var(--space-sm) var(--space-md) !important;
}

/* Neutralise Bootstrap variants */
.table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: transparent !important;
}

.table-hover > tbody tr:hover > * {
  background-color: transparent !important;
}

.table-borderless > :not(caption) > * > * {
  border-bottom-width: 0 !important;
}
