@mixin range-style($name, $color) {
  &.ui-#{$name} {
    .ui-range-progress-bar {
      background-color: $color;
    }
    &[disabled], &[readonly], &.disabled {
      .ui-range-btn {
        cursor: not-allowed;
        &:hover, &:active {
          background-color: lighten($color, 10);
        }
      }
    }
    &[disabled], &.disabled {
      .ui-range-btn {
        cursor: not-allowed;
      }
    }
    &[readonly] {
      .ui-range-btn {
        cursor: default;
      }
    }
  }
}

ui-input[type=range] {
  vertical-align: middle;
  display: inline-block;
  line-height: 0;
  height: 1em;
  width: 10em;
  padding-left: 14px;
  padding-right: 14px;
  text-align: left;
  @include range-style(primary, $color-primary);
  @include range-style(info, $color-info);
  @include range-style(warning, $color-warning);
  @include range-style(success, $color-success);
  @include range-style(danger, $color-danger);
  &[disabled], &[readonly], &.ui-disabled {
    opacity: .5;
    .ui-range-btn-raw {
      cursor: not-allowed;
    }
  }
  &[readonly] {
    cursor: default;
  }

}

.ui-input-range-raw {
  width: 0;
  height: 0;
  position: absolute;
  overflow: hidden;
  opacity: 0;
}

.ui-range {
  display: inline-block;
  height: 1px;
  position: relative;
  width: 100%;
  background-color: $color-gray;
  border-radius: inherit;
  cursor: default;
}

.ui-range-progress-bar {
  height: 100%;
  display: inline-block;
  width: 50%;
  position: absolute;
  top: 0;
  background-color: $color-dark;
}

.ui-range-btn {
  position: absolute;
  width: 28px;
  height: 28px;
  right: -14px;
  line-height: 28px;
  top: 50%;
  border-radius: 50%;
  transform: translateY(-50%);
  transform-origin: 50% 50%;
  background-color: #fff;
  box-shadow: 0 3px 1px rgba(0, 0, 0, .1), 0 4px 8px rgba(0, 0, 0, .13), 0 0 0 1px rgba(0, 0, 0, .02);
  border: none;
}

.ui-range-btn-raw {
  cursor: pointer;
  width: 100%;
  height: 100%;
  position: absolute;
  background-color: #fff;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
  border: 0;
  border-radius: 50%;
  &.ui-focus, &:focus {
    @include focus($color-primary);
  }
}

.ui-range-progress {
  top: 0;
  height: 100%;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 12px;
  text-align: center;
  color: #fff;
  background-color: $color-dark;
  display: block;
  padding-left: 6px;
  padding-right: 6px;
  min-width: 24px;
  opacity: 0;
  transition: all .2s;
  border-radius: 5px;
  box-shadow: 0 3px 3px rgba(0, 0, 0, .3);
  &:after {
    content: "";
    width: 0;
    height: 0;
    border-width: 3px 4px;
    border-style: solid;
    border-color: $color-dark transparent transparent transparent;
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -4px;
  }
  &.ui-touched {
    opacity: 1;
    transform: translateX(-50%) translateY(-36px);
  }
}