@import '../../styles/common';
@import '../../Loader/styles/mixin';
@import 'mixin';
@import 'table-pagination';

//
// Table
// --------------------------------------------------

// Table Content
.@{ns}table {
  position: relative;
  overflow: hidden;
  background: @table-body-background;

  &-column-resizing {
    cursor: ew-resize;
    user-select: none;
  }

  &-row {
    overflow: hidden;
    position: absolute;
    height: 36px;
    width: 100%;
    top: 0;
    border-bottom: 1px solid @table-border-color;

    &.virtualized {
      .pointer-event-none;
    }
  }

  &-row-expanded {
    position: absolute;
    height: 46px;
    bottom: 0;
    width: 100%;
    z-index: 4;
    border-top: 1px solid @table-border-color;
    padding: 10px;
    background: @table-body-background;
  }

  &-hover &-row:hover &-cell-group {
    background: @table-body-background;
  }

  &-hover &-row:hover &-cell {
    background: @table-body-background;
  }

  &-row-header {
    color: @table-head-font-color;
    background: @table-head-background;
  }

  &-row-header &-cell {
    background: @table-head-background;
  }

  &-row-header &-cell-group-shadow {
    z-index: @zindex-table-row-cell-group-shadow;
    box-shadow: none;
  }

  // Added transition for hover
  &-row,
  &-cell-group,
  &-cell {
    transition: background-color 0.3s linear;
  }

  &-hover &-row:not(&-row-header):hover,
  &-hover &-row:hover &-cell-group,
  &-hover &-row:hover &-cell {
    background: @table-body-hover-background;
  }

  &-hover &-row-header:hover &-cell-group,
  &-hover &-row-header:hover &-cell {
    background: @table-head-background;
  }

  &-header-row-wrapper {
    z-index: @zindex-table-header-row-wrapper;
    position: relative;
  }

  &-body-row-wrapper {
    position: relative;
    overflow: hidden;
    z-index: @zindex-table-body-row-wrapper;
  }

  &-body-info {
    width: 100%;
    text-align: center;
    top: 50%;
    position: absolute;
    margin-top: -20px;
    line-height: 40px;

    .icon {
      margin: 0 10px;
    }

    &-wheel-area {
      width: 100%;
    }
  }

  &-body-wheel-area {
    width: 100%;
  }

  &-loader-wrapper {
    position: absolute;
    height: 100%;
    width: 100%;
    background-color: @table-loader-backdrop-color;
    opacity: 0;
    transition: opacity @table-loader-transition;
    .pointer-event-none;
  }

  &-loader {
    width: 100%;
    text-align: center;
    top: 50%;
    position: absolute;
    margin-top: -20px;
    line-height: 40px;

    &-icon {
      .set-side-length(@loader-default-diameter);
      .loader-spin;

      display: inline-block;
      position: relative;
      margin-right: @loader-content-spin-spacing-horizontal;
      // Make sure loader vertical-align center
      padding-top: 3px;
    }
  }

  &-loading &-loader-wrapper {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    // When loading cover scrollbar.
    z-index: 1;
  }

  &-cell {
    height: 36px;
    border-style: solid;
    border-width: 0;
    border-color: @table-border-color;
    display: block;
    overflow: hidden;
    position: absolute;
    white-space: normal;
    background: @table-body-background;

    &.first {
      border-left-width: 0;
    }

    &-wrap1 {
      display: table;
    }

    &-wrap2 {
      display: table-row;
    }

    &-wrap3 {
      display: table-cell;
      vertical-align: middle;
    }

    &-content {
      padding: @table-body-content-padding-vertical @table-content-padding-horizontal;

      .ellipsis;
    }

    &-header &-content {
      padding: @table-header-content-padding-vertical @table-content-padding-horizontal;
      font-size: @table-header-font-size;
      line-height: @table-header-line-small;
    }

    &-header {
      &-sort-wrapper {
        cursor: pointer;
        margin-left: @table-header-sort-wrapper-margin-left;
        display: inline-block;
      }

      &-icon-sort {
        width: 10px;
        height: 10px;
        color: @table-sort-icon-color;
        font-size: @table-header-font-size;
        line-height: @table-header-line-small;
      }

      &-icon-sort::after {
        content: @table-sort-icon-unsort;
        font-style: normal;
        font-family: @font-family-icon;
      }

      &-icon-sort-asc::after {
        content: @table-sort-icon-asc;
        color: @H500;
      }

      &-icon-sort-desc::after {
        content: @table-sort-icon-desc;
        color: @H500;
      }
    }
  }

  &-cell-header-sortable &-cell-content {
    cursor: pointer;
  }

  &-column-resize-spanner {
    .column-resize-spanner;

    border-left: @table-column-resize-spanner-gap-width solid @table-spanner-background;
    box-sizing: content-box;
    margin-left: -1 * @table-column-resize-spanner-gap-width;

    &::after,
    &::before {
      content: ' ';
      position: absolute;
      width: 0;
      height: 0;
      margin: auto;
      bottom: 0;
      top: 0;
      display: none;
    }

    &::before {
      border-style: dashed solid dashed dashed;
      border-color: transparent @table-resize-mouse-color transparent transparent;
      border-width: @table-column-resize-spanner-triangle-side-length;
      right: 4px;
    }

    &::after {
      border-style: dashed dashed dashed solid;
      border-color: transparent transparent transparent @table-resize-mouse-color;
      border-width: @table-column-resize-spanner-triangle-side-length;
      left: 4px;
    }
  }

  // Table not resizing , header should show resize-spanner .
  &:not(&-column-resizing) &-cell-header &-cell:hover ~ &-column-resize-spanner,
  &:not(&-column-resizing) &-column-resize-spanner:hover {
    background-color: @table-resize-mouse-color;

    &::before,
    &::after {
      display: block;
    }
  }

  &-cell-group {
    &-fixed-right,
    &-fixed-left {
      position: absolute;
      z-index: @zindex-table-cell-group-fixed;
      background: @table-body-background;
    }

    &-fixed-right {
      margin-left: @table-scrollbar-width;
    }

    &-shadow,
    &-left-shadow {
      box-shadow: 3px @table-table-cell-fixed-shadow;
    }

    &-right-shadow {
      box-shadow: -3px @table-table-cell-fixed-shadow;
    }
  }

  &-mouse-area {
    display: none;
    background: @table-resize-mouse-color;
    left: -1px;
    top: 0;
    position: absolute;
    width: 1px;
    z-index: @zindex-table-mouse-area;

    > span {
      .column-resize-spanner;

      background-color: @table-resize-mouse-color;
      position: absolute;
      left: -1 * (@table-column-resize-spanner-width / 2);
    }
  }

  &-word-wrap &-cell-content {
    white-space: normal;
    word-break: break-all;
  }

  &-bordered {
    border: 1px solid @table-border-color;
  }

  &-cell-bordered &-cell {
    border-width: 0 1px 0 0;
  }
}

