@import "mixins/mixins";
@import "checkbox";
@import "tag";
@import "tooltip";
@import "common/var";

// 表格tip样式，因tip节点在table之外，所以无法放include里
.table-tooltip {
  max-width: 240px;
}

@include b(table) {
  position: relative;
  // overflow: hidden;
  box-sizing: border-box;
  flex: 1;
  width: 100%;
  max-width: 100%;
  background-color: $--color-white;
  font-size: 12px;
  color: $--table-font-color;
  min-height: 40px;
  padding: 0 16px;
  padding-bottom: 1px;

  th {
    border-bottom: 1px solid rgba(44, 40, 54, 0.12);
    border-top: 1px solid rgba(44, 40, 54, 0.12);
  }

  // 数据为空
  @include e(empty-block) {
    min-height: 60px;
    text-align: center;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    .empty-default {
      display: flex;
      flex-flow: column nowrap;
      justify-content: center;
      align-items: center;
      height: 100%;
      width: 100%;
      margin: 0 auto;
      min-height: 350px;
      .img_table_no_data {
        width: 286px;
        height: 140px;
      }
      .no-data {
        margin-top: 12px;
        font-family: PingFangSC, PingFang SC;
        font-weight: 400;
        font-size: 14px;
        color: rgba(44, 40, 54, 0.66);
        line-height: 22px;
        letter-spacing: 4px;
        text-align: right;
        font-style: normal;
      }
    }
  }

  @include e(empty-text) {
    // min-height doesn't work in IE10 and IE11 https://github.com/philipwalton/flexbugs#3-min-height-on-a-flex-container-wont-apply-to-its-flex-items
    // set empty text line height up to contrainer min-height as workaround.
    line-height: 60px;
    width: 50%;
    color: $--color-text-secondary;
  }

  // 展开行
  @include e(expand-column) {
    .cell {
      padding: 0;
      text-align: center;
    }
  }

  @include e(expand-icon) {
    position: relative;
    cursor: pointer;
    color: #666;
    font-size: 12px;
    transition: transform 0.2s ease-in-out;
    height: 20px;

    @include m(expanded) {
      transform: rotate(90deg);
    }

    /*rtl:ignore*/
    @include m(expandedRtl) {
      &:dir(rtl) {
        transform: rotate(270deg);
      }
    }
    > .el-icon {
      position: absolute;
      left: 50%;
      top: 50%;
      margin-left: -5px;
      margin-top: -5px;
    }
  }

  @include e(expanded-cell) {
    background-color: $--color-white;

    // 纯属为了增加权重
    &[class*="cell"] {
      padding: 20px 50px;
    }

    &:hover {
      background-color: transparent !important;
    }
  }

  @include e(placeholder) {
    display: inline-block;
    width: 20px;
  }

  @include e(append-wrapper) {
    // 避免外边距重合 https://developer.mozilla.org/zh-CN/docs/Web/CSS/CSS_Box_Model/Mastering_margin_collapsing
    overflow: hidden;
  }

  @include m(fit) {
    border-right: 0;
    border-bottom: 0;

    th.gutter,
    td.gutter {
      border-right-width: 1px;
    }
  }

  @include m(scrollable-x) {
    .yk-table__body-wrapper {
      overflow-x: auto;
    }
  }

  @include m(scrollable-y) {
    .yk-table__body-wrapper {
      overflow-y: auto;
    }
  }
  .is-fixHeader {
    box-shadow: 0px 6px 12px 0px rgba(0, 102, 255, 0.04);
    position: relative;
    z-index: 4;
  }
  thead {
    color: $--table-header-font-color;
    font-weight: 500;

    &.is-group {
      th {
        background: $--background-color-base;
      }
    }
  }
  th {
    // padding: 22px 0;
  }
  td {
    height: 80px;
    // font-size: 14px;
  }
  th,
  td {
    min-width: 0;
    box-sizing: border-box;
    text-overflow: ellipsis;
    vertical-align: middle;
    position: relative;
    text-align: left;
    
    @include when(center) {
      text-align: center;
    }

    @include when(right) {
      text-align: right;
    }

    &.gutter {
      width: 15px;
      border-right-width: 0;
      border-bottom-width: 0;
      padding: 0;
    }

    &.is-hidden {
      > * {
        visibility: hidden;
      }
    }
  }

  @include m(medium) {
    th {
      box-sizing: border-box;
      height: 64px;
      box-sizing: border-box;
    }
    td {
      box-sizing: border-box;
      height: 80px;
      // font-size: 14px;
    }
  }

  @include m(small) {
    font-size: 12px;
    th,
    td {
      box-sizing: border-box;
      height: 52px;
    }
  }

  @include m(mini) {
    font-size: 12px;
    th,
    td {
      box-sizing: border-box;
      height: 30px;
    }
    .yk-button {
      font-size: 12px !important;
    }
  }

  tr {
    background-color: $--color-white;

    input[type="checkbox"] {
      margin: 0;
    }
  }

  th.is-leaf,
  td {
    // border-bottom: $--table-border;
    // border-top: 1px solid rgba($color: #000000, $alpha: 0);
    &:first-child {
      border-left: 1px solid rgba($color: #ffffff, $alpha: 0);
    }
    &:last-child {
      border-right: 1px solid rgba($color: #ffffff, $alpha: 0);
    }
  }
  td {
    border-bottom: 1px solid rgba($color: #000000, $alpha: 0);
  }

  th.is-sortable {
    cursor: pointer;
  }

  th {
    overflow: hidden;
    user-select: none;
    background-color: $--table-header-background-color;
    border-left: 1px solid rgba(44, 40, 54, 0.12);

    > .cell {
      display: inline-block;
      box-sizing: border-box;
      position: relative;
      vertical-align: middle;
      padding-left: 16px;
      padding-right: 16px;
      width: calc(100% - 18px);

      .yk-table-unitCss {
        font-family: PingFangSC, PingFang SC;
        font-weight: 400;
        font-size: 12px;
        color: rgba(44, 40, 54, 0.44);
        line-height: 12px;
        text-align: left;
        font-style: normal;
      }

      &.highlight {
        color: $--color-primary;
      }
    }

    &.required > div::before {
      display: inline-block;
      content: "";
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: #ff4d51;
      margin-right: 5px;
      vertical-align: middle;
    }

    // &:first-child {
    //   > .cell {
    //     padding-left: 32px;
    //   }
    // }
    // &:nth-last-child(2) {
    //   > .cell {
    //     padding-right: 32px;
    //   }
    // }
  }

  td {
    div {
      box-sizing: border-box;
    }

    &.gutter {
      width: 0;
    }
  }

  .cell {
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    word-break: break-all;
    padding-left: 16px;
    padding-right: 16px;
    max-height: 80px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    width: 100% !important;
  }

  // 拥有多级表头
  @include m((group, border)) {
    border: $--table-border;

    @include share-rule(border-pseudo) {
      content: "";
      position: absolute;
      background-color: $--table-border-color;
      z-index: 1;
    }

    // 表格右部伪 border
    &::after {
      @include extend-rule(border-pseudo);
      top: 0;
      right: 0;
      width: 1px;
      height: 100%;
    }
  }

  // 表格右部伪 border
  &::after {
    @include extend-rule(border-pseudo);
    top: 0;
    right: 0;
    width: 0px;
    height: 100%;
  }
  // 表格底部伪 border，总是有的
  &::before {
    @include extend-rule(border-pseudo);
    left: 0;
    bottom: 0;
    width: 100%;
    height: 0px; //去掉高度.没下边线,无border时不需要
  }

  // table--border
  @include m(border) {
    border-right: none;
    border-bottom: none;
    &.yk-loading-parent--relative {
      border-color: transparent;
    }

    th,
    td {
      // border-right: $--table-border;
      // border-bottom: $--table-border;

      &:first-child .cell {
        padding-left: 16px;
      }
    }
    th.gutter:last-of-type {
      border-bottom: $--table-border;
      border-bottom-width: 1px;
    }
    & th {
      border-bottom: $--table-border;
    }
    &::before {
      content: "";
      position: absolute;
      left: 0;
      bottom: 0;
      width: 100%;
      height: 1px; //去掉高度.没下边线
      background-color: $--border-color-lighter;
      z-index: 4;
    }
    // 表格右部伪 border
    &::after {
      @include extend-rule(border-pseudo);
      top: 0;
      right: 0;
      width: 1px;
      height: 100%;
      z-index: 4;
    }
  }

  @include m(hidden) {
    visibility: hidden;
  }

  @include e((fixed, fixed-right)) {
    position: absolute;
    top: 0;
    left: 16px;
    overflow-x: hidden;
    overflow-y: hidden;
    box-shadow: $--table-fixed-box-shadow;
    z-index: 6;
    // &::before {
    //   @include extend-rule(border-pseudo);
    //   left: 0;
    //   bottom: 0;
    //   width: 100%;
    //   height: 1px; //去掉高度.没下边线,无border时不需要
    //   z-index: 5;
    // }
  }
  @include e((fixed-right)) {
    box-shadow: -6px -4px 12px 0px rgba(0, 102, 255, 0.04);
  }

  @include e(fixed-right-patch) {
    position: absolute;
    top: -1px;
    right: 0;
    background-color: $--color-white;
    border-bottom: $--table-border;
  }

  @include e(fixed-right) {
    top: 0;
    left: auto;
    right: 16px;
    &.hasBorder {
      border-right: 1px solid $--table-border-color;
    }
    .yk-table__fixed-header-wrapper,
    .yk-table__fixed-body-wrapper,
    .yk-table__fixed-footer-wrapper {
      left: auto;
      right: 0;
    }
  }

  @include e(fixed-header-wrapper) {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 4;
  }

  @include e(fixed-footer-wrapper) {
    position: absolute;
    left: 0;
    bottom: 0;
    z-index: 3;

    & tbody td {
      border-top: $--table-border;
      background-color: $--table-row-hover-background-color;
      color: $--table-font-color;
    }
  }

  @include e(fixed-body-wrapper) {
    position: absolute;
    left: 0;
    top: 37px;
    overflow: hidden;
    z-index: 3;
  }
  @include e((sticky)) {
    position: sticky;
    top: 0;
    z-index: 6;
  }
  @include e((header-wrapper, body-wrapper, footer-wrapper)) {
    width: 100%;
  }

  @include e(footer-wrapper) {
    margin-top: -1px;
    td {
      border-top: $--table-border;
    }
  }

  @include e((header, body, footer)) {
    table-layout: fixed;
    border-collapse: separate;
  }

  @include e((header-wrapper, footer-wrapper)) {
    overflow: hidden;

    & tbody td {
      background-color: $--table-row-hover-background-color;
      color: $--table-font-color;
    }
  }

  @include e(body-wrapper) {
    overflow: hidden;
    position: relative;

    @include when(scrolling-none) {
      ~ .yk-table__fixed,
      ~ .yk-table__fixed-right {
        box-shadow: none;
      }
      // ~ .is-fixHeader{
      //   box-shadow: none;
      // }
    }

    @include when(scrolling-top) {
      ~ .yk-table__fixed {
        box-shadow: none;
      }
    }

    @include when(scrolling-left) {
      ~ .yk-table__fixed {
        box-shadow: none;
      }
    }

    @include when(scrolling-right) {
      ~ .yk-table__fixed-right {
        box-shadow: none;
      }
    }

    .yk-table--border {
      @include when(scrolling-right) {
        ~ .yk-table__fixed-right {
          border-left: $--table-border;
        }
      }

      @include when(scrolling-left) {
        ~ .yk-table__fixed {
          border-right: $--table-border;
        }
      }
    }
  }

  .caret-wrapper {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    height: 16px;
    width: 16px;
    vertical-align: middle;
    cursor: pointer;
    overflow: initial;
    position: relative;
    top: -2px;
    margin-left: 4px;
  }

  .sort-caret {
    fill: #2c2836;
    stroke: #2c2836;
    stroke-width: 1;
    opacity: 0.32;
  }

  .ascending .sort-caret.ascending {
    opacity: 1;
    // border-bottom: 5px solid $--color-black;
  }

  .descending .sort-caret.descending {
    opacity: 1;
    // border-top: 5px solid $--color-black;
  }

  .hidden-columns {
    visibility: hidden;
    position: absolute;
    z-index: -1;
  }
  .columns-field-none {
    display: none;
  }

  @include m(striped) {
    & .yk-table__body {
      & tr.yk-table__row--striped {
        td {
          // background: #FAFAFA;
          background: rgba(30, 70, 188, 0.06);
        }
        // &.current-row td {
        //   // background-color: $--table-current-row-background-color;
        //   box-sizing: border-box;
        //     // background-color: $--table-row-hover-background-color;
        //     border-top: 1px solid $--color-primary;
        //     border-bottom: 1px solid $--color-primary;
        //     box-sizing: border-box;
        //     &:first-child{
        //       border-left: 1px solid $--color-primary !important;
        //       // border-radius: 4px 0 0 4px !important;
        //     }
        //     &:last-child{
        //       border-right: 1px solid $--color-primary !important;
        //       z-index: 2;
        //       // border-radius: 0 4px 4px 0 !important;
        //     }
        // }
      }
      & tr.hover-row {
        td {
          // background: #ffffff;
        }
      }
    }
  }

  @include e(body) {
    // // 新增左右边距16px
    // tr {
    //   & {
    //     &, &.current-row {
    //       > td {
    //         &:first-child{
    //           padding-left: 16px;
    //         }
    //         &:last-child{
    //           padding-right: 16px;
    //         }
    //       }
    //     }
    //   }
    // }
    tr.hover-row {
      &,
      &.yk-table__row--striped {
        &,
        &.current-row {
          > td {
            // background-color: $--table-row-hover-background-color;
            border-top: 1px solid $--color-primary;
            border-bottom: 1px solid $--color-primary;
            z-index: 5;
            &:first-child {
              border-left: 1px solid $--color-primary !important;
              border-radius: 4px 0 0 4px !important;
            }
            &:last-child {
              border-right: 1px solid $--color-primary !important;
              border-radius: 0 4px 4px 0 !important;
            }
          }
        }
      }
    }

    tr.current-row > td {
      // background-color: $--table-current-row-background-color;
      border-top: 1px solid $--color-primary;
      border-bottom: 1px solid $--color-primary;
      box-sizing: border-box;
      z-index: 5;
      &:first-child {
        border-left: 1px solid $--color-primary !important;
        border-radius: 4px 0 0 4px !important;
      }
      &:last-child {
        border-right: 1px solid $--color-primary !important;
        border-radius: 0 4px 4px 0 !important;
      }
    }
  }

  @include e(column-resize-proxy) {
    position: absolute;
    left: 200px;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: $--table-border;
    z-index: 10;
  }

  @include e(column-filter-trigger) {
    display: inline-block;
    line-height: 34px;
    cursor: pointer;

    & i {
      color: $--color-info;
      font-size: 12px;
      transform: scale(0.75);
    }
  }

  @include m(enable-row-transition) {
    .yk-table__body td {
      transition: background-color 0.25s ease;
    }
  }

  @include m(enable-row-hover) {
    .yk-table__body tr.current-row {
      > td {
        box-sizing: border-box;
        // background-color: $--table-row-hover-background-color;
        border-top: 1px solid $--color-primary;
        border-bottom: 1px solid $--color-primary;
        box-sizing: border-box;
        z-index: 5;
        &:first-child {
          border-left: 1px solid $--color-primary !important;
          border-radius: 4px 0 0 4px !important;
        }
        &:last-child {
          border-right: 1px solid $--color-primary !important;
          border-radius: 0 4px 4px 0 !important;
        }
      }
    }
    .yk-table__body tr > td {
      border-top: 1px solid rgba($color: #ffffff, $alpha: 0);
      border-bottom: 1px solid rgba($color: #ffffff, $alpha: 0);
      &:first-child {
        border-left: 1px solid rgba($color: #ffffff, $alpha: 0) !important;
        border-radius: 4px 0 0 4px !important;
      }
      &:last-child {
        border-right: 1px solid rgba($color: #ffffff, $alpha: 0) !important;
        border-radius: 4px 0 0 4px !important;
      }
    }
    .yk-table__body tr:hover > td {
      // z-index: 10;
      background-color: #ffffff;
      border-top: 1px solid $--color-primary;
      border-bottom: 1px solid $--color-primary;
      box-sizing: border-box;
      z-index: 5;
      &:first-child {
        border-left: 1px solid $--color-primary !important;
        border-radius: 4px 0 0 4px !important;
      }
      &:last-child {
        border-right: 1px solid $--color-primary !important;
        border-radius: 0 4px 4px 0 !important;
      }
      &.yk-table__expanded-cell {
        border-radius: 4px !important;
      }
    }
  }

  @include m(fluid-height) {
    .yk-table__fixed,
    .yk-table__fixed-right {
      bottom: 0;
      overflow: hidden;
    }
  }

  [class*="yk-table__row--level"] {
    .yk-table__expand-icon {
      display: inline-block;
      width: 20px;
      line-height: 20px;
      height: 20px;
      text-align: center;
      margin-right: 3px;
    }
  }
}
// .table-head-filter-popover {
//   padding: 12px 4px 12px 12px !important;
//   width: 164px;
//   box-sizing: content-box;
// }
.table-field-sort {
  .yk-checkbox {
    // padding: 10px 0;
  }
  .line {
    height: 1px;
    background: rgba(46, 99, 253, 0.06);
    margin-bottom: 8px;
  }
  .table-field-sort-group {
    display: flex;
    flex-direction: column;
    max-height: 333px;
    overflow-y: auto;
    position: relative;
  }
  .yk-checkbox__input.is-checked + .yk-checkbox__label {
    color: rgba(44, 40, 54, 1) !important;
  }
  .header {
    padding-bottom: 12px;
    line-height: 36px;
    height: 36px;
    .yk-checkbox__label {
      font-size: 13px;
      font-weight: 600;
    }
  }
  .table-header-filter-checked-item {
    display: flex;
    align-items: center;
    line-height: 32px;
    height: 32px;
    margin-bottom: 8px;
    .yk_icon_move {
      font-size: 16px;
      margin-right: 8px;
      color: #2c2836;
      opacity: 0.12;
    }
    .yk-checkbox {
      display: inline-flex;
      align-items: center;
      .yk-checkbox__input {
        top: 1px;
      }
      .yk-checkbox__label {
        overflow: hidden;
        white-space: nowrap;
        width: 110px;
        text-overflow: ellipsis;
      }
    }
    &:hover {
      background: rgba(46, 99, 253, 0.04);
      border-radius: 4px;
    }
  }
  .ps .ps__rail-x:hover,
  .ps .ps__rail-y:hover,
  .ps .ps__rail-x:focus,
  .ps .ps__rail-y:focus,
  .ps .ps__rail-x.ps--clicking,
  .ps .ps__rail-y.ps--clicking {
    opacity: 1;
    background-color: transparent;
  }
  .ps__rail-y {
    width: 12px;
    .ps__thumb-y {
      background-color: rgba(208, 214, 245, 0.56);
    }
    &:hover {
      background-color: transparent;
      .ps__thumb-y {
        background-color: rgba(208, 214, 245, 1);
        width: 10px;
      }
    }
  }
  .ps__rail-y.ps--clicking .ps__thumb-y,
  .ps__rail-y:focus > .ps__thumb-y,
  .ps__rail-y:hover > .ps__thumb-y {
    background-color: rgba(208, 214, 245, 1);
    width: 10px;
  }
}
.table-head-filter-icon {
  font-size: 15px;
}
.tableHeaderFilterIconChecked {
  color: $--color-primary;
  background: $--button-secondary-bg-color !important;
  border-radius: 4px;
}
.tableHeaderFilterIcon {
  background: #ffffff;
  box-shadow: -9px 0px 20px 1px #ffffff;
  position: absolute;
  top: 1px;
  right: 16px;
  cursor: pointer;
  text-align: center;
  width: 28px;
  height: 28px;
  z-index: 9;
  line-height: 28px;
}

.table-header-title {
  display: flex;
  flex-flow: row nowrap;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background-color: #fff;
  .left {
    display: flex;
    flex-flow: row nowrap;
    justify-content: flex-start;
    align-items: center;
    min-width: 44px;
    flex: 1;
    margin-right: 12px;


    .table-title-left{
      display: flex;
      width: 100%;
    }
    .table-title-left-content{
      flex: 1;
      font-style: normal;      
      display: flex;
      min-width: 0;
      align-items: center;
      .table-title-text-total{
        // flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-weight: 600;
      }
    }

    .table-title-icon {
      width: 16px;
      height: 16px;
      flex-shrink: 0;
      margin-right: 8px;
    }
    .table-title-text {
      font-family: PingFangSC, PingFang SC;
      font-weight: 500;
      font-size: 14px;
      color: #2c2836;
      line-height: 22px;
      text-align: left;
      font-style: normal;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }
  .table-title-total{
    flex: 0 0 auto;
    flex-shrink: 0;
    font-family: PingFangSC, PingFang SC;
    font-weight: 500;
    font-size: 14px;
    color: #2c2836;
    line-height: 22px;
    text-align: left;
    font-style: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .right {
    display: flex;
    flex-flow: row nowrap;
    justify-content: flex-start;
    align-items: center;
    .controller {
      padding: 4px 4px 4px 13px;
      background: rgba(46, 99, 253, 0.06);
      border-radius: 4px;
      border: 1px solid rgba(44, 40, 54, 0.06);
      font-family: PingFangSC, PingFang SC;
      font-weight: 400;
      font-size: 13px;
      color: #2c2836;
      line-height: 22px;
      text-align: left;
      font-style: normal;
      display: flex;
      flex-flow: row nowrap;
      justify-content: flex-start;
      align-items: center;
      flex-shrink: 0;
      .btn-group {
        display: flex;
        flex-flow: row nowrap;
        justify-content: flex-start;
        align-items: center;
        column-gap: 2px;
        .btn-item {
          cursor: pointer;
          padding: 1px 12px;
        }
        .btn-item.active {
          background: #2e63fd;
          border-radius: 4px;
          font-family: PingFangSC, PingFang SC;
          font-weight: 500;
          font-size: 13px;
          color: #ffffff;
          line-height: 22px;
          text-align: right;
          font-style: normal;
        }
      }
    }
    .button-group {
      display: flex;
      flex-flow: row nowrap;
      justify-content: flex-start;
      align-items: center;
      .divider {
        width: 1px;
        height: 20px;
        background: rgba(44, 40, 54, 0.12);
        margin: 0 12px;
      }
    }
  }
}
.yk-table__row td {
  border: 1px solid transparent;
}
.gutter {
  border-left: none !important;
}
