@include dark-mode {
  $table-variants: (
    "primary":    shift-color($primary, $table-bg-scale-dark),
    "secondary":  shift-color($secondary, $table-bg-scale-dark),
    "success":    shift-color($success, $table-bg-scale-dark),
    "info":       shift-color($info, $table-bg-scale-dark),
    "warning":    shift-color($warning, $table-bg-scale-dark),
    "danger":     shift-color($danger, $table-bg-scale-dark),
  );

  @each $color, $value in $table-variants {
    @include table-variant($color, $value);
  }
}

.table {
  thead {
    th {
      color: $table-th-color;
      background: $table-th-bg;
      @include subheader;
      padding-top: $table-th-padding-y;
      padding-bottom: $table-th-padding-y;
      white-space: nowrap;

      @media print {
        background: transparent;
      }
    }
  }
}

.table-responsive {
  .table {
    margin-bottom: 0;
  }

  + .card-footer {
    border-top: 0;
  }
}

.table-transparent {
  thead {
    th {
      background: transparent;
    }
  }
}

.table-nowrap {
  > :not(caption) > * > * {
    white-space: nowrap;
  }
}

.table-vcenter {
  > :not(caption) > * > * {
    vertical-align: middle;
  }
}

.table-center {
  > :not(caption) > * > * {
    text-align: center;
  }
}

.td-truncate {
  max-width: 1px;
  width: 100%;
}

.table-mobile {
  @each $breakpoint, $breakpoint-max-widthin in $grid-breakpoints {
    &#{breakpoint-infix($breakpoint)} {
      @include media-breakpoint-down($breakpoint) {
        display: block;

        thead {
          display: none;
        }

        tbody,
        tr {
          display: flex;
          flex-direction: column;
        }

        td {
          display: block;
          padding: $table-cell-padding-x $table-cell-padding-y !important;
          border: none;
          color: var(--#{$prefix}body-color) !important;

          &[data-label] {
            &:before {
              @include subheader;
              content: attr(data-label);
              display: block;
            }
          }
        }

        tr {
          border-bottom: var(--#{$prefix}border-width) var(--#{$prefix}border-style) $table-border-color;
        }

        .btn {
          display: block;
        }
      }
    }
  }
}

.table-sort {
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  border: 0;
  background: inherit;
  display: block;
  width: 100%;
  text-align: inherit;
  @include transition(color $transition-time);

  margin: (-$table-th-padding-y) (-$table-th-padding-x);
  padding: $table-th-padding-y $table-th-padding-x;

  &:hover,
  &.asc,
  &.desc {
    color: var(--#{$prefix}body-color);
  }

  &:after,
  &.asc:after,
  &.desc:after {
    content: "";
    display: inline-flex;
    width: 1rem;
    height: 1rem;
    vertical-align: bottom;
    background: $table-sort-bg-image no-repeat center;
    opacity: .2;
  }

  &.asc:after {
    background: $table-sort-desc-bg-image no-repeat center;
    opacity: 1;
  }

  &.desc:after {
    background: $table-sort-asc-bg-image no-repeat center;
    opacity: 1;
  }
}

.table-borderless {
  thead th {
    background: transparent;
  }
}