@import '../styles/themes/themes.less';
@import '../styles/mixins/mixins.less';

.@{bk-prefix}-cascader-popover.@{bk-prefix}-pop2-content.@{bk-prefix}-popover {
  padding: 0;
}
.@{bk-prefix}-cascader-popover-wrapper {
  display: block;
}

.@{bk-prefix}-cascader-wrapper {
  position: relative;

  &.float-mode {
    max-height: @component-size-base;
  }
}

.@{bk-prefix}-cascader {
  position: relative;
  display: block;
  font-size: 12px;
  line-height: 30px;
  color: #63656e;
  cursor: pointer;
  background: #fff;
  border: 1px solid #c4c6cc;
  border-radius: 2px;
  outline: none;

  &.is-hover:not(.is-disabled) {
    border: 1px solid #979ba5;
  }

  &.is-disabled {
    cursor: not-allowed;
    background-color: @input-disabled-bg;
    border-color: @disable-color;
    opacity: 1;

    .@{bk-prefix}-cascader-name,
    input {
      cursor: not-allowed;
      background-color: @input-disabled-bg;
      opacity: 1;
    }
  }

  &.is-simplicity {
    background-color: transparent;
    border-color: transparent;
    border-bottom-color: @input-border-color;

    &:hover:not(.is-disabled) {
      background-color: @input-block-color;
      border-color: transparent;
      border-bottom-color: @light-gray;
      box-shadow: none;
      .@{bk-prefix}-input--text, .@{bk-prefix}-input--suffix-icon {
        background-color: @input-block-color;
      }
    }
  }


  &.is-focus {
    z-index: 1;
    border: 1px solid #3a84ff;

    .@{bk-prefix}-cascader-name {
      .cascader-selected-text {
        white-space: pre-wrap;
      }

      .cascader-tag-list {
        height: auto;
      }
    }

    &.is-simplicity.is-simplicity {
      border-color: transparent;
      border-bottom-color: @primary-color;
      box-shadow: none;
      .@{bk-prefix}-input--text, .@{bk-prefix}-input--suffix-icon {
        background-color: @input-block-color;
      }
    }
  }

  .@{bk-prefix}-icon-angle-up.active {
    transform: rotate(0);
  }

  &.is-unselected:before {
    position: absolute;
    top: 0;
    left: 11px;
    height: 100%;
    color: #c3cdd7;
    pointer-events: none;
    content: attr(data-placeholder);
  }

  &.is-filterable:before {
    display: none;
  }

  .@{bk-prefix}-icon-angle-up,
  .@{bk-prefix}-icon-clear-icon {
    position: absolute;
    right: 2px;
    display: inline-flex;
    align-items: center;
    height: 100%;
    font-size: 20px;
    color: #979ba5;
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    transform: rotate(180deg);
  }

  .@{bk-prefix}-icon-clear-icon {
    right: 4px;
    font-size: 14px;
    color: #c4c6cc;

    &:hover {
      color: #979ba5;
    }
  }
  .@{bk-prefix}-popover-reference {
    display: block;
    width: 100%;
  }
  .@{bk-prefix}-cascader-name {
    position: static;
    display: block;
    max-width: 100%;
    min-height: 30px;
    max-height: 120px;
    padding: 0 24px 0 11px;
    overflow-x: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    .@{bk-prefix}-cascader-search-input {
      width: 100%;
      min-width: 24px;
      flex: 1;
      font-size: 12px;
      cursor: text;
      border: none;
      outline: 0;

      &::placeholder {
        color: #c3cdd7;
      }
    }

    .cascader-selected-text {
      display: block;
      width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .cascader-tag-list {
      box-sizing: border-box;
      display: flex;
      flex-flow: row wrap;
      align-items: center;
      height: @component-size-base;
      min-height: 30px;
      padding-top: 5px;
      // overflow: hidden; // remove this to allow wrap

      .@{bk-prefix}-cascader-search-input {
        height: 22px;
        margin-bottom: 5px;
        line-height: 22px;
      }

      .tag-item {
        position: relative;
        max-width: calc(100% - 50px);
        height: 22px;
        padding-right: 18px;
        margin: 0 6px 5px 0;
        overflow: hidden;
        line-height: 22px;
        cursor: pointer;
        background-color: #f0f1f5;
        border-radius: 2px;

        &:hover {
          background: #dcdee5;
        }

        .tag-item-name {
          display: inline-block;
          width: 100%;
          padding: 0 5px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
      }

      .@{bk-prefix}-tag {
        margin-bottom: 5px;
      }
    }
  }
}

.@{bk-prefix}-cascader-popover{
  border: 1px solid @cascader-panel-border-color;
  border-radius: 2px;
  box-shadow: 0px 2px 6px 0px rgba(0,0,0,.10);
  .@{bk-prefix}-cascader-panel-wrapper {
    display: inline-flex;
    .@{bk-prefix}-cascader-panel {
      min-width: 160px;
      padding: 4px 0;
      background: @white-color;
      border-right: 1px solid @cascader-panel-border-color;
  
      &:last-child {
        border-right: none;
      }
      .@{bk-prefix}-cascader-node {
        position: relative;
        display: flex;
        align-items: center;
        padding: 0 16px;
        overflow: hidden;
        line-height: @component-size-base;
        text-overflow: ellipsis;
        white-space: nowrap;
        cursor: pointer;
  
        &:hover {
          background: @cascader-panel-hover;
        }
  
        &.is-selected,
        &.is-checked {
          color: @primary-color;
          background: @cascader-panel-active;
        }
  
        &.is-disabled {
          color: @light-gray;
          cursor: not-allowed;
          background-color: @white-color;
  
          .@{bk-prefix}-icon-angle-right {
            color: @light-gray;
          }
        }
  
        .@{bk-prefix}-icon-angle-right {
          position: absolute;
          top: 50%;
          right: 0;
          font-size: 20px;
          color: @gray-color;
          transform: translateY(-50%);
        }
  
        .@{bk-prefix}-icon-spinner {
          position: absolute;
          top: 50%;
          right: 5px;
          font-size: 12px;
          color: @gray-color;
          transform: translateY(-50%);
        }

        // OverflowTitle wrapper constraint
        .position-relative {
          flex: 1;
          min-width: 0; // Allow flex item to shrink below content size
          overflow: hidden;

          .text-ov {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }
        }

        .@{bk-prefix}-cascader-node-name {
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
      }
    }
    .@{bk-prefix}-cascader-panel-empty-wrapper {
      display: flex;
      align-items: center;
      justify-content: center;
      height: 100%;
      color: #63656e;
    }
    .@{bk-prefix}-cascader-search-empty {
      display: flex;
      align-items: center;
      justify-content: center;
      height: 56px;
      color: #63656e
    }
  }
}

.@{bk-prefix}-cascader-popover-reference{
  display: block !important;
  width: 100%;
}
