@import '../../style/themes/index';
@import '../../style/mixins/index';
@import '../../input/style/mixin';

@yee-cascader-prefix-cls: ~'@{yee-prefix}-cascader';

.@{yee-cascader-prefix-cls} {
  .yee-reset-component;

  &-input.@{yee-prefix}-input {
    // Keep it static for https://github.com/ant-design/ant-design/issues/16738
    position: static;
    width: 100%;
    // https://github.com/ant-design/ant-design/issues/17582
    padding-right: 24px;
    // Add important to fix https://github.com/ant-design/ant-design/issues/5078
    // because input.less will compile after cascader.less
    background-color: transparent !important;
    cursor: pointer;
  }

  &-picker-show-search &-input.@{yee-prefix}-input {
    position: relative;
  }

  &-picker {
    .yee-reset-component;

    position: relative;
    display: inline-block;
    background-color: @yee-component-background;
    border-radius: @yee-border-radius-base;
    outline: 0;
    cursor: pointer;
    transition: color 0.3s;

    &-with-value &-label {
      color: transparent;
    }

    &-disabled {
      color: @yee-disabled-color;
      background: @yee-input-disabled-bg;
      cursor: not-allowed;
      .@{yee-cascader-prefix-cls}-input {
        cursor: not-allowed;
      }
    }

    &:focus .@{yee-cascader-prefix-cls}-input {
      .yee-active;
    }

    &-show-search&-focused {
      color: @yee-disabled-color;
    }

    &-label {
      position: absolute;
      top: 50%;
      left: 0;
      width: 100%;
      height: 20px;
      margin-top: -10px;
      padding: 0 20px 0 @yee-control-padding-horizontal;
      overflow: hidden;
      line-height: 20px;
      white-space: nowrap;
      text-overflow: ellipsis;
    }

    &-clear {
      position: absolute;
      top: 50%;
      right: @yee-control-padding-horizontal;
      z-index: 2;
      width: 12px;
      height: 12px;
      margin-top: -6px;
      color: @yee-disabled-color;
      font-size: @yee-font-size-sm;
      line-height: 12px;
      background: @yee-component-background;
      cursor: pointer;
      opacity: 0;
      transition:
        color 0.3s ease,
        opacity 0.15s ease;
      &:hover {
        color: @yee-text-color-secondary;
      }
    }

    &:hover &-clear {
      opacity: 1;
    }

    // arrow
    &-arrow {
      position: absolute;
      top: 50%;
      right: @yee-control-padding-horizontal;
      z-index: 1;
      width: 12px;
      height: 12px;
      margin-top: -6px;
      color: @yee-disabled-color;
      font-size: 12px;
      line-height: 12px;
      transition: transform 0.2s;
      &&-expand {
        transform: rotate(180deg);
      }
    }
  }

  // https://github.com/ant-design/ant-design/pull/12407#issuecomment-424657810
  &-picker-label:hover + &-input {
    .yee-hover;
  }

  &-picker-small &-picker-clear,
  &-picker-small &-picker-arrow {
    right: @yee-control-padding-horizontal-sm;
  }

  &-menus {
    position: absolute;
    z-index: @yee-zindex-dropdown;
    font-size: @yee-cascader-dropdown-font-size;
    white-space: nowrap;
    background: @yee-component-background;
    border-radius: @yee-border-radius-base;
    box-shadow: @yee-box-shadow-base;

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

    &-empty,
    &-hidden {
      display: none;
    }
    &.slide-up-enter.slide-up-enter-active&-placement-bottomLeft,
    &.slide-up-appear.slide-up-appear-active&-placement-bottomLeft {
      animation-name: antSlideUpIn;
    }

    &.slide-up-enter.slide-up-enter-active&-placement-topLeft,
    &.slide-up-appear.slide-up-appear-active&-placement-topLeft {
      animation-name: antSlideDownIn;
    }

    &.slide-up-leave.slide-up-leave-active&-placement-bottomLeft {
      animation-name: antSlideUpOut;
    }

    &.slide-up-leave.slide-up-leave-active&-placement-topLeft {
      animation-name: antSlideDownOut;
    }
  }
  &-menu {
    display: inline-block;
    min-width: 111px;
    height: 180px;
    margin: 0;
    padding: @yee-cascader-dropdown-edge-child-vertical-padding 0;
    overflow: auto;
    vertical-align: top;
    list-style: none;
    border-right: @yee-border-width-base @yee-border-style-base @yee-border-color-split;
    -ms-overflow-style: -ms-autohiding-scrollbar; // https://github.com/ant-design/ant-design/issues/11857

    &:first-child {
      border-radius: @yee-border-radius-base 0 0 @yee-border-radius-base;
    }
    &:last-child {
      margin-right: -1px;
      border-right-color: transparent;
      border-radius: 0 @yee-border-radius-base @yee-border-radius-base 0;
    }
    &:only-child {
      border-radius: @yee-border-radius-base;
    }
  }
  &-menu-item {
    padding: @yee-cascader-dropdown-vertical-padding @yee-control-padding-horizontal;
    line-height: @yee-cascader-dropdown-line-height;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.3s;
    &:hover {
      background: @yee-item-hover-bg;
    }
    &-disabled {
      color: @yee-disabled-color;
      cursor: not-allowed;
      &:hover {
        background: transparent;
      }
    }
    &-active:not(&-disabled) {
      &,
      &:hover {
        font-weight: @yee-select-item-selected-font-weight;
        background-color: @yee-background-color-light;
      }
    }
    &-expand {
      position: relative;
      padding-right: 24px;
    }

    &-expand &-expand-icon,
    &-loading-icon {
      .yee-iconfont-size-under-12px(10px);

      position: absolute;
      right: @yee-control-padding-horizontal;
      color: @yee-text-color-secondary;
      .@{yee-cascader-prefix-cls}-menu-item-disabled& {
        color: @yee-disabled-color;
      }
    }

    & &-keyword {
      color: @yee-highlight-color;
    }
  }
}
