/**
 * @author zhixin wen <wenzhixin2010@gmail.com>
 */

.ms-offscreen {
  clip: rect(0 0 0 0)!important;
  width: 1px!important;
  height: 1px!important;
  border: 0!important;
  margin: 0!important;
  padding: 0!important;
  overflow: hidden!important;
  position: absolute!important;
  outline: 0!important;
  left: auto!important;
  top: auto!important;
}

.ms-parent {
  display: inline-block;
  position: relative;
  vertical-align: middle;
}

.ms-choice {
  display: block;
  width: 100%;
  height: 26px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid #aaa;
  text-align: left;
  white-space: nowrap;
  line-height: 26px;
  color: #444;
  text-decoration: none;
  border-radius: 4px;
  background-color: #fff;

  &.disabled {
    background-color: #f4f4f4;
    background-image: none;
    border: 1px solid #ddd;
    cursor: default;
  }

  > {
    span {
      position: absolute;
      top: 0;
      left: 0;
      right: 20px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      display: block;
      padding-left: 8px;

      &.ms-placeholder {
        color: #999;
      }
    }
    div.icon-close {
      position: absolute;
      top: 0px;
      right: 16px;
      height: 100%;
      width: 16px;

      &:before {
        content: '×';
        color: #888;
        font-weight: bold;
      }

      &:hover:before {
        color: #333;
      }
    }
    div.icon-caret {
      position: absolute;
      width: 0;
      height: 0;
      top: 50%;
      right: 8px;
      margin-top: -2px;
      border-color: #888 transparent transparent transparent;
      border-style: solid;
      border-width: 5px 4px 0 4px;

      &.open {
        border-color: transparent transparent #888 transparent;
        border-width: 0 4px 5px 4px;
      }
    }
  }
}

.ms-drop {
  width: auto;
  min-width: 100%;
  overflow: hidden;
  display: none;
  margin-top: -1px;
  padding: 0;
  position: absolute;
  z-index: 1000;
  background: #fff;
  color: #000;
  border: 1px solid #aaa;
  border-radius: 4px;

  &.bottom {
    top: 100%;
    box-shadow: 0 4px 5px rgba(0, 0, 0, 0.15);
  }

  &.top {
    bottom: 100%;
    box-shadow: 0 -4px 5px rgba(0, 0, 0, 0.15);
  }
}

.ms-search {
  display: inline-block;
  margin: 0;
  min-height: 26px;
  padding: 2px;
  position: relative;
  white-space: nowrap;
  width: 100%;
  z-index: 10000;

  input {
    width: 100%;
    height: auto !important;
    min-height: 24px;
    padding: 0 5px;
    margin: 0;
    outline: 0;
    font-family: sans-serif;
    border: 1px solid #aaa;
    border-radius: 5px;
    box-shadow: none;
  }

  box-sizing: border-box;
}

.ms-filter-options {
  display: flex;
  padding: 4px 4px;
  border-bottom: 1px solid #eee;
  background-color: #f9f9f9;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */

  &::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
  }
}

.ms-filter-option {
  line-height: 20px;
  padding: 4px 6px;
  margin-right: 4px;
  cursor: pointer;
  border-radius: 3px;
  color: #666;
  background-color: #fff;
  border: 1px solid #ddd;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;

  &:hover {
    background-color: #e9ecef;
    border-color: #ccc;
  }

  &.active {
    background-color: #007bff;
    color: #fff;
    border-color: #007bff;
  }

  &:last-child {
    margin-right: 0;
  }
}

.ms-drop {
  ul {
    overflow: auto;
    margin: 0;
    padding: 0;

    > li {
      list-style: none;
      display: list-item;
      background-image: none;
      position: static;
      padding: .25rem 8px;

      .disabled {
        font-weight: normal!important;
        opacity: .35;
        filter: Alpha(Opacity = 35);
        cursor: default;
      }

      &.multiple {
        display: block;
        float: left;
      }

      &.group {
        clear: both;
      }

      &.multiple label {
        width: 100%;
        display: block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      label {
        position: relative;
        padding-left: 1.25rem;
        margin-bottom: 0;
        font-weight: normal;
        display: block;
        white-space: nowrap;
        cursor: pointer;

        &.optgroup {
          font-weight: bold;
        }
      }

      &.hide-radio {
        padding: 0;

        &:focus,
        &:hover {
          background-color: #f8f9fa;
        }

        &.selected {
          color: #fff;
          background-color: #007bff;
        }

        label {
          margin-bottom: 0;
          padding: 5px 8px;
        }

        input {
          display: none;
        }
      }

      &.option-level-1 {
        label {
          padding-left: 28px;
        }
      }

      &.group ~ li.option-level-1:not(.hide-radio) > label {
        padding-left: 40px;
      }

      &.option-divider {
        padding: 0;
        border-top: 1px solid #e9ecef;
      }
    }
  }

  input {
    &[type="radio"], &[type="checkbox"] {
      position: absolute;
      margin-top: .3rem;
      margin-left: -1.25rem;
    }
  }

  .ms-no-results {
    display: none;
  }
}
