@use 'sass:math';
@use 'sass:map';

@use 'mixins/mixins' as *;
@use 'mixins/utils' as *;
@use 'mixins/var' as *;
@use 'common/var' as *;

@include b(unidirectionalTransfer) {
  @include set-component-css-var('transfer', $transfer);
}

@include b(unidirectionalTransfer) {
  font-size: getCssVar('font-size', 'base');

  @include e(buttons) {
    display: inline-block;
    vertical-align: middle;
    padding: 0 30px;
  }

  @include e(button) {
    vertical-align: top;

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

    i,
    span {
      font-size: 14px;
    }

    & .#{$namespace}-icon + span {
      margin-left: 0;
    }
  }
}

@include b(unidirectionalTransfer-panel) {
  overflow: hidden;
  background: getCssVar('bg-color', 'overlay');
  display: inline-block;
  text-align: left;
  vertical-align: middle;
  width: 280px;
  max-height: 100%;
  box-sizing: border-box;
  position: relative;
  & + .#{$namespace}-unidirectionalTransfer-panel {
    .#{$namespace}-unidirectionalTransfer-panel__header, .#{$namespace}-unidirectionalTransfer-panel__body {
      border-left: 0;  
    }
  }

  @include e(header) {
    display: flex;
    align-items: center;
    height: getCssVar('transfer-panel-header-height');
    background: getCssVar('transfer-panel-header-bg-color');
    margin: 0;
    padding-left: 15px;
    border: 1px solid getCssVar('transfer-border-color');
    box-sizing: border-box;
    color: getCssVar('color-black');

    .#{$namespace}-checkbox {
      position: relative;
      display: flex;
      width: 100%;
      align-items: center;

      .#{$namespace}-checkbox__label {
        font-size: 16px;
        color: getCssVar('text-color', 'primary');
        font-weight: normal;

        span {
          position: absolute;
          right: 15px;
          top: 50%;
          transform: translate3d(0, -50%, 0);
          color: getCssVar('text-color', 'primary');
          font-size: 14px;
          font-weight: normal;
        }
      }
    }
  } 

  @include e(body) {
    height: getCssVar('transfer-panel-body-height');
    border-left: 1px solid getCssVar('transfer-border-color');
    border-right: 1px solid getCssVar('transfer-border-color');
    border-bottom: 1px solid getCssVar('transfer-border-color');
    overflow-y: auto;
    padding: 8px 0;
  }
  @include e(body-left) {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    .#{$namespace}-tree {
      overflow-y: auto;  
    }
    .#{$namespace}-tree-node__expand-icon.is-leaf {
      display: none;
    }
      
    .#{$namespace}-tree-node__children .#{$namespace}-tree-node__expand-icon.is-leaf {
      display: block;
    }

    .#{$namespace}-tree-node__content {
      white-space: pre-wrap;
      height: auto;
      padding: 0 12px !important;
    }
    .#{$namespace}-tree-node__label {
      padding: 6px 0;
    }
  }
  @include e(list) {
    display: flex;
    justify-content: space-between;
    align-items: center;
    list-style: none;
    height: 32px;
    overflow: auto;
    box-sizing: border-box;
    padding: 0 12px;
    @include when(filterable) {
      height: calc(100% - getCssVar('transfer-filter-height') - 30px);
      padding-top: 0;
    }
    .#{$namespace}-icon {
      color: getCssVar('text-color', 'secondary');
      cursor: pointer;
      &:hover {
        color: getCssVar('text-color', 'primary');
      }
    }
  }

  @include e(item) {
    height: getCssVar('transfer-item-height');
    line-height: getCssVar('transfer-item-height');
    padding-left: 15px;
    display: block !important;

    & + .#{$namespace}-transfer-panel__item {
      margin-left: 0;
    }

    &.#{$namespace}-checkbox {
      color: getCssVar('text-color', 'regular');
    }

    &.#{$namespace}-checkbox .#{$namespace}-checkbox__label {
      width: 100%;
      @include utils-ellipsis;
      display: block;
      box-sizing: border-box;
      padding-left: 22px;
      line-height: getCssVar('transfer-item-height');
    }

    .#{$namespace}-checkbox__input {
      position: absolute;
      top: 8px;
    }
  }

  @include e(filter) {
    text-align: center;
    margin: 8px 12px;
    box-sizing: border-box;
    width: auto;

    .#{$namespace}-input__wrapper {
      height: getCssVar('transfer-filter-height');
      box-sizing: border-box;
      background: getCssVar('bg-color', 'active');
      box-shadow: 0 0 0 1px #dfe2e9 inset;
      &:focus {
        border-color: getCssVar('color', 'primary')
      }
    }
    input::-webkit-input-placeholder {
      color: #65789b;
    }

    .#{$namespace}-input__icon {
      color: getCssVar('color', 'primary');
      cursor: pointer;
    }

    .#{$namespace}-icon-circle-close {
      cursor: pointer;
    }
  }

}
