@import '../../../../es/style/themes/default';
@import '../../../../es/style/mixins/index';
@import '../../text-field/style/mixin';
@import '../../trigger-field/style/mixin';
@import '../../select/style/mixin';
@import 'filter-select';
@import 'field-list';
@import 'customization';

@table-prefix-cls: ~'@{c7n-pro-prefix}-table';
@output-prefix-cls: ~'@{c7n-pro-prefix}-output';
@table-border: @border-width-base @border-style-base @border-color-base;

.@{table-prefix-cls} {
  position: relative;
  color: @text-color;
  font-size: @font-size-base;
  border-top: @table-border;
  border-bottom: @table-border;
  outline: none;

  table {
    font-size: inherit;
    text-align: left;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
  }

  &-header {
    margin-bottom: 0.1rem;
    padding: 0.08rem;
    font-weight: 400;
    font-size: 0.16rem;
    border-bottom: @border-width-base @border-style-base @border-color-base;
  }

  &-content {
    position: relative;
    overflow: hidden;

    &-overflow {
      overflow-x: auto;
      //border-right: @table-border;
    }
  }

  &-footer {
    padding: @table-padding-vertical 0;
    text-align: left;
  }

  &-export-progress-footer {
    display: flex;
    flex-flow: row nowrap;
    justify-content: space-between;
  }

  &-cell {
    margin: 0;
    padding: 0.01rem;

    &-inner {
      position: relative;
      display: block;
      padding: @table-padding-vertical @table-padding-horizontal;

      &:focus {
        outline: none;
      }

      &:empty::before {
        display: inline-block;
        width: 0;
        content: ' ';
      }

      &-edit {
        background-color: transparent;

        input {
          font-weight: 700;
          border-color: transparent;
        }
      }

      > * {
        vertical-align: middle;
      }

      &-fixed-height {
        overflow: hidden;
        text-overflow: ellipsis;
      }

      &-auto-height {
        word-break: break-all;
      }
    }

    &-dirty {
      .@{table-prefix-cls}-cell-inner::after {
        position: absolute;
        top: 0;
        left: 0;
        white-space: normal;
        border-top: 0.06rem solid @primary-color;
        border-right: 0.06rem solid transparent;
        content: ' ';
      }
    }

    .@{output-prefix-cls}-invalid::after {
      border-top-color: @error-color;
    }

    &-prefix {
      float: left;
      padding-left: @table-padding-horizontal;

      > * {
        vertical-align: middle;
      }
    }

    &-fix-left,
    &-fix-right {
      position: sticky !important;
      z-index: 2;
      background-image: linear-gradient(to right, @component-background 0%, @component-background 100%);
      background-blend-mode: multiply;
    }
  }

  &-thead &-cell,
  &-tfoot &-cell {
    position: relative;
    color: @heading-color;
    background-color: @table-header-bg;
    border-right: @border-width-base @border-style-base transparent;
  }

  &-thead &-cell,
  &-tfoot-bordered &-cell {
    border-bottom: @table-border;
  }

  &-thead &-cell[colspan] {
    border-bottom: none;
  }

  &-tfoot &-cell {
    border-top: @table-border;
  }

  &:not(&-bordered) &-thead&-column-resizable {
    border-bottom: none;

    .@{table-prefix-cls}-cell[colspan] {
      border-bottom: @border-width-base @border-style-base transparent;
    }

    &:hover,
    &.@{table-prefix-cls}-thead-hover {
      .@{table-prefix-cls}-cell {
        border-right-color: @border-color-base;
        border-bottom-color: @border-color-base;
      }
    }
  }

  &-tbody &-cell {
    border-right: @border-width-base @border-style-base transparent;
    border-bottom: @table-border;
  }

  &-row-number-column,
  &-customized-column {
    &,
    .@{table-prefix-cls}-cell-inner {
      padding: 0 !important;
    }
  }

  &-row-height-fixed &-cell-inner {
    padding: 0 @table-padding-horizontal;
    overflow: hidden;
    line-height: inherit;
    white-space: nowrap;
    text-overflow: ellipsis;

    &-fixed-height {
      padding: .07rem @table-padding-horizontal;
      white-space: normal;
      overflow-wrap: break-word;
    }

    .@{output-prefix-cls}-multi {
      div {
        overflow: hidden;
        line-height: inherit;
        white-space: nowrap;
        text-overflow: ellipsis;
      }

      .@{c7n-pro-prefix}-validation-message {
        padding-left: 0;
        font-size: inherit;
      }
    }
  }

  &-editor {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    transform: translateX(-1000rem);

    &-lock {
      z-index: 2;
    }

    > * {
      display: block !important;
    }

    .@{table-prefix-cls}-multi-label {
      opacity: 0;
    }

    .@{table-prefix-cls}-multi-value > * {
      width: calc(100% - 10px);
    }
  }

  &-body {
    position: relative;
    overflow: auto;
  }

  &-head {
    overflow: hidden;
  }

  &-foot {
    position: relative;
    overflow-x: auto;
    background-color: @component-background;
  }

  &-export-quantity {
    margin-top: .1rem;

    span {
      line-height: .3rem
    }

    .@{c7n-prefix}-col-18 {
      text-align: right;
    }
  }

  &-fixed-left,
  &-fixed-right {
    position: absolute;
    top: 0;
    z-index: 1;

    .@{table-prefix-cls}-head,
    .@{table-prefix-cls}-body {
      overflow-x: hidden;
      overflow-y: auto;
    }

    .@{table-prefix-cls}-body {
      background-color: #fff;
    }

    .@{table-prefix-cls}-foot {
      overflow-x: hidden;
    }

    table {
      background-color: #fff;
      transition: width 0.3s;
    }
  }

  &-fixed-left {
    left: 0;
    box-shadow: 0.06rem 0 0.06rem -0.04rem @shadow-color;
  }

  &-fixed-right {
    right: 0;
    box-shadow: -0.06rem 0 0.06rem -0.04rem @shadow-color;
  }

  &-scroll-position-left &-fixed-left,
  &-scroll-position-right &-fixed-right {
    box-shadow: none;
  }

  &-cell-fix-left-last,
  &-cell-fix-right-first {
    &::after {
      position: absolute;
      top: 0;
      bottom: -.01rem;
      width: .3rem;
      transition: box-shadow .3s;
      content: "";
      pointer-events: none;
    }
  }

  &-cell-fix-left-last::after {
    right: 0;
    transform: translateX(100%);
  }

  &-cell-fix-right-first::after {
    left: 0;
    transform: translateX(-100%);
  }

  &-scroll-position-right &-cell-fix-left-last::after,
  &-scroll-position-middle &-cell-fix-left-last::after {
    box-shadow: inset 0.06rem 0 0.06rem -0.04rem @shadow-color;
  }

  &-scroll-position-left &-cell-fix-right-first::after,
  &-scroll-position-middle &-cell-fix-right-first::after {
    box-shadow: inset -0.06rem 0 0.06rem -0.04rem @shadow-color;
  }

  &-bordered {
    &.@{table-prefix-cls},
    .@{table-prefix-cls}-filter-bar {
      border-left: @table-border;
    }

    .@{table-prefix-cls}-content,
    .@{table-prefix-cls}-filter-bar,
    .@{table-prefix-cls}-head,
    //.@{table-prefix-cls}-body,
    .@{table-prefix-cls}-foot,
    .@{table-prefix-cls}-empty-row {
      border-right: @table-border;
    }

    .@{table-prefix-cls}-footer {
      padding-right: @table-padding-horizontal;
      padding-left: @table-padding-horizontal;
      border-bottom: @table-border;
    }

    .@{table-prefix-cls}-thead,
    .@{table-prefix-cls}-tfoot {
      .@{table-prefix-cls}-cell:last-child {
        border-right: @table-border;
      }
    }

    .@{table-prefix-cls}-thead {
      border-bottom: none;
    }

    .@{table-prefix-cls}-tfoot .@{table-prefix-cls}-cell {
      border-right: @table-border;
      border-bottom: @table-border;
    }

    .@{table-prefix-cls}-cell,
    .@{table-prefix-cls}-cell[colspan] {
      border-right: @table-border;
      border-bottom: @table-border;
    }

    .@{table-prefix-cls}-cell-inner {
      border: @border-width-base @border-style-base transparent;
    }

    .@{table-prefix-cls}-tbody {
      .@{table-prefix-cls}-cell:last-child {
        border-right: @border-width-base @border-style-base transparent;
      }
    }
    .@{table-prefix-cls}-fixed-left .@{table-prefix-cls}-tbody {
      .@{table-prefix-cls}-cell:last-child {
        border-right: @border-width-base @border-style-base @border-color-base;
      }
    }
  }

  &-scroll-position-middle {
    .@{table-prefix-cls}-tfoot,
    .@{table-prefix-cls}-cell-fix-left-last {
      border-right: @border-width-base @border-style-base transparent;
    }
  }

  &-resizer {
    position: absolute;
    top: 0;
    width: 0.05rem;
    height: 100%;
    cursor: col-resize;
    user-select: none;

    &-left {
      left: @border-width-base / -2;
    }

    &-right {
      right: @border-width-base / -2;
    }
  }

  &-split-line {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 3;
    display: none;
    width: 0.01rem;
    background-color: @table-split-color;
  }

  &-resizing {
    user-select: none;

    .@{table-prefix-cls}-split-line {
      display: block;
    }
  }

  //ROW
  &-empty-row div {
    display: inline-block;
    transform: translateX(-50%);
  }

  &-parity-row &-row:nth-child(even) > td {
    background-color: @table-even-row-bg;
  }

  &-expanded-row > td {
    background-color: @table-expanded-row-bg;
    border-bottom: @table-border;
  }

  &-row-mouse-batch-choose {
    background-color: @table-mouse-batch-choose-bg;
  }

  &-row:hover,
  &-row-hover,
  &-parity-row &-row:nth-child(even):hover,
  &-parity-row &-row-hover:nth-child(even) {
    &,
    & + .@{table-prefix-cls}-expanded-row {
      & > td {
        background-color: @table-row-hover-bg;
      }
    }
  }

  &-row-current,
  &-row-current:hover,
  &-parity-row &-row-current:nth-child(even) {
    &.@{table-prefix-cls}-row-highlight,
    &.@{table-prefix-cls}-row-highlight + .@{table-prefix-cls}-expanded-row {
      & > td {
        background-color: @table-current-row-bg;
      }
    }
  }

  &-row-clicked,
  &-row-clicked:hover,
  &-parity-row &-row-clicked:nth-child(even) {
    &.@{table-prefix-cls}-row-highlight,
    &.@{table-prefix-cls}-row-highlight + .@{table-prefix-cls}-expanded-row {
      & > td {
        background-color: @table-current-row-bg;
      }
    }
  }

  &-row-selected&-row:hover,
  &-parity-row &-row-selected&-row:nth-child(even):hover {
    &,
    & + .@{table-prefix-cls}-expanded-row {
      & > td {
        background-color: @item-active-bg;
      }
    }
  }

  &-row-selected,
  &-parity-row &-row-selected:nth-child(even) {
    &,
    & + .@{table-prefix-cls}-expanded-row {
      & > td {
        background-color: @table-selected-row-bg;
      }
    }
  }

  &-cell-editable &-cell-inner {
    border-color: @table-editable-cell-border-color;
  }

  &-cell-editable&-cell-required &-cell-inner {
    background-color: @table-editable-cell-required-bg;
  }

  &-cell-editable .@{output-prefix-cls}-invalid {
    border-color: @error-color;
  }

  &-cell-editable&-cell-required .@{output-prefix-cls}-invalid {
    background-color: @error-bg-color;
  }

  &-row:last-child &-cell {
    border-bottom: none;
  }

  &-last-row-bordered &-row:last-child &-cell {
    border-bottom: @table-border;
  }

  &-row-disabled > td {
    color: @disabled-color !important;
    background-color: @disabled-bg !important;

    .@{c7n-pro-prefix}-btn {
      color: @disabled-color !important;
    }

    &:not(.@{table-prefix-cls}-selection-column) .@{table-prefix-cls}-cell-inner::before {
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
      z-index: 100;
      content: ' ';
    }
  }

  &-toolbar {
    padding-bottom: 0.1rem;
    overflow: hidden;

    &-button-group {
      display: inline-block;
      vertical-align: middle;
    }

    button span {
      font-weight: 500;
    }
  }

  &-summary-group {
    display: inline-flex;
    flex-wrap: wrap;
    float: left;
    vertical-align: middle;
    background: #FFF6EA;
    border-radius: 0.02rem;
  }

  &-summary-menu-item {
    padding: 0 !important;

    button {
      height: 0.4rem;
      padding: 0 0.26rem;
    }
  }

  &-summary-button-more {
    width: 0.7rem;
    font-size: 0.12rem;
    line-height: 0.3rem;
    letter-spacing: 0;
    text-align: center;

    a {
      color: #5A6677;
    }

    i {
      vertical-align: text-bottom;
    }
  }

  &-summary-col {
    display: inline-flex;
    flex-shrink: 0;
    width: 1.7rem;
    height: 0.3rem;
    padding: 0 0.16rem;
    line-height: 0.3rem;

    div {
      font-size: 0.12rem;
      letter-spacing: 0;
    }

    &-label {
      width: 0.72rem;
      overflow: hidden;
      color: #5A6677;
      white-space: nowrap;
      text-align: left;
      text-overflow: ellipsis;
    }

    &-value {
      width: calc(100% - 0.72rem);
      overflow: hidden;
      color: #F7A835;
      white-space: nowrap;
      text-align: right;
      text-overflow: ellipsis;
    }

    &-separate {
      display: inline-block;
      width: 0.01rem;
      height: 0.3rem;
      vertical-align: top;
      background-color: #fef6e9;

      div {
        display: inline-block;
        width: 0.01rem;
        height: 0.12rem;
        margin-top: 0.1rem;
        background: rgba(87, 102, 121, 0.40);
      }
    }
  }

  &-query-bar {
    float: right;

    > * + * {
      margin-left: 0.16rem;
    }

    &-dirty-info {
      display: inline-block;
      height: @input-height-base;
      padding: 0 0.12rem;
      line-height: 2;
      vertical-align: middle;
      background-color: @background-color-light;
      border-radius: @border-radius-base;

      > * {
        vertical-align: middle;

        & + * {
          margin-left: 0.05rem;
        }
      }

      .@{iconfont-css-prefix} {
        color: @yellow-6;
      }
    }

    input {
      font-weight: 500;
    }
  }

  &-advanced-query-bar {
    padding: 0.12rem 0;

    &-button {
      display: inline-block;
      vertical-align: middle;
    }

    &-options .@{table-prefix-cls}-filter-select {
      padding-right: 0 !important;
      padding-left: 1.2rem !important;
      border-top-style: dashed !important;
      cursor: default;

      &-prefix {
        width: 1.2rem;
        line-height: 1.5;
        text-align: left;
      }
    }
  }

  &-dynamic-filter-bar {
    input::-webkit-input-placeholder { // 谷歌
      color: #6A6A6A;
    }

    input:-moz-placeholder { //火狐
      color: #6A6A6A;
    }

    input::-moz-placeholder {
      color: #6A6A6A;
    }

    input:-ms-input-placeholder { //微软
      color: #6A6A6A;
    }

    .@{c7n-pro-prefix}-input-number-placeholder, .@{c7n-pro-prefix}-select-placeholder {
      color: #6A6A6A;
    }
  }

  &-dynamic-filter-bar-suffix {
    display: inline-block;
    border-left: @table-border;
  }

  &-dynamic-filter-toolbar {
    padding-top: 0.1rem;
    text-align: right;

    .@{table-prefix-cls}-toolbar {
      text-align: right;

      .@{table-prefix-cls}-dynamic-filter-bar-suffix {
        margin-left: 0.16rem;
      }
    }

    .@{table-prefix-cls}-columns-chooser {
      display: inline-block;
      width: auto;
      margin-left: 0.16rem;
      border-left: none;

      button {
        margin: 0 0.05rem;
      }

      button:not(:last-child) {
        margin-right: 0.05rem;
      }
    }
  }

  &-filter-menu {
    .@{c7n-pro-prefix}-select {
      //width: 0.9rem;
      min-width: 0.9rem;
      max-width: 2rem;
      margin: 0;
      border: none;

      &-clear-button-flat {
        right: 0;
        background: #fff;
      }
    }

    &-expand {
      color: @primary-color;
      cursor: pointer;
    }
  }

  &-filter-content {
    display: flex;
    flex-shrink: 0;
  }


  &-filter-wrapper {
    display: inline-flex;
    flex-wrap: wrap;
    width: calc(100% - 2.3rem);
    margin: 0.06rem 0 0;
  }

  &-add-fields {
    display: flex;
    align-items: center;
    color: @primary-color;
    cursor: pointer;
  }

  &-filter-rest-buttons {
    display: inline-flex;
    align-items: center;
    float: right;
    height: 0.36rem;

    button {
      margin-right: 0.08rem;
    }
  }

  &-filter-buttons {
    position: relative;
    top: 0.36rem;
    float: right;
    width: 2.3rem;
    vertical-align: top;

    button {
      float: right;
      margin: 0 0 0 0.08rem;
    }
  }

  &-filter-modal-item {
    font-size: 12px;

    &:not(:last-child) {
      margin-bottom: 0.2rem;
    }

    &-label {
      margin-left: 0.06rem;
      vertical-align: middle;
    }
  }

  &-filter-menu-option {
    display: flex;

    &:hover {
      i {
        display: inline-block;
      }
    }

    &-icons {
      margin-left: auto;

      i {
        display: none;
        margin-left: 0.08rem;
        font-size: 0.15rem;
      }

      .icon-delete_forever-o {
        color: @error-color;
      }

      .icon-star {
        color: @primary-color;
      }
    }
  }

  &-filter-label {
    display: flex;
    align-items: center;
    height: @input-height-base;
    margin-right: 0.02rem;
    padding-top: 0.005rem;
    color: #6A6A6A;
    font-size: 0.12rem;
  }

  &-filter-search {
    display: flex;
    width: 2rem;
    font-size: 0.12rem;

    i {
      height: 0.2rem;
      font-size: 0.15rem;
      line-height: 0.2rem;
    }
  }

  &-filter-item {
    display: flex;
    margin-right: 0.32rem;
    font-size: 0.12rem;

    &-label {
      input::-webkit-input-placeholder { // 谷歌
        color: transparent;
      }

      input:-moz-placeholder { //火狐
        color: transparent;
      }

      input::-moz-placeholder {
        color: transparent;
      }

      input:-ms-input-placeholder { //微软
        color: transparent;
      }

      .@{c7n-pro-prefix}-input-number-placeholder, .@{c7n-pro-prefix}-select-placeholder {
        color: transparent;
      }
    }

    //&:hover {
    //  background-color: @background-color-light;
    //}

    i {
      //height: 0.2rem;
      font-size: 0.15rem;
      line-height: 0.2rem;
    }

    &-close {
      display: flex;
      align-items: center;
      color: #D5DAE0;
      cursor: pointer;

      &:hover {
        color: #6A6A6A;
      }
    }

    .@{c7n-pro-prefix}-input-number-plus, .@{c7n-pro-prefix}-input-number-minus {
      height: 0.14rem;
      line-height: 0.14rem;
    }

    .@{c7n-pro-prefix}-checkbox-inner {
      top: 0.08rem;
      width: 0.12rem;
      height: 0.12rem;

      &::after {
        width: 0.05rem;
        height: 0.1rem;
      }
    }

    .@{c7n-pro-prefix}-select-trigger {
      font-size: 0.15rem;
    }

    .@{c7n-pro-prefix}-select, .@{c7n-pro-prefix}-input, .@{c7n-pro-prefix}-input-number, .@{c7n-pro-prefix}-calendar-picker {
      width: auto;
      min-width: unset;
      //max-width: 2rem;
      margin: 0;
      padding: 0.02rem;
      border: none;

      &-required {
        background-color: #fff;

        & > label::before { // 谷歌
          display: inline-block;
          width: .08rem;
          margin-left: .04rem;
          color: #d50000;
          font-family: SimSun, sans-serif;
          //line-height: 1;
          vertical-align: middle;
          content: "*";
        }

        .@{c7n-pro-prefix}-input-number-placeholder, .@{c7n-pro-prefix}-select-placeholder {
          &::before {
            display: inline-block;
            width: .08rem;
            margin-left: .04rem;
            color: #d50000;
            font-family: SimSun, sans-serif;
            //line-height: 1;
            vertical-align: middle;
            content: "*";
          }
        }
      }

      &-multiple {
        & > label::before { // 谷歌
          content: "";
        }
      }

      &-invalid {
        input::-webkit-input-placeholder { // 谷歌
          color: @error-color;
        }

        input:-moz-placeholder { //火狐
          color: @error-color;
        }

        input::-moz-placeholder {
          color: @error-color;
        }

        input:-ms-input-placeholder { //微软
          color: @error-color;
        }

        .@{c7n-pro-prefix}-input-number-placeholder, .@{c7n-pro-prefix}-select-placeholder {
          color: @error-color;
        }
      }
    }

    .@{c7n-pro-prefix}-select-suffix-button .@{c7n-pro-prefix}-select-inner-button {
      right: 0.18rem;
    }

    .@{c7n-pro-prefix}-select-multiple-block > div:not(:last-child) {
      max-width: calc(100% - 0.2rem);
    }

    .@{c7n-pro-prefix}-input-number-multiple-block > div:not(:last-child) {
      max-width: calc(100% - 0.2rem);
    }
  }

  &-professional-query-bar {
    display: flex;
    padding: 0.06rem 0;

    .@{c7n-pro-prefix}-field-label, .@{c7n-pro-prefix}-field-wrapper {
      padding: 0.1rem 0.02rem;

      .@{c7n-pro-prefix}-checkbox-wrapper {
        vertical-align: sub;
      }
    }

    &-button {
      display: inline-flex;
      flex-grow: 1;
      flex-shrink: 0;
      align-items: flex-start;
      justify-content: flex-end;
      padding: 0.1rem 0 0.1rem 0.7rem;

      span {
        vertical-align: baseline;
      }
    }
  }

  &-professional-toolbar {
    padding-top: 0.1rem;
    text-align: right;
  }

  &-pagination {
    margin: 0.1rem 0 0 0;
    text-align: right;

    &-with-selection-tips {
      display: flex;
      align-items: center;
      justify-content: flex-end;
    }
  }

  &-selection-tips {
    display: flex;
    flex: 1;
    align-items: center;
    text-align: left;

    .@{table-prefix-cls}-switch {
      float: none;
      margin-left: .1rem;
    }

    b {
      font-weight: 500;
    }
  }

  &-switch {
    float: left;
  }

  col {
    transition: width 0.3s;
  }

  &-sort-icon,
  &-help-icon {
    margin-right: 0.03rem;
    margin-left: 0.03rem;
  }

  &-sort-icon {
    color: rgba(0, 0, 0, 0.45);
    font-weight: normal;
    opacity: 0;
  }

  &-help-icon {
    color: @primary-color;
  }

  &-sort {
    &-asc &-icon,
    &-desc &-icon {
      color: inherit;
      opacity: 1;
    }

    &-desc &-icon {
      transform: rotate(180deg);
    }
  }

  &:not(&-resizing) &-thead &-cell-inner:hover &-sort-icon {
    opacity: 1;
  }

  &-expand-icon {
    border: @border-width-base @border-style-base transparent;
    cursor: pointer;
    transition: transform 0.3s;

    &:focus {
      color: @primary-color;
      outline: none;
      transform: scale(1.4);
    }

    &-expanded {
      transform: rotate(90deg);

      &:focus {
        transform: rotate(90deg) scale(1.4);
      }
    }

    &-spaced {
      visibility: hidden;
    }

    & + .@{c7n-pro-prefix}-checkbox {
      margin-left: @table-padding-horizontal;
    }
  }

  &-columns-chooser {
    width: 0.65rem;
    border-left: @table-border;

    &-dropdown-menu {
      .dropdown-menu;
      min-width: 1.8rem;
    }
  }
}
