@import '../variables';

.Select {
  position: relative;
  text-align: left;

  &-control {
    position: relative;
    box-sizing: border-box;
    color: #333333;
    font-size: 1.2rem;
    font-weight: 300;
    line-height: 1.42857;
    padding: 0.3rem 1.2rem 0.1rem;
    padding-left: 0;
    background-color: #ffffff;
    border-bottom: 1px solid $light-grey;
    outline: none;
    overflow: hidden;
    cursor: pointer;

    &:hover,
    &:active,
    &:focus {
      z-index: 20;
      border-color: $brand-primary;
    }
  }

  &-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: -15px;
    padding-top: .6rem;
    max-width: 100%;
    color: #aaaaaa;
    font-size: 1.2rem;
    font-weight: 400;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
  }

  &-value {
    position: absolute;
    top: 0;
    left: 0;
    right: -15px;
    padding: 8px 52px 8px 10px;
    max-width: 100%;
    color: #aaaaaa;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
  }

  &-input > input {
    display: inline-block;
    height: auto;
    margin: 0;
    padding: .5rem;
    padding-left: 0;
    font-family: inherit;
    font-size: inherit;
    background: none transparent;
    box-shadow: none;
    border: 0 none;
    cursor: default;
    outline: none;
    -webkit-appearance: none;
  }

  &-loading {
    position: absolute;
    right: 30px;
    top: 50%;
    display: inline-block;
    box-sizing: border-box;
    width: 1rem;
    height: 1rem;
    margin-top: -.5rem;
    border: 2px solid #cccccc;
    border-right-color: #333333;
    border-radius: 50%;
    -webkit-animation: Select-animation-spin 400ms infinite linear;
    -o-animation: Select-animation-spin 400ms infinite linear;
    animation: Select-animation-spin 400ms infinite linear;
  }

  &-clear {
    position: absolute;
    right: 17px;
    top: 0;
    display: inline-block;
    padding: 3px 10px;
    color: #999999;
    font-size: 16px;
    cursor: pointer;

    &:hover {
      color: #c0392b;
    }

    > span {
      font-size: 1.1em;
    }
  }

  &-arrow-zone {
    content: " ";
    display: block;
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 30px;
    cursor: pointer;
  }

  &-arrow {
    border-color: #999999 transparent transparent;
    border-top-color: #ccc;
    border-style: solid;
    border-width: 5px 5px 0;
    content: " ";
    display: block;
    height: 0;
    margin-top: -ceil(2.5px);
    position: absolute;
    right: 10px;
    top: 1.2rem;
    width: 0;
    cursor: pointer;
  }

  &-menu-outer {
    position: absolute;
    top: 100%;
    width: 100%;
    z-index: 1000;
    background-color: $brand-white;
    box-shadow: 0 0 5px 1px rgba(0, 0, 0, 0.06);
    box-sizing: border-box;
    margin-top: -1px;
    max-height: 200px;

    -webkit-overflow-scrolling: touch;
  }

  &-menu {
    max-height: 198px;
    overflow-y: auto;
  }

  &-option {
    box-sizing: border-box;
    cursor: pointer;
    display: block;
    padding: 1rem 1.5rem;
    color: $brand-default;

    &.is-focused {
      background-color: #e3f2fd;
    }

    &.is-disabled {
      color: #cccccc;
      cursor: not-allowed;
    }
  }

  &-item {
    border: 1px solid #c9e6f2;
    display: inline-block;
    font-size: 1em;
    margin: 0;
    background-color: #44484B;
    border: 1px solid;
    color: #fff;
    padding: .4rem .7rem;
  }
}

.is-searchable.is-open > .Select-control {
  cursor: text;
}

.is-open > .Select-control {
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
  background: #ffffff;
  border-color: #ccc;
}

.is-open > .Select-control > .Select-arrow {
  border-color: transparent transparent #999999;
  border-width: 0 5px 5px;
}

.is-searchable.is-focused:not(.is-open) > .Select-control {
  cursor: text;
}

.is-focused:not(.is-open) > .Select-control {
  z-index: 10;
  border-color: $brand-primary;
}

.has-value > .Select-control > .Select-placeholder {
  color: #333333;
}

.has-value > .Select-control > .Select-value {
  color: #333333;
}

.is-focused .Select-input > input {
  cursor: text;
}

.Select-control:not(.is-searchable) > .Select-input {
  outline: none;
}

.has-value > .Select-control > .Select-loading {
  right: 46px;
}

.Select-noresults,
.Select-search-prompt,
.Select-searching {
  box-sizing: border-box;
  color: #999999;
  cursor: default;
  display: block;
  padding: 1rem 1.5rem;
}

.Select.is-multi .Select-control {
  padding: 2px 52px 2px 3px;
}

.Select.is-multi .Select-input {
  vertical-align: middle;
  border: 1px solid transparent;
  margin: 2px;
  padding: 3px 0;
}

.Select-item-icon,
.Select-item-label {
  display: inline-block;
  vertical-align: middle;
}

.Select-item-label {
  cursor: default;
  border-bottom-right-radius: 2px;
  border-top-right-radius: 2px;
  padding: 0;
  vertical-align: baseline;
}

.Select-item-label .Select-item-label__a {
  color: #0088cc;
  cursor: pointer;
}

.Select-item-icon {
  cursor: pointer;
  border-bottom-left-radius: 2px;
  border-top-left-radius: 2px;
  border: 0;
  margin-left: .5rem;
  color: #ed835c;
  padding: 0;
  vertical-align: baseline;
}

.Select-item-icon:hover,
.Select-item-icon:focus {
  background-color: transparent;
  color: darken(#ed835c, 10%);
}

.Select-item-icon:active {
  background-color: #c9e6f2;
}

.Select.is-multi.is-disabled .Select-item {
  background-color: #f2f2f2;
  border: 1px solid #d9d9d9;
  color: #888888;
}

.Select.is-multi.is-disabled .Select-item-icon {
  cursor: not-allowed;
  border-right: 1px solid #d9d9d9;
}

.Select.is-multi.is-disabled .Select-item-icon:hover,
.Select.is-multi.is-disabled .Select-item-icon:focus,
.Select.is-multi.is-disabled .Select-item-icon:active {
  background-color: #f2f2f2;
}

.Select {
  &.is-open {
    .Select-placeholder {
      display: none;
    }
  }

  &-ranged {
    display: inline-block;
    width: 50%;
    text-align: center;

    &:nth-child(1) {
      .Select-control {
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
      }
    }

    &:nth-child(2) {
      margin-left: -1px;

      .Select-control {
        border-top-left-radius: 0;
        border-bottom-left-radius: 0;
      }
    }
  }
}

table {
  .Select-control {
    border: none;
  }
}

@keyframes Select-animation-spin {
  to {
    transform: rotate(1turn);
  }
}
@-webkit-keyframes Select-animation-spin {
  to {
    -webkit-transform: rotate(1turn);
  }
}
