/* ==================================
   #DATA TABLE (DRAFT)
   ================================== */

.au-c-data-table {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  flex-grow: 1;
  height: 100%;
  overflow: hidden;
}

.au-c-data-table__actions {
  flex-shrink: 1;
}

.au-c-data-table__actions--top {
}

.au-c-data-table__actions--bottom {
  padding: $au-unit-small $au-unit;
  border-top: 0.1rem solid var(--au-gray-300);
}

.au-c-data-table__search {
  position: relative;
  min-width: 32rem;

  > .au-c-input {
    padding-right: $au-unit-large;
  }
}

.au-c-data-table__search-icon {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  padding: $au-unit-tiny $au-unit-small;
}

.au-c-data-table__wrapper {
  flex-grow: 999;
  overflow: auto;
  position: relative;
  border-top: 1px solid var(--au-gray-300);
  width: 100%;
}

.au-c-data-table__table {
  @include au-font-size(var(--au-h6));
  display: table;
  position: relative;
  min-width: 50rem;
  width: 100%;
  border-collapse: collapse;

  thead {
    position: relative;
    width: 100%;
    z-index: var(--au-z-index-alpha);
    border: 0;
    @include au-font-size(var(--au-base), 1.2);
  }

  tbody tr {
    border-bottom: 0.1rem solid var(--au-gray-300);
  }

  tbody tr:nth-child(odd) {
    background-color: var(--au-gray-100);
  }

  tbody tr:nth-child(even) {
    background-color: var(--au-white);
  }

  th {
    font-weight: var(--au-medium);
    text-align: left;
    padding: $au-unit-tiny $au-unit-small;
    border-radius: 0;
  }

  td {
    padding: $au-unit-small;
  }

  th {
    white-space: nowrap;
  }

  th,
  td {
    max-width: 55ch;
    position: relative;
  }

  th.is-selectable,
  td.is-selectable {
    width: $au-unit-large + $au-unit-tiny;
  }

  th:first-child,
  td:first-child {
    padding-left: $au-unit;
  }

  th:last-child,
  td:last-child {
    padding-right: $au-unit;
    min-width: 0;
  }

  th + th,
  td + td {
    &:after {
      content: "";
      display: block;
      position: absolute;
      width: 0.1rem;
      left: -0.1rem;
      top: 0;
      height: 100%;
      border-left: 0.1rem dotted var(--au-gray-300);
    }
  }
}

.au-c-data-table__table.au-c-data-table__table--small {
  th,
  td {
    padding: $au-unit-tiny;
  }

  th:first-child,
  td:first-child {
    padding-left: $au-unit;
  }
}

.au-c-data-table__header {
  background-color: var(--au-white);

  th {
    position: sticky;
    z-index: 1;
    top: 0;
    border: 0;
    outline: 0;
    background-color: var(--au-white);
    box-shadow: inset 0 -0.2rem 0 0 var(--au-gray-300);
  }
}

.au-c-data-table__sort {
  border: 0;
  outline: 0;
  padding: $au-unit-tiny;
  color: var(--au-gray-700);

  > .au-c-icon {
    bottom: -0.1ex;
  }

  &:after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }

  &:focus {
    outline: var(--au-outline);
  }
}

.au-c-data-table__header-title {
  font-weight: var(--au-medium);
}

.au-c-data-table__header-title--sortable {
  display: flex;
  align-items: baseline;
  position: relative;
  text-decoration: underline;
  text-decoration-color: var(--au-gray-300);
  color: var(--au-gray-700);
  transition: color var(--au-transition);

  &:hover {
    color: var(--au-gray-900);
    text-decoration: none;
  }

  &.is-active {
    text-decoration: none;
    color: var(--au-gray-900);
  }
}

.au-c-data-table__message {
  border-bottom: 0.1rem solid var(--au-gray-300);
}
