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

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

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

  position: absolute;
  top: -9999px;
  left: -9999px;
  z-index: @yee-zindex-dropdown;
  display: block;

  &::before {
    position: absolute;
    top: -7px;
    right: 0;
    bottom: -7px;
    left: -7px;
    z-index: -9999;
    opacity: 0.0001;
    content: ' ';
  }

  &-wrap {
    position: relative;

    .@{yee-prefix}-btn > .@{yee-iconfont-css-prefix}-down {
      .yee-iconfont-size-under-12px(10px);
    }

    .@{yee-iconfont-css-prefix}-down::before {
      transition: transform 0.2s;
    }
  }

  &-wrap-open {
    .@{yee-iconfont-css-prefix}-down::before {
      transform: rotate(180deg);
    }
  }

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

  &-menu {
    position: relative;
    margin: 0;
    padding: @yee-dropdown-edge-child-vertical-padding 0;
    text-align: left;
    list-style-type: none;
    background-color: @yee-component-background;
    background-clip: padding-box;
    border-radius: @yee-border-radius-base;
    outline: none;
    box-shadow: @yee-box-shadow-base;
    -webkit-transform: translate3d(0, 0, 0);

    &-item-group-title {
      padding: 5px @yee-control-padding-horizontal;
      color: @yee-text-color-secondary;
      transition: all 0.3s;
    }

    &-submenu-popup {
      position: absolute;
      z-index: @yee-zindex-dropdown;

      > .@{yee-dropdown-prefix-cls}-menu {
        transform-origin: 0 0;
      }

      ul,
      li {
        list-style: none;
      }

      ul {
        margin-right: 0.3em;
        margin-left: 0.3em;
        padding: 0;
      }
    }

    &-item,
    &-submenu-title {
      clear: both;
      margin: 0;
      padding: @yee-dropdown-vertical-padding @yee-control-padding-horizontal;
      color: @yee-text-color;
      font-weight: normal;
      font-size: @yee-dropdown-font-size;
      line-height: @yee-dropdown-line-height;
      white-space: nowrap;
      cursor: pointer;
      transition: all 0.3s;

      > .anticon:first-child,
      > span > .anticon:first-child {
        min-width: 12px;
        margin-right: 8px;
        font-size: @yee-font-size-sm;
      }

      > a {
        display: block;
        margin: -@yee-dropdown-vertical-padding -@yee-control-padding-horizontal;
        padding: @yee-dropdown-vertical-padding @yee-control-padding-horizontal;
        color: @yee-text-color;
        transition: all 0.3s;
      }

      &:first-child {
        & when (@yee-dropdown-edge-child-vertical-padding = 0) {
          border-radius: @yee-border-radius-base @yee-border-radius-base 0 0;
        }
      }

      &:last-child {
        & when (@yee-dropdown-edge-child-vertical-padding = 0) {
          border-radius: 0 0 @yee-border-radius-base @yee-border-radius-base;
        }
      }

      &-selected,
      &-selected > a {
        color: @yee-dropdown-selected-color;
        background-color: @yee-item-active-bg;
      }

      &:hover {
        background-color: @yee-item-hover-bg;
      }

      &-disabled {
        color: @yee-disabled-color;
        cursor: not-allowed;

        &:hover {
          color: @yee-disabled-color;
          background-color: @yee-component-background;
          cursor: not-allowed;
        }
      }

      &-divider {
        height: 1px;
        margin: 4px 0;
        overflow: hidden;
        line-height: 0;
        background-color: @yee-border-color-split;
      }

      .@{yee-dropdown-prefix-cls}-menu-submenu-arrow {
        position: absolute;
        right: @yee-padding-xs;
        &-icon {
          color: @yee-text-color-secondary;
          font-style: normal;
          .yee-iconfont-size-under-12px(10px);
        }
      }
    }

    &-item-group-list {
      margin: 0 8px;
      padding: 0;
      list-style: none;
    }

    &-submenu-title {
      padding-right: 26px;
    }

    &-submenu-vertical {
      position: relative;
    }

    &-submenu-vertical > & {
      position: absolute;
      top: 0;
      left: 100%;
      min-width: 100%;
      margin-left: 4px;
      transform-origin: 0 0;
    }

    &-submenu&-submenu-disabled .@{yee-dropdown-prefix-cls}-menu-submenu-title {
      &,
      .@{yee-dropdown-prefix-cls}-menu-submenu-arrow-icon {
        color: @yee-disabled-color;
        background-color: @yee-component-background;
        cursor: not-allowed;
      }
    }

    // https://github.com/ant-design/ant-design/issues/19264
    &-submenu-selected &-submenu-title {
      color: @yee-primary-color;
    }
  }

  &.slide-down-enter.slide-down-enter-active&-placement-bottomLeft,
  &.slide-down-appear.slide-down-appear-active&-placement-bottomLeft,
  &.slide-down-enter.slide-down-enter-active&-placement-bottomCenter,
  &.slide-down-appear.slide-down-appear-active&-placement-bottomCenter,
  &.slide-down-enter.slide-down-enter-active&-placement-bottomRight,
  &.slide-down-appear.slide-down-appear-active&-placement-bottomRight {
    animation-name: antSlideUpIn;
  }

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

  &.slide-down-leave.slide-down-leave-active&-placement-bottomLeft,
  &.slide-down-leave.slide-down-leave-active&-placement-bottomCenter,
  &.slide-down-leave.slide-down-leave-active&-placement-bottomRight {
    animation-name: antSlideUpOut;
  }

  &.slide-up-leave.slide-up-leave-active&-placement-topLeft,
  &.slide-up-leave.slide-up-leave-active&-placement-topCenter,
  &.slide-up-leave.slide-up-leave-active&-placement-topRight {
    animation-name: antSlideDownOut;
  }
}

.@{yee-dropdown-prefix-cls}-trigger,
.@{yee-dropdown-prefix-cls}-link {
  > .@{yee-iconfont-css-prefix}.@{yee-iconfont-css-prefix}-down {
    .yee-iconfont-size-under-12px(10px);
  }
}

.@{yee-dropdown-prefix-cls}-button {
  white-space: nowrap;

  &.@{yee-prefix}-btn-group > .@{yee-prefix}-btn:last-child:not(:first-child) {
    padding-right: @yee-padding-xs;
    padding-left: @yee-padding-xs;
  }
  .@{yee-iconfont-css-prefix}.@{yee-iconfont-css-prefix}-down {
    .yee-iconfont-size-under-12px(10px);
  }
}

// https://github.com/ant-design/ant-design/issues/4903
.@{yee-dropdown-prefix-cls}-menu-dark {
  &,
  .@{yee-dropdown-prefix-cls}-menu {
    background: @yee-menu-dark-bg;
  }
  .@{yee-dropdown-prefix-cls}-menu-item,
  .@{yee-dropdown-prefix-cls}-menu-submenu-title,
  .@{yee-dropdown-prefix-cls}-menu-item > a {
    color: @yee-text-color-secondary-dark;
    .@{yee-dropdown-prefix-cls}-menu-submenu-arrow::after {
      color: @yee-text-color-secondary-dark;
    }
    &:hover {
      color: @yee-text-color-inverse;
      background: transparent;
    }
  }
  .@{yee-dropdown-prefix-cls}-menu-item-selected {
    &,
    &:hover,
    > a {
      color: @yee-text-color-inverse;
      background: @yee-primary-color;
    }
  }
}
