@import '../../helpers/mixin.scss';

.vxe-table-custom--option {
  display: flex;
  flex-direction: row;
}

.vxe-table-custom-wrapper {
  display: none;
  position: absolute;
  top: -4px;
  right: 2px;
  text-align: left;
  background-color: var(--vxe-ui-layout-background-color);
  z-index: 19;
  border: 1px solid var(--vxe-ui-table-border-color);
  border-radius: var(--vxe-ui-border-radius);
  box-shadow: var(--vxe-ui-base-popup-box-shadow);
  &.is--active {
    display: block;
  }
}

.vxe-table-custom--header,
.vxe-table-custom--body {
  list-style-type: none;
  overflow-x: hidden;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  user-select: none;
  & > li {
    max-width: 18em;
    min-width: 14em;
    padding: 0.2em 1em 0.2em 1em;
    @for $i from 2 through 8 {
      $interval: $i - 1 + 0.2;
      &.level--#{$i}{
        padding-left: #{$interval + 2.3}em;
        .vxe-checkbox--icon {
          left: #{$interval + 0.6}em;
        }
      }
    }
  }
}

.vxe-table-custom--header {
  padding: 0.28em 0;
  font-weight: 700;
  border-bottom: 1px solid var(--vxe-ui-base-popup-border-color);
}

.vxe-table-custom--body {
  padding: 0.2em 0;
  max-height: 20em;
  .vxe-table-custom--checkbox-option {
    &:hover {
      background-color: var(--vxe-ui-table-row-hover-background-color);
    }
  }
}

.vxe-table-custom--footer {
  border-top: 1px solid var(--vxe-ui-base-popup-border-color);
  text-align: right;
  button {
    background-color: transparent;
    width: 50%;
    height: 2.5em;
    border: 0;
    color: var(--vxe-ui-font-color);
    text-align: center;
    cursor: pointer;
    &:focus {
      outline: none;
    }
    &:hover {
      color: var(--vxe-ui-font-primary-color);
    }
  }
}

.vxe-table-custom--checkbox-option {
  @include createCheckboxIcon();
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-grow: 1;
}

.vxe-table-custom--fixed-option {
  flex-shrink: 0;
  padding-left: 0.5em;
  display: flex;
  flex-direction: row;
  align-items: center;
}

.vxe-table-custom--fixed-left-option,
.vxe-table-custom--fixed-right-option {
  line-height: 1.34em;
  font-size: 1.1em;
  padding: 0 0.2em;
  cursor: pointer;
  &.is--checked,
  &:hover {
    color: var(--vxe-ui-font-primary-color);
  }
  &.is--disabled {
    cursor: no-drop;
    color: var(--vxe-ui-input-disabled-color);
  }
}

.vxe-table-custom-popup--body {
  overflow: auto;
  height: 100%;
}

.vxe-table-custom-popup--table-wrapper {
  border-bottom: 1px solid var(--vxe-ui-table-border-color);
  table {
    width: 100%;
    border: 0;
    table-layout: fixed;
    word-break: break-all;
    border-spacing: 0;
    border-collapse: separate;
    th {
      position: sticky;
      top: 0;
      text-align: left;
      border-top: 1px solid var(--vxe-ui-table-border-color);
      border-bottom: 1px solid var(--vxe-ui-table-border-color);
      border-left: 1px solid var(--vxe-ui-table-border-color);
      background-color: var(--vxe-ui-table-header-background-color);
      z-index: 7;
    }
    td {
      border-top: 1px solid var(--vxe-ui-table-border-color);
      border-left: 1px solid var(--vxe-ui-table-border-color);
    }
    tr {
      &:first-child {
        td {
          border-top: 0;
        }
      }
      &:hover {
        background-color: var(--vxe-ui-table-row-hover-background-color);
      }
    }
    th,
    td {
      height: 44px;
      padding: 0 0.6em;
      &:last-child {
        border-right: 1px solid var(--vxe-ui-table-border-color);
      }
    }
  }
}

.vxe-table-custom-popup--drag-hint {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  padding: 0.6em 1em 0.6em 1.8em;
  max-width: 300px;
  border-radius: var(--vxe-ui-border-radius);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: none;
  pointer-events: none;
  background-color: var(--vxe-ui-layout-background-color);
  box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.2);
  z-index: 33;
}

.vxe-table-custom-popup--name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@for $index from 2 to 10 {
  $paddingLeft: ($index - 1) * 24px;
  .vxe-table-custom-popup--row {
    &.level--#{$index} {
      .vxe-table-custom-popup--name {
        padding-left: $paddingLeft;
      }
    }
  }
}

.vxe-table-custom-popup--column-item {
  position: relative;
  &.col--sort,
  &.col--visible,
  &.col--fixed {
    text-align: center;
  }
}

.vxe-table-custom-popup--row {
  &.active--drag-target {
    &[drag-pos="top"] {
      .vxe-table-custom-popup--column-item {
        &::after {
          display: block;
          top: -2px;
        }
      }
    }
    &[drag-pos="bottom"] {
      .vxe-table-custom-popup--column-item {
        &::after {
          display: block;
          bottom: -2px;
        }
      }
    }
  }
  &:first-child {
    &[drag-pos="top"] {
      .vxe-table-custom-popup--column-item {
        &::after {
          top: 0;
        }
      }
    }
  }
  &:last-child {
    &[drag-pos="bottom"] {
      .vxe-table-custom-popup--column-item {
        &::after {
          bottom: 0;
        }
      }
    }
  }
}

.vxe-table-custom-popup--column-item {
  &::after {
    display: none;
    content: "";
    position: absolute;
    left: -1px;
    width: calc(100% + 1px);
    height: 3px;
    background-color: var(--vxe-ui-font-primary-color);
    z-index: 12;
  }
  &:last-child {
    &::after {
      width: 100%;
    }
  }
}

.vxe-table-custom--list-move {
  transition: transform 0.35s;
}

.vxe-table-custom-popup--column-sort-btn {
  font-size: 1.2em;
  padding: 0.2em 0.5em;
  cursor: grab;
  &:active {
    cursor: grabbing;
  }
}

.vxe-table-custom-popup--table-sort-help-title,
.vxe-table-custom-popup--table-sort-help-icon {
  vertical-align: middle;
}
.vxe-table-custom-popup--table-sort-help-icon {
  margin-left: 5px;
  cursor: help;
}
