/*
 * Tables
 * @see https://designsystem.digital.gov/components/tables/
 * @source https://github.com/uswds/uswds/blob/develop/src/stylesheets/elements/_table.scss
 */

table.atat-table {
  @include panel-margin;
  min-width: 100%;

  @include ie-only {
    border-collapse: separate;
  }

  background: $color-white;

  th,
  td {
    &.table-cell {
      &--align-right {
        text-align: right;
      }

      &--align-center {
        text-align: center;
      }

      &--shrink {
        width: 1%;
      }

      &--expand {
        width: 100%;
      }

      &--hide-small {
        display: none;

        @include media($medium-screen) {
          display: table-cell;
        }
      }
    }
  }

  tbody,
  thead {
    tr {
      th,
      td {
        background: none;
        margin: 0;
        padding: $gap * 2;
        border: 1px solid $color-gray-lighter;
        display: table-cell;
        white-space: nowrap;
        vertical-align: top;

        &:first-child {
          border-left: none;
        }

        &:last-child {
          border-right: none;
        }
      }
    }
  }

  thead {
    tr {
      th,
      td {
        background-color: $color-gray-lightest;
        padding: 1rem 1.5rem;
        border-top: none;
      }
    }
  }
}

.responsive-table-wrapper {
  overflow-x: auto;

  @include panel-margin;

  &__header {
    @include panel-base;
    @include panel-theme-default;

    border-top: none;
    border-bottom: 0;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    padding: $gap * 2;

    &__title {
      @include h4;

      font-size: $lead-font-size;
      justify-content: space-between;
      flex: 2;
    }
  }

  table {
    margin-bottom: 0;
  }

  @at-root .panel #{&} {
    &:last-child {
      margin-bottom: 0;
    }
  }
}

.fixed-table-wrapper {
  width: 100%;

  table {
    max-width: 100%;
    table-layout: fixed;

    th,
    td {
      white-space: normal;
    }
  }
}
