.vuiTableWrapper {
  container-type: inline-size;
  width: 100%;
  position: relative;
}

.vuiTableBlock {
  background-color: transparentize($colorEmptyShade, 0.6);
  height: 100%;
  left: 0;
  padding: $sizeM;
  position: absolute;
  top: 0;
  width: 100%;
}

.vuiTable {
  width: 100%;
  table-layout: fixed;

  thead {
    border-bottom: 1px solid $borderColor;
  }

  tbody tr {
    border-bottom: 1px solid $borderColorLight;

    &.vuiTableRow-isBeingActedUpon,
    &:not(.vuiTableRow--inert):hover {
      background-color: transparentize($colorLightShade, 0.75);
      box-shadow: $shadowSmallEnd;
      border-bottom-color: transparent;
    }

    &:last-child {
      border-bottom: 1px solid $borderColor;
    }

    .vuiTableCell__label {
      display: none;
      max-inline-size: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .vuiTableCell {
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: flex-start;
    }
  }

  th {
    font-size: $fontSizeStandard;
    font-weight: $fontWeightBold;
    padding: $sizeXxs;
  }

  td {
    font-size: $fontSizeStandard;
    padding: $sizeXxs;
    vertical-align: middle;
    word-break: break-word;
  }
}

.vuiTableCell__label {
  font-size: $fontSizeSmall;
  font-weight: $labelFontWeight;
  color: $labelColor;
}

@container (width < 800px) {
  .vuiTable--responsive {
    thead {
      display: none;
    }

    .vuiTableRow--isSelectable {
      padding-left: $sizeXxl;
    }

    .vuiTableRow--hasActions {
      padding-right: $sizeXxl;
    }

    tbody tr {
      position: relative;
      column-gap: $sizeM;
      row-gap: $sizeM;
      display: grid;
      grid-template-columns: 1fr 1fr;
      padding-top: $sizeM;
      padding-bottom: $sizeM;
      border: none;
      border-radius: $sizeXs;
      box-shadow: $shadowLargeStart;
      margin-bottom: $sizeS;

      td {
        padding: 0;
      }

      .vuiTableCellWrapper {
        display: flex;
        flex-direction: column;
        gap: $sizeXxs;
      }

      .vuiTableCell__label {
        display: block;
      }

      .vuiTableRowSelect {
        position: absolute;
        top: $sizeM;
        left: $sizeXs;
      }

      .vuiTableRowActions {
        position: absolute;
        top: $sizeXs * 1.25;
        right: $sizeXs;
      }
    }

    &.vuiTable--notSelectable {
      tbody tr {
        padding-left: $sizeM;
      }
    }

    &.vuiTable--noActions {
      tbody tr {
        padding-right: $sizeM;
      }
    }
  }
}

@container (width < 500px) {
  .vuiTable--responsive {
    tbody tr {
      grid-template-columns: 1fr;
    }
  }
}

.vuiTable--verticalAlignTop {
  tbody td {
    vertical-align: top;
  }
}

.vuiTable--verticalAlignMiddle {
  tbody td {
    vertical-align: middle;
  }
}

.vuiTable--verticalAlignBottom {
  tbody td {
    vertical-align: bottom;
  }
}

.vuiTable--fluid {
  table-layout: auto;
}

.vuiTableActions {
  display: flex;
  justify-content: flex-end;
}

.vuiTableManyPagesToken {
  padding: 0 $sizeXs;
}

.vuiTableManyPagesToken-isDisabled {
  opacity: 0.5;
}

.vuiTableHeaderSelect {
  width: 32px;

  .vuiTableCellWrapper {
    text-align: left; // Align checkbox with checkboxes in table rows.
  }
}

.vuiTableHeaderActions {
  width: 42px;
}

.vuiTableContent {
  height: 80px;
}

.vuiTableStickyHeader {
  position: sticky;
  top: 0;
  background-color: $colorEmptyShade;
  padding: $sizeS $sizeS 0;
  margin: 0 -$sizeS; // Preserve same table position as when sticky header is not used
  margin-bottom: $sizeS;
  z-index: 1; // Ensure it is above the table content

  &::after {
    content: "";
    position: absolute;
    bottom: -$sizeS;
    left: 0;
    width: 100%;
    height: $sizeS;
    background: linear-gradient(rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
    pointer-events: none;
  }
}
