$component-name: $lib-name + "-table";
$table-border-color: $border-color-base;
$table-header-bg: $background-color-disabled;
$table-stripe-row-bg: lighten($background-color-disabled, 1);
$table-row-hover-bg: lighten($primary-color-hover, 45);
$order-triangle-height: 4px;

.#{$component-name} {
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  border-right: none;
  border-bottom: none;
  background: $background-color-base;
  &::before {
    position: absolute;
    left: 0;
    bottom: 0;
    z-index: 20;
    width: 100%;
    height: 1px;
    background: $table-border-color;
    content: "";
  }
  &.#{$component-name}--border {
    border: 1px solid $table-border-color;
    border-right: none;
    border-bottom: none;
    &::after {
      position: absolute;
      top: 0;
      right: 0;
      z-index: 20;
      width: 1px;
      height: 100%;
      background: $table-border-color;
      content: "";
    }
  }
  .hidden-content {
    visibility: hidden;
    position: absolute;
    z-index: -1;
  }
  .table-header-wrapper,
  .table-body-wrapper {
    overflow: hidden;
    &.flex-wrapper {
      display: flex;
    }
  }
  .#{$component-name}-header,
  .#{$component-name}-body {
    table-layout: fixed;
    // fix scroller line-height
    line-height: 1;
  }
  .table-header-row {
    background: $table-header-bg;
  }
  .table-row {
    transition: background $transition-time;
    &:hover,
    &.hover-state {
      background: $table-row-hover-bg;
    }
    &.striped-row {
      background: $table-stripe-row-bg;
      &:hover,
      &.hover-state {
        background: $table-row-hover-bg;
      }
    }
  }
  .table-header-cell,
  .table-cell {
    box-sizing: border-box;
    &.right-border {
      border-right: 1px solid $table-border-color;
    }
    &.bottom-border {
      border-bottom: 1px solid $table-border-color;
    }
    &.hidden-column {
      visibility: hidden;
    }
  }
  .table-header-cell-content,
  .table-cell-content {
    padding: 10px 12px;
    font-size: 14px;
    line-height: 18px;
    text-overflow: ellipsis;
    overflow-wrap: break-word;
    &.align-left {
      text-align: left;
    }
    &.align-center {
      text-align: center;
    }
    &.align-right {
      text-align: right;
    }
    &.icon-column {
      .expand-icon {
        cursor: pointer;
        color: $sub-text-color-light;
        font-size: 14px;
        &:hover {
          color: $primary-color;
        }
      }
    }
    .unfold-icon {
      margin-left: 8px;
      cursor: pointer;
      color: $sub-text-color-light;
      font-size: 12px;
      transition: transform $transition-time;
      &:hover {
        color: $primary-color;
      }
      &.rotate-down {
        transform: rotate(90deg);
      }
    }
  }
  .table-header-cell-content {
    font-weight: 500;
    color: $title-color-light;
    &.flex-cell {
      display: flex;
      align-items: center;
      .table-header-text.sortable-column {
        cursor: pointer;
        user-select: none;
      }
      &.align-left {
        justify-content: flex-start;
      }
      &.align-center {
        justify-content: center;
      }
      &.align-right {
        justify-content: flex-start;
        flex-direction: row-reverse;
      }
    }
    .column-order-area {
      display: inline-flex;
      flex-direction: column;
      justify-content: space-between;
      height: 18px;
      margin: 0 8px;
      .ascending-order,
      .descending-order {
        cursor: pointer;
        border-style: solid;
        border-width: $order-triangle-height;
      }
      .ascending-order {
        border-color: transparent transparent $disabled-text-color-light transparent;
      }
      .descending-order {
        border-color: $disabled-text-color-light transparent transparent transparent;
      }
    }
  }
  .asc .column-order-area .ascending-order {
    border-color: transparent transparent $primary-color transparent;
  }
  .desc .column-order-area .descending-order {
    border-color: $primary-color transparent transparent transparent;
  }
  .table-cell-content {
    color: $content-color-light;
    @for $i from 1 through 9 {
      &.row-level-#{$i} {
        padding-left: 12px * $i;
      }
    }
  }
  &.affix-table-header {
    .affix {
      position: fixed;
      top: 0;
      z-index: 5;
      background: $background-color-base;
    }
  }
  .fixed-left-table-wrapper,
  .fixed-right-table-wrapper {
    position: absolute;
    top: 0;
    z-index: 10;
    overflow: hidden;
    background: $background-color-base;
    box-shadow: $box-shadow-base;
    &.no-shadow {
      box-shadow: none;
      .transparent-border {
        border-right-color: $table-border-color;
      }
    }
    .affix {
      z-index: 15;
    }
    .table-header-wrapper,
    .table-body-wrapper {
      position: absolute;
    }
  }
  .fixed-left-table-wrapper {
    left: 0;
    .transparent-border {
      border-right-color: transparent;
    }
  }
  .fixed-right-table-wrapper {
    right: 0;
    .table-header-wrapper,
    .table-body-wrapper {
      right: 0;
    }
  }
  .table-empty-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 50px;
    .table-empty-text {
      font-size: 14px;
      color: $sub-text-color-light;
    }
  }
  .table-column-resize-proxy {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 1px solid $table-border-color;
    z-index: 25;
  }
  &.scrollable-x {
    .table-body-scroller {
      &.#{$lib-name}-h-scrollbar {
        z-index: 6;
      }
      &.#{$lib-name}-v-scrollbar {
        z-index: 16;
      }
    }
  }
}
