/**
* Copyright (c) 2022 - present TinyVue Authors.
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

@import '../mixins/transfer.less';
@import '../custom.less';
@import './vars.less';

@transfer-prefix-cls: ~'@{css-prefix}transfer';
@transfer-panel-prefix-cls: ~'@{css-prefix}transfer-panel';
@checkbox-prefix-cls: ~'@{css-prefix}checkbox';
@checkbox-group-prefix-cls: ~'@{css-prefix}checkbox-group';
@input-prefix-cls: ~'@{css-prefix}input';
@table-prefix-cls: ~'@{css-prefix}table';
@pager-prefix-cls: ~'@{css-prefix}pager';
@button-prefix-cls: ~'@{css-prefix}button';
@svg-prefix-cls: ~'@{css-prefix}svg';
@tree-node-prefix-cls: ~'@{css-prefix}tree-node';
@tree-prefix-cls: ~'@{css-prefix}tree';

.@{transfer-prefix-cls} {
  .component-css-vars-transfer();

  display: flex;
  justify-content: flex-start;
  align-items: center;
  font-size: var(--ti-transfer-font-size);

  &__buttons {
    padding-left: var(--ti-transfer-buttons-padding-left);
    padding-right: var(--ti-transfer-buttons-padding-right);
    padding-top: var(--ti-transfer-buttons-padding-top);
    padding-bottom: var(--ti-transfer-buttons-padding-bottom);

    .defaultButton {
      display: flex;
      flex-direction: column;

      .@{button-prefix-cls} + .@{button-prefix-cls} {
        margin-left: var(--ti-transfer-buttons-defaultButton-margin-left);
      }

      & + .@{button-prefix-cls} {
        margin-right: var(--ti-transfer-buttons-defaultButton-margin-right);
        margin-top: var(--ti-transfer-buttons-defaultButton-margin-top);
        margin-bottom: var(--ti-transfer-buttons-defaultButton-margin-bottom);
      }
    }

    .@{button-prefix-cls} {
      min-width: auto;
      margin-left: var(--ti-transfer-buttons-margin-left);
      margin-right: var(--ti-transfer-buttons-margin-right);
      margin-top: var(--ti-transfer-buttons-margin-top);
      margin-bottom: var(--ti-transfer-buttons-margin-bottom);
    }
  }

  &__button {
    display: block;
    margin-left: var(--ti-transfer-button-margin-left);
    margin-right: var(--ti-transfer-button-margin-right);
    margin-top: var(--ti-transfer-button-margin-top);
    margin-bottom: var(--ti-transfer-button-margin-bottom);
    border-color: var(--ti-transfer-button-bg-color);
    background-color: var(--ti-transfer-button-bg-color);
    min-width: 30px;
    min-height: 30px;
    border-radius: var(--ti-transfer-button-border-radius);
    line-height: normal;
    padding-left: var(--ti-transfer-button-padding-left);
    padding-right: var(--ti-transfer-button-padding-right);
    padding-top: var(--ti-transfer-button-padding-top);
    padding-bottom: var(--ti-transfer-button-padding-bottom);

    &.is-with-texts {
      border-radius: var(--ti-transfer-button-border-radius);
      min-width: 60px;
    }

    &.@{button-prefix-cls}:not(.is-circle) .@{svg-prefix-cls} {
      margin-right: 0;
    }

    &:first-child {
      margin-bottom: var(--ti-transfer-first-button-margin-bottom);
    }

    &:nth-child(2) {
      margin: 0;
    }

    i,
    span {
      font-size: var(--ti-transfer-font-size);
    }

    [class*='tiny-icon'] + span {
      margin-left: 0;
    }
  }

  & &__button {
    &.is-disabled,
    &.is-disabled:hover {
      border: 1px solid var(--ti-transfer-button-disabled-border-color);
      background-color: var(--ti-transfer-button-disabled-bg-color);
      color: var(--ti-transfer-button-disabled-text-color);
      line-height: var(--ti-transfer-button-disabled-line-height);

      .@{svg-prefix-cls} {
        fill: var(--ti-transfer-button-disabled-text-color);
      }
    }
  }
}

.@{transfer-panel-prefix-cls} {
  border: 1px solid var(--ti-transfer-panel-border-color);
  border-radius: var(--ti-transfer-panel-border-radius);
  overflow: hidden;
  background: var(--ti-transfer-panel-bg-color);
  width: var(--ti-transfer-panel-width);
  max-height: 100%;
  vertical-align: middle;
  box-sizing: border-box;
  position: relative;

  &__body {
    position: relative;
    height: var(--ti-transfer-panel-body-height);
    text-align: left;
    padding-right: var(--ti-transfer-panel-body-padding-right);

    &.is-with-footer {
      padding-bottom: var(--ti-transfer-panel-body-footer-padding-bottom);
      height: var(--ti-transfer-panel-body-footer-height);
    }

    .@{tree-prefix-cls} {
      height: var(--ti-transfer-panel-body-tree-height);
      padding-left: var(--ti-transfer-panel-body-tree-padding-left);
      padding-right: var(--ti-transfer-panel-body-tree-padding-right);
      padding-top: var(--ti-transfer-panel-body-tree-padding-top);
      padding-bottom: var(--ti-transfer-panel-body-tree-padding-bottom);
      overflow: auto;
      .transfer-scrollbar(8px);
    }

    .@{transfer-panel-prefix-cls}__filter ~ .@{tree-prefix-cls} {
      height: var(--ti-transfer-panel-body-tree-filter-height);
    }
  }

  &__list {
    margin-left: var(--ti-transfer-panel-body-list-margin-left);
    margin-right: var(--ti-transfer-panel-body-list-margin-right);
    margin-top: var(--ti-transfer-panel-body-list-margin-top);
    margin-bottom: var(--ti-transfer-panel-body-list-margin-bottom);
    padding-left: var(--ti-transfer-panel-body-list-padding-left);
    padding-right: var(--ti-transfer-panel-body-list-padding-right);
    padding-top: var(--ti-transfer-panel-body-list-padding-top);
    padding-bottom: var(--ti-transfer-panel-body-list-padding-bottom);
    list-style: none;
    height: var(--ti-transfer-panel-body-height);
    overflow: auto;
    box-sizing: border-box;
    display: block;

    &.@{checkbox-group-prefix-cls} {
      display: block;
    }

    &.is-filterable {
      height: var(--ti-transfer-panel-body-filter-height);
      padding-top: var(--ti-transfer-panel-body-filter-padding-top);
      display: flex;
      flex-direction: column;

      .@{transfer-panel-prefix-cls}__item {
        @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
          flex-shrink: 0;
        }
      }
    }
  }

  & &__list {
    .transfer-scrollbar(8px);
  }

  &__item {
    line-height: var(--ti-transfer-panel-item-height);
    padding-left: var(--ti-transfer-panel-item-padding-left);
    display: flex;
    transition: all 0.5s;

    & + & {
      margin-left: 0;
      display: flex;
    }

    &.@{checkbox-prefix-cls} {
      color: var(--ti-transfer-panel-item-text-color);
      line-height: var(--ti-transfer-panel-item-height);
      margin: 0;
      display: flex;

      &.@{checkbox-prefix-cls}__label {
        width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: block;
        box-sizing: border-box;
        padding-left: var(--ti-transfer-panel-item-checkbox-padding-left);
        line-height: var(--ti-transfer-panel-item-height);
      }

      .@{checkbox-prefix-cls}__input {
        line-height: 1;
      }
    }

    &:hover {
      background: var(--ti-transfer-panel-item-hover-bg-color);
      color: var(--ti-transfer-panel-item-hover-text-color);
    }

    &.is-disabled:hover {
      background: 0;
    }

    &.@{checkbox-prefix-cls}__input {
      position: absolute;
      top: 7px;
    }
  }

  &__filter {
    text-align: center;
    padding-left: var(--ti-transfer-panel-filter-padding-left);
    padding-right: var(--ti-transfer-panel-filter-padding-right);
    padding-top: var(--ti-transfer-panel-filter-padding-top);
    padding-bottom: var(--ti-transfer-panel-filter-padding-bottom);
    box-sizing: border-box;
    display: block;
    width: auto;

    .@{input-prefix-cls}__inner {
      height: var(--ti-transfer-panel-filter-height);
      line-height: var(--ti-transfer-panel-filter-height);
      width: 100%;
      font-size: var(--ti-transfer-panel-filter-font-size);
      display: inline-block;
      box-sizing: border-box;
      border-radius: var(--ti-transfer-panel-filter-border-radius);
      padding-right: var(--ti-transfer-panel-filter-input-padding-right);
      padding-left: var(--ti-transfer-panel-filter-input-padding-left);
    }

    .@{input-prefix-cls}__icon {
      margin-left: 5px;
    }

    .@{css-prefix}icon-circle-close {
      cursor: pointer;
    }
  }

  & &__header {
    height: var(--ti-transfer-header-height);
    line-height: var(--ti-transfer-header-height);
    background: var(--ti-transfer-header-bg-color);
    margin-left: var(--ti-transfer-header-margin-left);
    margin-right: var(--ti-transfer-header-margin-right);
    margin-top: var(--ti-transfer-header-margin-top);
    margin-bottom: var(--ti-transfer-header-margin-bottom);
    padding-left: var(--ti-transfer-header-padding-left);
    padding-right: var(--ti-transfer-header-padding-right);
    padding-top: var(--ti-transfer-header-padding-top);
    padding-bottom: var(--ti-transfer-header-padding-bottom);
    border-bottom: 1px solid var(--ti-transfer-header-border-color);
    box-sizing: border-box;
    color: var(--ti-transfer-header-text-color);
    position: relative;
    display: flex;
    justify-content: flex-start;
    align-items: center;

    .@{checkbox-prefix-cls} {
      width: 100%;
      line-height: 1;
      text-align: left;

      .@{checkbox-prefix-cls}__label {
        font-size: var(--ti-transfer-header-font-size);
        color: var(--ti-transfer-header-text-color);
        font-weight: 400;
        width: calc(100% - 38px);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;

        span {
          position: absolute;
          right: 0;
          color: var(--ti-transfer-header-span-text-color);
          font-size: var(--ti-transfer-header-font-size);
          font-weight: var(--ti-transfer-header-span-font-weight);
        }
      }
    }

    .headSort {
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translateY(-50%);

      div {
        width: var(--ti-transfer-header-sort-width);
        height: var(--ti-transfer-header-sort-width);
        line-height: var(--ti-transfer-header-sort-width);
        margin-right: var(--ti-transfer-header-sort-margin-right);
        text-align: center;
        border: 1px solid;
        border-radius: var(--ti-transfer-header-sort-border-radius);
        color: var(--ti-transfer-header-sort-text-color);
        display: inline-block;
        cursor: pointer;

        i {
          width: calc(var(--ti-transfer-header-sort-width) - 2px);
          height: calc(var(--ti-transfer-header-sort-width) - 2px);
          display: block;
        }
      }
    }
  }

  & &__footer {
    height: var(--ti-transfer-footer-height);
    background: var(--ti-transfer-footer-bg-color);
    margin-left: var(--ti-transfer-footer-margin-left);
    margin-right: var(--ti-transfer-footer-margin-right);
    margin-top: var(--ti-transfer-footer-margin-top);
    margin-bottom: var(--ti-transfer-footer-margin-bottom);
    padding-left: var(--ti-transfer-footer-padding-left);
    padding-right: var(--ti-transfer-footer-padding-right);
    padding-top: var(--ti-transfer-footer-padding-top);
    padding-bottom: var(--ti-transfer-footer-padding-bottom);
    border-top: 1px solid var(--ti-transfer-footer-border-color);
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1;

    &::after {
      display: inline-block;
      content: '';
      height: 100%;
      vertical-align: middle;
    }

    .@{checkbox-prefix-cls} {
      padding-left: var(--ti-transfer-footer-checkbox-padding-left);
    }
  }

  & &__empty {
    position: absolute;
    width: 100%;
    top: calc(50% - 33px);
    margin: 0;
    height: var(--ti-transfer-empty-height);
    line-height: var(--ti-transfer-empty-height);
    padding-left: var(--ti-transfer-empty-padding-left);
    padding-right: var(--ti-transfer-empty-padding-right);
    padding-top: var(--ti-transfer-empty-padding-top);
    padding-bottom: var(--ti-transfer-empty-padding-bottom);
    color: var(--ti-transfer-empty-text-color);
    text-align: center;
  }

  &.transferGrid {
    width: 600px;

    .@{transfer-panel-prefix-cls}__body {
      height: 100%;
    }

    .@{table-prefix-cls}.simple {
      width: 100%;
      padding-left: var(--ti-transfer-table-padding-left);
      padding-right: var(--ti-transfer-table-padding-right);
      padding-top: var(--ti-transfer-table-padding-top);
      padding-bottom: var(--ti-transfer-table-padding-bottom);
      height: 400px;
      overflow-y: auto;

      table {
        width: 100%;
      }
    }

    .@{pager-prefix-cls} {
      padding-left: var(--ti-transfer-pager-padding-left);
      padding-top: var(--ti-transfer-pager-padding-top);
      padding-bottom: var(--ti-transfer-pager-padding-bottom);
      padding-right: var(--ti-transfer-pager-padding-right);
    }
  }

  .@{checkbox-prefix-cls}__label {
    padding-left: var(--ti-transfer-checkbox-label-padding-left);
  }
}
