@import "../../style/themes/default";
@import "../../style/mixins/index";
@import "mixin";
@import "../../_ticker/style/index";

@popedit-prefix-cls: ~"@{mk-prefix}-popedit";

.@{popedit-prefix-cls} {
  .reset-component;
  display: inline-block;
  position: relative;
  outline: 0;

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

  > ul > li > a {
    padding: 0;
    background-color: @component-background;
  }

  &-selection {
    outline: none;
    user-select: none;
    box-sizing: border-box;
    display: block;
    position: relative;
    cursor: pointer;
    background-color: @component-background;
    border-radius: @border-radius-base;
    border: @border-width-base @border-style-base @border-color-base;
    border-top-width: @border-width-base + 0.02px;
    transition: all .3s @ease-in-out;

    &:hover {
      .hover;
    }

    .@{popedit-prefix-cls}-focused &,
    &:focus,
    &:active {
      .active;
    }

    &__clear {
      .selection__clear();
    }

    &:hover &__clear {
      opacity: 1;
    }

    &-selected-value {
      float: left;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      max-width: 100%;
      padding-right: 20px;
    }
    &-icon {
      position: absolute;
      top: 50%;
      right: @control-padding-horizontal - 1px;
      line-height: 1;
      margin-top: -@font-size-sm / 2;
      transform-origin: 50% 50%;
      color: @disabled-color;
      transition: transform .3s;
    }
  }

  &-lg {
    font-size: @font-size-lg;
    .@{popedit-prefix-cls}-selection--single {
      height: @input-height-lg;
    }
    .@{popedit-prefix-cls}-selection__rendered {
      line-height: @input-height-lg - 2px;
    }
    .@{popedit-prefix-cls}-selection--multiple {
      min-height: @input-height-lg;
      .@{popedit-prefix-cls}-selection__rendered {
        li {
          height: @input-height-lg - 8px;
          line-height: @input-height-lg - 8px;
        }
      }
      .@{popedit-prefix-cls}-selection__clear {
        top: @input-height-lg / 2;
      }
    }
  }

  &-sm {
    .@{popedit-prefix-cls}-selection--single {
      height: @input-height-sm;
    }
    .@{popedit-prefix-cls}-selection__rendered {
      line-height: @input-height-sm - 2px;
      margin: 0 @control-padding-horizontal-sm - 1px;
    }
    .@{popedit-prefix-cls}-selection--multiple {
      min-height: @input-height-sm;
      .@{popedit-prefix-cls}-selection__rendered {
        li {
          height: @input-height-sm - 8px;
          line-height: @input-height-sm - 10px;
        }
      }
      .@{popedit-prefix-cls}-selection__clear {
        top: @input-height-sm / 2;
      }
    }
    .@{popedit-prefix-cls}-selection__clear,
    .@{popedit-prefix-cls}-arrow {
      right: @control-padding-horizontal-sm;
    }
  }

  // custom
  &-li {
    &.@{popedit-prefix-cls}-disabled {
      .@{popedit-prefix-cls}-selection {
        border-bottom: @border-width-base @border-style-disable @border-color-base;
        background-color: #fff;
      }
      .@{popedit-prefix-cls}-arrow {
        display: none;
      }
    }
    .@{popedit-prefix-cls}-selection {
      border: 0;
      border-bottom: @border-width-base @border-style-base @border-color-base;
      border-radius: 0;
    }
  }

  &-selection__rendered {
    display: block;
    margin-left: @control-padding-horizontal - 1px;
    margin-right: @control-padding-horizontal - 1px;
    position: relative;
    line-height: @input-height-base - 2px;
    &:after {
      content: '.';
      visibility: hidden;
      pointer-events: none;
      display: inline-block;
      width: 0;
    }
    .mk-ticker {
      float: left;
    }
  }

  &-selection--single {
    height: @input-height-base;
    position: relative;
  }

  &-selection--multiple {
    min-height: @input-height-base;
    .clearfix;
    .mk-ticker {
      margin-top: 3px;
      margin-right: 4px;
    }
  }

  &-selection__placeholder {
    position: absolute;
    top: 50%;
    left: 0;
    right: 9px;
    color: @input-placeholder-color;
    line-height: 20px;
    height: 20px;
    max-width: 100%;
    margin-top: -10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
  }

  &-open {
    .@{popedit-prefix-cls}-selection {
      .active();
      .@{popedit-prefix-cls}-selection-icon {
        transform: rotate(180deg);
      }
    }
  }
  &-dropdown-wrapper {
    .reset-component;
    background-color: @component-background;
    box-shadow: @box-shadow-base;
    border-radius: @border-radius-base;
    box-sizing: border-box;
    z-index: @zindex-dropdown;
    left: -9999px;
    top: -9999px;
    position: absolute;
    outline: none;
    font-size: @font-size-base;
    min-height: 100px;
    min-width: 300px;
    &-hidden {
      display: none;
    }
  }
  &-loading {
    display: block;
    margin: 25px auto;
    font-size: @loading-size-lg;
    color: @border-color-base;
  }
}
