@import "../../style/themes/default";
@import "../../style/mixins/index";
@import "../../checkbox/style/mixin";
@import "./mixin";
@import "./directory";

@tree-prefix-cls: ~"@{dt-prefix}-tree";
@tree-showline-icon-color: @text-color-secondary;

.antCheckboxFn(@checkbox-prefix-cls: ~"@{dt-prefix}-tree-checkbox");

.@{tree-prefix-cls} {
  .reset-component;
  font-size: @font-size-base;
  margin: 0;
  padding: 0;
  position: relative;

  ol, ul {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  li {
    padding: 4px 0;
    margin: 0;
    list-style: none;
    white-space: nowrap;
    outline: 0;

    // Tree with dragable
    span[draggable],
    span[draggable="true"] {
      user-select: none;
      /* Required to make elements draggable in old WebKit */
      -khtml-user-drag: element;
      -webkit-user-drag: element;
      &:before {
        border-top: 2px transparent solid;
        border-bottom: 2px transparent solid;
      }
    }

    &.drag-over {
      > span[draggable] {
        color: white;
        transition: color .3s;

        &:before {
          opacity: 0.8;
          background-color: @primary-color;
        }
      }
    }
    &.drag-over-gap-top {
      > span[draggable]:before {
        border-top-color: @primary-color;
      }
    }
    &.drag-over-gap-bottom {
      > span[draggable]:before {
        border-bottom-color: @primary-color;
      }
    }

    &.filter-node {
      > span {
        color: @highlight-color !important;
        font-weight: 500 !important;
      }
    }

    // When node is loading
    &.@{tree-prefix-cls}-treenode-loading {
      span {
        &.@{tree-prefix-cls}-switcher {
          &.@{tree-prefix-cls}-switcher_open,
          &.@{tree-prefix-cls}-switcher_close {
            &:before {
              display: inline-block;
              width: 24px;
              height: 24px;
              .iconfont-font(@icon-loading);
              animation: loadingCircle 1s infinite linear;
              color: @primary-color;
              transform: none;
              font-size: 14px;
            }

            :root &:after {
              opacity: 0;
            }
          }
        }
      }
    }

    ul {
      margin: 0;
      padding: 0 0 0 18px;
    }

    // to cover the bg
    .@{tree-prefix-cls}-switcher,
    .@{tree-prefix-cls}-checkbox {
      .improveRenderingOrder;
    }
    .@{tree-prefix-cls}-node-content-wrapper {
      display: inline-block;
      padding: 0 5px;
      margin: 0;
      cursor: pointer;
      text-decoration: none;
      vertical-align: top;
      color: #333;
      transition: all .3s;
      height: 24px;
      line-height: 24px;

      &:before {
        .antTreeBeforeForBackground;
      }
      & > span {
        // to create stacking context
        opacity: .999;
      }

      &:hover {
        .treeOptionHover();
      }
      &.@{tree-prefix-cls}-node-selected {
        &,
        &:hover {
          .treeOptionSelected();
        }
      }
    }
    span {
      &.@{tree-prefix-cls}-checkbox {
        margin: 4px 4px 0 2px;
      }
      &.@{tree-prefix-cls}-switcher,
      &.@{tree-prefix-cls}-iconEle {
        margin: 0;
        width: 24px;
        height: 24px;
        line-height: 24px;
        display: inline-block;
        vertical-align: middle;
        border: 0 none;
        cursor: pointer;
        outline: none;
        text-align: center;
      }
      &.@{tree-prefix-cls}-icon_loading {
        position: absolute;
        left: 0;
        top: 1px;
        background: #fff;
        transform: translateX(-100%);
        transition: all .3s;
        &:after {
          display: inline-block;
          .iconfont-font(@icon-loading);
          animation: loadingCircle 1s infinite linear;
          color: @primary-color;
        }
      }
      &.@{tree-prefix-cls}-switcher {
        position: relative;

        &.@{tree-prefix-cls}-switcher-noop {
          cursor: default;
        }
        &.@{tree-prefix-cls}-switcher_open {
          .antTreeSwitcherIcon();
        }
        &.@{tree-prefix-cls}-switcher_close {
          .antTreeSwitcherIcon();
          &:after {
            transform: rotate(270deg) scale(1);
          }
        }
      }
    }
    &:last-child > span {
      &.@{tree-prefix-cls}-switcher,
      &.@{tree-prefix-cls}-iconEle {
        &:before {
          display: none;
        }
      }
    }
  }
  > li {
    &:first-child {
      padding-top: 7px;
    }
    &:last-child {
      padding-bottom: 7px;
    }
  }
  &-child-tree {
    display: none;
    &-open {
      display: block;
    }
  }
  li&-treenode-disabled {
    > span:not(.@{tree-prefix-cls}-switcher),
    > .@{tree-prefix-cls}-node-content-wrapper,
    > .@{tree-prefix-cls}-node-content-wrapper span {
      color: @disabled-color;
      cursor: not-allowed;
    }
    > .@{tree-prefix-cls}-node-content-wrapper:hover {
      background: transparent;
    }
  }
  &-icon__open {
    margin-right: 2px;
    vertical-align: top;
  }
  &-icon__close {
    margin-right: 2px;
    vertical-align: top;
  }
  // Tree with line
  &&-show-line {
    li {
      position: relative;
      span {
        &.@{tree-prefix-cls}-switcher {
          color: @tree-showline-icon-color;
          &.@{tree-prefix-cls}-switcher-noop {
            .antTreeShowLineIcon("tree-doc-icon");
          }
          &.@{tree-prefix-cls}-switcher_open {
            .antTreeShowLineIcon("tree-showline-open-icon");
          }
          &.@{tree-prefix-cls}-switcher_close {
            .antTreeShowLineIcon("tree-showline-close-icon");
          }
        }
      }
    }
    li:not(:last-child):before {
      content: ' ';
      width: 1px;
      border-left: 1px solid @border-color-base;
      height: ~"calc(100% - 24px)";
      position: absolute;
      left: 12px;
      margin: 22px 0;
    }
  }

  &.@{tree-prefix-cls}-icon-hide {
    .@{tree-prefix-cls}-treenode-loading {
      .@{tree-prefix-cls}-iconEle {
        display: none;
      }
    }
  }

  &.@{tree-prefix-cls}-not-whole-row-hover {
    .@{tree-prefix-cls}-node-content-wrapper {
      position: relative;
    }
  }
}
