@import '../../style/variables.less';

.pro-tree-wrap-ellipse {
  display: block;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  word-break: keep-all;
}

.pro-tree {
  height: 100%; // tree auto css
  .@{ant-prefix}-tree-iconEle {
    margin-right: 8px;
  }

  .@{ant-prefix}-tree-node-content-wrapper {
    display: flex;
    align-items: baseline;
  }

  .@{ant-prefix}-tree .@{ant-prefix}-tree-treenode-disabled {
    .@{ant-prefix}-tree-node-content-wrapper {
      color: var(--zaui-text);
    }

    .pro-tree-tree-node.checked {
      color: var(--zaui-text);
    }

    .pro-tree-tree-node.checked .brand-bg-opa-ten {
      background-color: inherit;
    }
  }

  // 解决双滚动条
  .@{ant-prefix}-select-dropdown.pro-tree-select-drop-down-container.checkable-tree {
    overflow: hidden !important;
  }

  .@{ant-prefix}-spin-nested-loading {
    height: 100%; // tree auto css

    .@{ant-prefix}-spin-container {
      height: 100%; // tree auto css
    }
  }

  &-placeholder {
    color: #939499;
  }

  .pro-tree-search {
    margin-bottom: calc(var(--zaui-space-size-sm; 8px) * var(--zaui-size; 1));
  }

  &-content {
    display: flex; // tree auto css
    flex-direction: column; // tree auto css
    height: 100%;

    // overflow-y: scroll;
    .pro-tree-header-box,
    .pro-tree-footer-box {
      display: inline-flex;
      flex-direction: column;
    }

    .pro-tree-tree-warp {
      height: 100%;
      flex: 1 1;
      overflow-y: auto;
      overflow-x: auto;
      .@{ant-prefix}-tree-switcher:not(.@{ant-prefix}-tree-switcher-noop):hover:before {
        background-color: transparent;
      }
      .@{ant-prefix}-tree-checkbox {
        margin-top: 11px;
        align-self: flex-start;
      }
    }

    .tree-title-box {
      display: flex;
      padding-top: 10px;
      justify-content: space-between;

      .tree-title-text {
        font-size: var(--zaui-font-size-lg);
        margin-bottom: var(--zaui-space-size-xs);
        font-weight: 500;
        padding-left: 2px;
      }

      .expand-button {
        padding-left: var(--zaui-space-size-sm);
        display: flex;
        align-items: baseline;
        cursor: pointer;
        &.expand {
          .expand-icon {
            .anticon-caret-down {
              transform: rotate(180deg);
            }
          }
        }

        .expand-icon {
          font-size: var(--zaui-font-size-sm, 12px);
          margin-right: var(--zaui-space-size-xs);
        }
      }
    }

    .@{ant-prefix}-tree-switcher {
      line-height: 44px;
    }

    .@{ant-prefix}-tree-switcher-leaf-line {
      display: none;
    }

    .@{ant-prefix}-tree-treenode {
      align-items: flex-start;
      width: 100%;
      padding: 0;
      color: var(--zaui-text);
      font-size: var(--zaui-font-size);
    }

    .@{ant-prefix}-tree-node-content-wrapper {
      min-height: 20px;
      line-height: 20px;
    }

    .@{ant-prefix}-tree-node-content-wrapper {
      width: 100%;

      .@{ant-prefix}-tree-title {
        display: block;
        width: 100%;
      }
    }

    // 只读状态下，是否隐藏未勾选行
    .hide-disable-node {
      .@{ant-prefix}-tree-treenode.@{ant-prefix}-tree-treenode-disabled {
        display: none;
      }

      .@{ant-prefix}-tree-treenode-checkbox-indeterminate,
      .@{ant-prefix}-tree-treenode-checkbox-checked {
        &.@{ant-prefix}-tree-treenode-disabled {
          display: flex;
        }
      }
    }
  }

  &-tree-node {
    display: flex;
    flex-direction: row;
    padding: 9px var(--zaui-space-size-sm);
    margin-left: -8px;
    border-radius: var(--zaui-space-size-xs);

    &:hover {
      background: #f7f9fc;
    }

    &:last-child {
      flex: 1;
    }

    &.checked {
      position: relative;
      z-index: 1;
      color: var(--zaui-brand);

      .brand-bg-opa-ten {
        position: absolute;
        width: 100%;
        height: 100%;
        top: 0px;
        left: 0px;
        background-color: var(--zaui-brand);
        opacity: 0.1;
        z-index: -1;
        border-radius: var(--zaui-space-size-xs);
      }
    }

    .tree-node-show-text {
      display: flex;
      flex-direction: row;
      width: 100%;

      .tree-node-show-text-label {
        flex: 1;
        overflow: hidden;

        span {
          width: 100%;
        }

        span.ellipse {
          display: block;
          text-overflow: ellipsis;
          overflow: hidden;
          height: 20px;
          word-break: keep-all;
          white-space: nowrap;
        }
      }
    }

    .operate-tree-node-btns {
      display: flex;
      z-index: 3;

      .icon-item {
        transition-delay: 10s;
        width: 100%;
        margin-left: var(--zaui-space-size-xs);
      }

      .icon-add {
        font-size: var(--zaui-font-size-sm, 12px);
      }

      .svg-icon-expand {
        margin-bottom: -2px;
      }
    }

    .operate-tree-node-btns-absolute {
      visibility: visible;
      position: absolute;
      right: 0px;
    }
  }

  &-tree-node-tag {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 20px;
    margin-right: var(--zaui-space-size-sm);
    padding: 0 var(--zaui-space-size-xs);
    font-weight: 400;
    line-height: 24px;
    white-space: nowrap;
    border-radius: var(--zaui-border-radius-card);

    span {
      font-size: var(--zaui-font-size-sm, 12px);
      line-height: 20px;
      text-align: center;
      transform: scale(0.83, 0.83);
    }
  }

  // 连接线、箭头宽度
  .@{ant-prefix}-tree-show-line .@{ant-prefix}-tree-indent-unit {
    width: 20px;
  }

  .@{ant-prefix}-tree-switcher {
    width: 20px;
    align-self: flex-start;
    margin-top: -4px;
  }

  .@{ant-prefix}-tree-show-line .@{ant-prefix}-tree-indent-unit::before {
    right: 9px;
  }

  // 底部样式
  .pro-tree-footer-box {
    z-index: 4;
    padding: var(--zaui-space-size-md) var(--zaui-space-size-md) var(--zaui-space-size-md)
      var(--zaui-space-size-sm);
    position: relative;
    box-shadow: 0 -20px 5px -21px rgba(151, 151, 151, 0.32);
  }

  // 去除antd白色背景
  .@{ant-prefix}-tree-show-line .@{ant-prefix}-tree-switcher,
  .@{ant-prefix}-tree {
    background-color: transparent;
  }

  .empty-tree {
    color: #939599;
    height: 100%;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

// 操作按钮样式
.pro-tree-operate-container {
  padding-top: 0px;
  min-width: 120px;

  .@{ant-prefix}-popover-inner-content {
    padding: 0px;
    width: 100%;
  }

  .@{ant-prefix}-popover-arrow {
    display: none;
  }

  .pro-tree-operate-btn-popover {
    .icon-item {
      position: relative;
      z-index: 1;
      cursor: pointer;
      padding-left: var(--zaui-space-size-md);
      width: 100%;
      height: 32px;
      line-height: 32px;
    }

    .icon-item:hover {
      &:after {
        position: absolute;
        display: block;
        z-index: 0;
        left: 0;
        top: 0;
        content: '';
        width: 120px;
        height: 32px;
        background-color: var(--zaui-brand);
        opacity: 0.08;
      }
    }
  }
}

// 重置ant-form view模式样式ant-tree样式
.pro-form.pro-form-view .@{ant-prefix}-form-item .pro-tree * {
  line-height: 1 !important;
  height: auto !important;
  min-height: auto !important;
}

.pro-form.pro-form-view .@{ant-prefix}-form-item .pro-tree .@{ant-prefix}-tree-checkbox {
  margin-top: var(--zaui-space-size-sm);
}

.pro-form.pro-form-view .@{ant-prefix}-form-item .pro-tree .@{ant-prefix}-tree-switcher {
  padding-top: var(--zaui-font-size-sm);
}

.pro-form.pro-form-view .@{ant-prefix}-form-item .pro-tree .@{ant-prefix}-tree-checkbox * {
  height: 16px !important;
}

.pro-tree-select,
.pro-tree-select-drop-down-container {
  .@{ant-prefix}-select-selector {
    .check-mark-icon {
      display: none;
    }
  }
  &.@{ant-prefix}-select-dropdown {
    // 隐藏单选下拉树后面勾号
    .@{ant-prefix}-select-tree-node-content-wrapper {
      .check-mark-icon {
        display: none;
      }
    }
  }
}

.@{ant-prefix}-select-tree-node-content-wrapper {
  &:has(.pro-tree-wrap-ellipse) {
    overflow: hidden;
  }
}

// ProTree 更多项数量样式
.pro-tree-more-count {
  color: var(--zaui-primary, #006aff);
  font-weight: bold;
}
