@tablePrefixCls: rc-table;
@text-color: #666;
@font-size-base: 12px;
@line-height: 1.5;
@table-border-color: #e9e9e9;
@table-head-background-color: #f7f7f7;
@vertical-padding: 16px;
@horizontal-padding: 8px;
@border-width: 1px;
@border-color: red;
@border: @border-width solid @border-color;
@cell-padding: @vertical-padding @horizontal-padding;
@cell-margin: -@vertical-padding -@horizontal-padding;

.tableBorder() {
  border: @border;
  border-right: 0;
  border-bottom: 0;
}

.@{tablePrefixCls} {
  position: relative;
  box-sizing: border-box;
  color: @text-color;
  font-size: @font-size-base;
  line-height: @line-height;

  &-rtl {
    direction: rtl;
  }

  // ================= Global =================
  table {
    width: 100%;
    border-spacing: 0px;
  }

  th,
  td {
    position: relative;
    box-sizing: border-box;
    padding: 0;

    padding: @cell-padding;
    white-space: normal;
    word-break: break-word;
    border: @border;
    border-top: 0;
    border-left: 0;
    transition: box-shadow 0.3s;

    .@{tablePrefixCls}-rtl& {
      border-right: 0;
      border-left: @border;
    }
  }

  // ================== Cell ==================
  &-cell {

    &-fix-left,
    &-fix-right {
      z-index: 1;
    }

    &-fix-right:last-child:not(&-fix-sticky) {
      border-right-color: transparent;
    }

    .@{tablePrefixCls}-rtl & {
      &-fix-right:last-child {
        border-right-color: @border-color;
      }

      &-fix-left:last-child {
        border-left-color: transparent;
      }
    }

    &-fix-left-first {
      .@{tablePrefixCls}-rtl & {
        box-shadow: 1px 0 0 @border-color;
      }
    }

    &-fix-left-first::after,
    &-fix-left-last::after {
      position: absolute;
      top: 0;
      right: -1px;
      bottom: -1px;
      width: 20px;
      transform: translateX(100%);
      transition: box-shadow 0.3s;
      content: '';
      pointer-events: none;
    }

    &-fix-right-first,
    &-fix-right-last {
      box-shadow: -1px 0 0 @border-color;

      .@{tablePrefixCls}-rtl & {
        box-shadow: none;
      }

      &::after {
        position: absolute;
        top: 0;
        bottom: -1px;
        left: -1px;
        width: 20px;
        transform: translateX(-100%);
        transition: box-shadow 0.3s;
        content: '';
        pointer-events: none;
      }
    }

    &&-ellipsis {
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;

      // Fixed first or last should special process
      &.@{tablePrefixCls}-cell-fix-left-first,
      &.@{tablePrefixCls}-cell-fix-left-last,
      &.@{tablePrefixCls}-cell-fix-right-first &.@{tablePrefixCls}-cell-fix-right-last {
        overflow: visible;

        .@{tablePrefixCls}-cell-content {
          display: block;
          overflow: hidden;
          text-overflow: ellipsis;
        }
      }
    }

    &&-row-hover {
      background: rgba(255, 0, 0, 0.05);
    }
  }

  &-ping-left {

    .@{tablePrefixCls}-cell-fix-left-first::after,
    .@{tablePrefixCls}-cell-fix-left-last::after {
      box-shadow: inset 10px 0 8px -8px green;
    }
  }

  &-ping-right {

    .@{tablePrefixCls}-cell-fix-right-first::after,
    .@{tablePrefixCls}-cell-fix-right-last::after {
      box-shadow: inset -10px 0 8px -8px green;
    }
  }

  // ================= Expand =================
  &-expand-icon-col {
    width: 60px;
  }

  &-row-expand-icon-cell {
    text-align: center;
  }

  // ================= Header =================
  thead {

    td,
    th {
      text-align: center;
      background: @table-head-background-color;
    }

    .@{tablePrefixCls}-cell-scrollbar::after {
      position: absolute;
      top: 0;
      bottom: 0;
      left: -1px;
      width: 1px;
      background: @table-head-background-color;
      content: '';

      .@{tablePrefixCls}-rtl& {
        right: -1px;
        left: auto;
      }
    }
  }

  &-header {
    .tableBorder();
  }

  // ================= Empty ==================
  &-placeholder {
    text-align: center;
  }

  // ================== Body ==================
  tbody {
    tr {

      td,
      th {
        background: #fff;
      }
    }
  }

  &-content {
    .tableBorder();
    border-radius: 5px 0 0 0;
  }

  &-body {
    .tableBorder();
    border-top: 0;
  }

  &-fixed-column &-body::after {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    border-right: @border;
    content: '';
  }

  // ================= Expand =================
  &-expanded-row {
    .@{tablePrefixCls}-cell {
      box-shadow: inset 0 8px 8px -8px green;
    }

    &-fixed {
      box-sizing: border-box;
      margin: @cell-margin;
      margin-right: -@horizontal-padding - 2 * @border-width;
      padding: @cell-padding;

      &::after {
        position: absolute;
        top: 0;
        right: 1px;
        bottom: 0;
        width: 0;
        border-right: @border;
        content: '';
      }
    }
  }

  &-row-expand-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    color: #aaa;
    line-height: 16px;
    text-align: center;
    vertical-align: middle;
    border: 1px solid currentColor;
    cursor: pointer;

    &.@{tablePrefixCls}-row-expanded::after {
      content: '-';
    }

    &.@{tablePrefixCls}-row-collapsed::after {
      content: '+';
    }

    &.@{tablePrefixCls}-row-spaced {
      visibility: hidden;
    }
  }

  // ================= Title ==================
  &-title {
    padding: @cell-padding;
    border: @border;
    border-bottom: 0;
  }

  // ================= Footer =================
  &-footer {
    padding: @cell-padding;
    border: @border;
    border-top: 0;
  }

  tfoot {
    td {
      background: #fff;
    }
  }

  &-summary {
    border-top: @border;
    border-left: @border;
  }

  &-sticky {
    &-holder {
      position: sticky;
      z-index: 2;
    }

    &-scroll {
      position: sticky;
      bottom: 0;
      z-index: 2;
      display: flex;
      align-items: center;
      border-top: 1px solid #f3f3f3;
      opacity: 0.6;
      transition: transform 0.1s ease-in 0s;

      &:hover {
        transform: scaleY(1.2);
        transform-origin: center bottom;
      }

      &-bar {
        height: 8px;
        background-color: #bbb;
        border-radius: 4px;

        &:hover {
          background-color: #999;
        }

        &-active {
          background-color: #999;
        }
      }
    }
  }
}