@import "mixins/mixins";
@import "common/var";
@import "common/transition";
@import "checkbox";

@include b(tree) {
  position: relative;
  cursor: default;
  background: $--color-white;
  color: $--color-black-65;
  max-height: $--tree-box-height;
  width: 180px;
  border:1px solid $--input-disabled-border;
  border-radius: $--border-radius-base;
  overflow: hidden;

  .xb-tree__wrap{
    max-height: $--tree-box-height;
  }

  @include e(empty-block) {
    position: relative;
    min-height: 60px;
    text-align: center;
    width: 100%;
    height: 100%;
  }

  @include e(empty-text) {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: $--color-text-secondary;
    font-size: $--font-size-base;
  }

  @include e(drop-indicator) {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    @include theme-bg-color;
  }
}

@include b(tree-node) {
  white-space: nowrap;
  outline: none;
  &:focus {
    > .xb-tree-node__content {
      @include select-option-hover-bg;
      @include theme-font-color;
    }
  }

  @include when(drop-inner) {
    > .xb-tree-node__content .xb-tree-node__label {
      color: #fff;
    }
  }

  @include e(content) {
    display: flex;
    align-items: center;
    height: 32px;
    cursor: pointer;
    padding:0 10px;

    & > .xb-tree-node__expand-icon {
      padding: 6px;
    }
    & > label.xb-checkbox {
      margin-right: 8px;
    }
    & > label.xb-checkbox.is-disabled + .xb-tree-node__label {
      color: $--color-text-disabled;
      cursor: not-allowed;
    }
    &:hover {
      @include select-option-hover-bg;
      @include theme-font-color;
    }

    .xb-tree.is-dragging & {
      cursor: move;

      & * {
        pointer-events: none;
      }
    }

    .xb-tree.is-dragging.is-drop-not-allow & {
      cursor: not-allowed;
    }
  }

  @include e(expand-icon) {
    cursor: pointer;
    color: $--color-black-65;
    font-size: 12px;

    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;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  @include e(loading-icon) {
    margin-right: 8px;
    font-size: $--font-size-base;
    color: $--color-black-45;
  }

  & > .xb-tree-node__children {
    overflow: hidden;
    background-color: transparent;
  }

  &.is-expanded > .xb-tree-node__children {
    display: block;
  }
}

.xb-tree--highlight-current .xb-tree-node.is-current > .xb-tree-node__content {
  // background-color: mix($--color-white, red, 92%);
}
