@import './../theme/vars.scss';
@import './../mixins/index.scss';

$cascaderPrefixCls: #{$vender-prefix}-cascader;
$cascaderDropdownPrefixCls: #{$cascaderPrefixCls}-dropdown;
$popoverPrefixCls: amos-popover;
$idropDownPrefixCls: amos-idropdown;
$loadingIconCls: aficon-loading-tint;

.#{$cascaderDropdownPrefixCls} {
  position: relative;
  min-width: 20em;
  line-height: 28px;
  background-color: white;
  border: 1px solid $border-color-base;
  border-radius: 2px;
  outline: none;

  &:focus {
    border-color: var(--primary-color);
  }

  &.#{$popoverPrefixCls}-trigger-disabled {
    &:focus {
      border-color: $border-color-base;
    }
  }

  &.#{$idropDownPrefixCls}-toggle-open {
    border-color: var(--primary-color);

    .#{$cascaderDropdownPrefixCls}-icon {
      color: var(--primary-color);
    }
  }

  &-iconable {
    // padding-right: 24px;
  }

  &-icon,
  &-icon-clear {
    position: absolute;
    top: 50%;
    right: 10px;
    display: inline-block;
    margin-top: -14px;
  }

  &-icon-clear {
    display: none;
  }

  &-popover {
    &.#{$popoverPrefixCls}-down {
      padding-top: 1px;

      &::after {
        display: none;
      }
    }

    &.#{$popoverPrefixCls}-up {
      padding-bottom: 1px;
      margin-top: 1px;

      &::after {
        display: none;
      }
    }

    > .#{$popoverPrefixCls}-content {
      max-width: none;
      padding: 0;

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

// cascader

.#{$cascaderPrefixCls} {
  &-input.#{$vender-prefix}-input {
    position: relative;
    width: 100%;
    cursor: pointer;
    background-color: transparent;
  }

  &-picker-show-search &-input.#{$vender-prefix}-input {
    position: relative;
  }

  &-picker {
    position: relative;
    display: inline-block;
    cursor: pointer;
    background-color: $component-background;
    border-radius: $border-radius-base;
    outline: 0;
    transition: color 0.3s;

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

    &-disabled {
      color: $disabled-color;
      cursor: not-allowed;
      background: $ipt-disabled-bg;

      .#{$cascaderPrefixCls}-input {
        cursor: not-allowed;
      }
    }

    &-show-search.#{$cascaderPrefixCls}-focused {
      color: $disabled-color;
    }

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

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

      &:hover {
        color: $text-color-secondary;
      }
    }

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

    // arrow
    &-arrow {
      position: absolute;
      top: 50%;
      right: $control-padding-horizontal;
      z-index: 1;
      width: 12px;
      height: 12px;
      margin-top: -6px;
      font-size: 12px;
      line-height: 12px;
      color: $disabled-color;
      transition: transform 0.2s;

      &.#{$cascaderPrefixCls}-arrow-expand {
        transform: rotate(180deg);
      }
    }
  }

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

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

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

    &-empty,
    &-hidden {
      display: none;
    }
  }

  &-menu {
    display: inline-block;
    height: 180px;
    min-width: 100px;
    padding: 0;
    margin: 0;
    overflow: auto;
    vertical-align: top;
    list-style: none;
    border-right: $border-width-base $border-style-base $border-color-split;
    -ms-overflow-style: -ms-autohiding-scrollbar; //

    &:first-child {
      border-radius: $border-radius-base 0 0 $border-radius-base;
    }

    &:last-child {
      margin-right: -1px;
      border-right-color: transparent;
      border-radius: 0 $border-radius-base $border-radius-base 0;
    }

    &:only-child {
      border-radius: $border-radius-base;
    }
  }

  &-menu-item {
    padding: 5px $control-padding-horizontal;
    line-height: 22px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.3s;

    &:hover {
      background: $item-hover-bg;
    }

    &-disabled {
      color: $disabled-color;
      cursor: not-allowed;

      &:hover {
        background: transparent;
      }
    }

    &-active:not(&-disabled) {
      &,
      &:hover {
        font-weight: 600;
        background-color: $background-color-light;
      }
    }

    &-expand {
      position: relative;
      padding-right: 24px;
    }

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

      position: absolute;
      right: $control-padding-horizontal;
      color: $text-color-secondary;
    }

    &-expand &-loading-icon {
      @include iconfont-spinner($loadingIconCls);
    }

    & &-keyword {
      color: $highlight-color;
    }
  }
}