// Tree Table
.@{ns}table-cell-expanded .@{ns}table-cell-expand-icon::before {
  font-family: @font-family-icon;
  content: @table-shrink-content;
}

.@{ns}table-cell-expand-wrapper {
  margin-right: 10px;
  display: inline-block;
  cursor: pointer;

  &::after {
    content: '';
    position: absolute;
    left: -1 * @icon-table-sense-width;
    right: -1 * @icon-table-sense-width;
    top: -1 * @icon-table-sense-width;
    bottom: -1 * @icon-table-sense-width;
  }
}

.@{ns}table-cell-expand-icon {
  width: 10px;
  cursor: pointer;
  outline: none;
  color: @table-expand-icon-color;

  &::before {
    font-family: @font-family-icon;
    content: @table-expand-content;
    font-style: normal;
  }
}

// Scrollbar
.@{ns}table-scrollbar {
  background: @table-scrollbar-background;
  position: absolute;
  transition: background @table-scrollbar-timing-duration linear,
    transform @table-scrollbar-timing-duration linear;
  opacity: 0.6;
  // Make sure Scrollbar on the loader.
  z-index: 1;

  &-hide {
    display: none;
  }

  &-handle {
    position: absolute;
    background-color: @table-scrollbar-handle-background;
    border-radius: 4px;
  }

  &-pressed {
    z-index: 1;
  }

  &-pressed &-handle {
    background-color: @table-scrollbar-pressed-handle-background;
  }

  &-horizontal {
    width: 100%;
    height: @table-scrollbar-width;
    bottom: 0;
  }

  &-horizontal &-handle {
    height: @table-scrollbar-handle-width;
    left: 0;
    top: @table-scrollbar-handle-gap;
  }

  &-pressed&-horizontal:hover,
  &-horizontal:hover {
    transform-origin: center bottom;
    transform: scaleY(1.2);
  }

  &-vertical {
    top: 0;
    right: 0;
    width: @table-scrollbar-width;
    // Reserve scroll bar position.
    bottom: @table-scrollbar-width;
    background-color: @table-scrollbar-vertical-handle-background-color;
  }

  &-vertical &-handle {
    min-height: 20px;
    width: @table-scrollbar-handle-width;
    top: 0;
    left: @table-scrollbar-handle-gap;
  }

  &-pressed&-vertical:hover,
  &-vertical:hover {
    transform-origin: right center;
    transform: scaleX(1.2);
  }
}
