@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';

@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-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;
  }

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

  &-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: ' ';
      }

      > * {
        vertical-align: middle;
      }
    }

    &-dirty {
      .@{table-prefix-cls}-cell-inner::after {
        position: absolute;
        top: 0;
        left: 0;
        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;
      }
    }
  }

  &-thead {
    border-bottom: @table-border;
  }

  &-thead &-cell,
  &-tfoot &-cell {
    position: relative;
    color: @heading-color;
    background-color: @table-header-bg;

    &:last-child {
      border-right: none;
    }
  }

  &-thead&-column-resizable {
    border-bottom: none;

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

  &-tbody &-cell {
    border-bottom: @table-border;
  }

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

  &-editor {
    position: absolute;
    left: -1000rem;
    z-index: 1;

    > * {
      display: block !important;
    }
  }

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

  &-head {
    overflow: hidden;
  }

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

  &-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}-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;
  }

  &-bordered {
    &.@{table-prefix-cls},
    .@{table-prefix-cls}-filter-bar {
      border-right: @table-border;
      border-left: @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;
      border-left: @table-border;
    }

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

    &:not(.@{table-prefix-cls}-scroll-position-left)
      .@{table-prefix-cls}-fixed-left
      .@{table-prefix-cls}-cell:last-child {
      border-right: none;
    }
  }

  &-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: 1;
    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%);
  }

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

  &-row-highlight&-row:hover,
  &-row-hover {
    &,
    & + .@{table-prefix-cls}-expanded-row {
      & > td {
        background-color: @table-row-hover-bg;
      }
    }
  }

  &-row-current,
  &-row-current:hover {
    &.@{table-prefix-cls}-row-highlight,
    &.@{table-prefix-cls}-row-highlight + .@{table-prefix-cls}-expanded-row {
      & > td {
        background-color: @table-current-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;
    }
  }

  &-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;
      }
    }
  }

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

  &-switch {
    float: left;
  }

  col {
    transition: width 0.3s;
  }

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

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

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

  &:not(&-resizing) &-thead .@{table-prefix-cls}-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;
    }
  }

  &-help-icon {
    margin-right: 0.03rem;
    margin-left: 0.03rem;
    color: @primary-color;
  }

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

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