@import 'mixins/mixins';
@import 'common/var';
@import 'common/transition';
@import 'checkbox';

@include b(tree) {
  position: relative;
  cursor: default;
  background: $--color-white;
  color: $--tree-font-color;

  @include e(empty-block) {
    position: relative;
    padding: 6px 0;
    margin: 10px 0;
    text-align: center;
    font-size: $--font-size-base;
  }

  @include e(empty-text) {
    color: $--color-text-primary;
  }

  @include e(drop-indicator) {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background-color: $--color-primary;
  }

  @include when(line) {
    &.el-tree > .el-tree-node {
      padding-left: 0;
      &:after, &:before{
        display: none;
      }
    }
    .el-tree-node {
      position: relative;
      padding-left: 20px;
      &:before, &:after{
        content: "";
        left: -4px;
        position: absolute;
        right: auto;
        border-width: 1px;
      }
      &:before {
        border-left: 1px dashed $--border-color-base;
        bottom: 0px;
        height: 100%;
        top: -20px;
        width: 1px;
      }
      &:after {
        border-top: 1px dashed $--border-color-base;
        height: 20px;
        top: 17px;
        width: 16px;
      }
    }
    .el-tree-node__expand-icon.is-leaf{
      display: none;
    }
    .el-tree-node__children {
      padding-left: 16px;
    }
    .el-tree-node :last-child:before {
      height: 38px;
    }
  }

  @include m(medium) {
    .el-tree-node__content {
      height: 32px;
    }
  }
  @include m(small) {
    @include when(line) {
      .el-tree-node {
        &:before {
          top: -23px;
        }
        &:after {
          top: 15px;
        }
      }
    }
    .el-tree-node__content {
      font-size: 12px;
      height: 30px;
    }
    .el-tree-node__label {
      font-size: 12px;
    }
  }
  @include m(mini) {
    @include when(line) {
      .el-tree-node {
        &:before {
          top: -23px;
        }
        &:after {
          top: 14px;
        }
      }
    }
    .el-tree-node__content {
      font-size: 12px;
      height: 28px;
    }
    .el-tree-node__label {
      font-size: 12px;
    }
  }
}

@include b(tree-node) {
  white-space: nowrap;
  outline: none;

  &:focus > .el-tree-node__content{
    background-color: $--tree-node-hover-background-color;
  }

  @include when(drop-inner) {
    > .el-tree-node__content .el-tree-node__label {
      background-color: $--color-primary;
      color: $--color-white;
    }
  }

  @include e(content) {
    display: flex;
    align-items: center;
    height: 34px;
    cursor: pointer;

    & > .el-tree-node__expand-icon {
      padding: 6px;
    }
    & > label.el-checkbox {
      margin-right: 8px;
    }
    &:hover {
      background-color: $--tree-node-hover-background-color;
      color: $--select-option-hover--font-color;
      .el-tree-node__expand-icon {
        color: $--select-option-hover--font-color;
        &.is-leaf {
          color: transparent;
          cursor: default;
        }
      }
    }

    .el-tree.is-dragging & {
      cursor: move;

      & * {
        pointer-events: none;
      }
    }

    .el-tree.is-dragging.is-drop-not-allow & {
      cursor: not-allowed;
    }
  }

  @include e(expand-icon) {
    position: relative;
    top: 1px;
    cursor: pointer;
    color: $--tree-expand-icon-color;
    font-size: 10px;

    transform: rotate(0deg);
    transition: transform 0.3s ease-in-out;

    &.expanded {
      transform: rotate(90deg);
    }

    &.is-leaf {
      color: transparent;
      cursor: default;
    }
  }

  @include e(label) {
    font-size: $--font-size-base;
    &.is-ellipsis {
      width: 100%;
      display: inline-block;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    em {
      font-style: normal;
    }
  }

  @include e(loading-icon) {
    margin-right: 8px;
    font-size: $--font-size-base;
    color: $--tree-expand-icon-color;
  }

  & > .el-tree-node__children {
    overflow: hidden;
    background-color: transparent;
  }

  &.is-expanded > .el-tree-node__children {
    display: block;
  }
}

.el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {
  background-color: $--tree-node-hover-background-color;
  color: $--color-primary;
  .el-tree-node__expand-icon:not(.is-leaf) {
    color: $--color-primary;
  }
}
