.range-display {
  position: relative;
  display: block;
  padding: 32px 38px 32px 34px;
  min-width: 240px;
  border: 4px solid @component-border-color;
  border-radius: 44px;
  background-color: @component-background-default;

  .range-display--compact:not(.range-display--vertical) & {
    padding: 8px 10px;
    min-width: auto;
  }

  .range-display--inline:not(.range-display--vertical) & {
    padding: 9px 12px;
    min-width: auto;
    border-width: 3px;
  }

  &--compact:not(.range-display--vertical) {
    display: flex;
    align-items: center;

    &::before {
      display: inline-block;
      padding-right: 8px;
      content: attr(data-label);
      font-weight: bold;
    }

    .range-display {
      flex: 1 1 auto;
      min-width: auto;
    }
  }

  &__range {
    position: absolute;
    right: 37px;
    left: 34px;
    display: flex;
    height: 4px;
    border: 0;
    border-radius: 0;
    background-color: transparent;
    &::before {
      position: absolute;
      bottom: 0;
      width: 100%;
      border-bottom: 1px dotted currentColor;
      content: '';
      opacity: 0.5;
    }

    .range-display--compact:not(.range-display--vertical) & {
      right: 10px;
      left: 10px;
    }

    .range-display--inline:not(.range-display--vertical) & {
      right: 12px;
      left: 12px;
    }

    &__unit {
      position: absolute;
      top: -24px;
      font-weight: bold;

      .range-display--compact:not(.range-display--vertical) &,
      .range-display--inline:not(.range-display--vertical) & {
        display: none;
      }
    }

    &__max,
    &__min {
      position: absolute;
      top: -4px;
      max-width: 100%;
      height: 8px;
      border-radius: 0;
    }

    &__max {
      left: var(--range-r-min);
      width: calc(var(--range-r-max) - var(--range-r-min));
      background-color: var(--input-validation-error, @status-danger);
    }

    &__min {
      left: var(--range-y-min);
      width: calc(var(--range-y-max) - var(--range-y-min));
      border-right: 1px solid @component-background-default;
      background-color: var(--input-validation-warning, @status-warning);
    }

    &__target {
      position: relative;
      top: -2px;
      z-index: 11;
      width: var(--measurement-target);
      pointer-events: none;

      .range-display--compact:not(.range-display--vertical) &,
      .range-display--inline:not(.range-display--vertical) & {
        display: none;
      }

      &:before {
        position: absolute;
        top: 0;
        right: 0;
        display: block;
        width: 2px;
        height: 26px;
        border-radius: 0;
        background-color: @status-success;
        content: '';
        opacity: 1;
        cursor: pointer;
        transition: all 0.25s ease;
        transform: translate(50%, -50%);
        pointer-events: all;
      }

      &:after {
        position: absolute;
        right: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 6px;
        width: auto;
        height: auto;
        border: 0;
        border-radius: 8px;
        background-color: @status-success;
        color: white;
        content: attr(data-label);
        white-space: nowrap;
        font-size: 11px;
        transform: translate(50%, -24px);
      }
    }

    &__current {
      position: absolute;
      top: 4px;
      z-index: 12;
      width: var(--measurement-current);
      height: 12px;
      border-top: 4px solid var(--brand-light, @brand-primary-light);
      background-color: transparent;
      opacity: 1;
      transition: width 0.15s ease;

      &:before {
        position: absolute;
        top: -14px;
        right: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 2px;
        height: 54px;
        border-radius: 0%;
        border-left: 1px dashed @tooltip-background-default;
        color: transparent;
        content: '';
        text-align: center;
        transition: all 0.25s ease;
        transform: translate(calc(50% + .5px), -32px);
      }

      &:after {
        position: absolute;
        right: 0;
        display: flex;
        overflow: hidden;
        align-items: center;
        justify-content: center;
        padding: 2px 12px;
        width: auto;
        border: 0;
        border-radius: 32px;
        background-color: var(--range-display-tooltip-bg);
        box-shadow: var(--c8y-elevation--md);
        color: @palette-high;
        content: attr(data-label);
        white-space: pre;
        font-size: 11px;
        transition: background-color .15s ease;
        transform: var(--range-display-tooltip-translate);
        top: -8px;
      }
    }
  }

  &__ruler {
    position: relative;
    display: flex;
    flex-flow: row nowrap;
    justify-content: space-between;
    width: 100%;
    height: 8px;
    border-top: 0;
    border-left: 0;
  }

  &__tick {
    position: relative;

    &:before {
      position: absolute;
      top: 4px;
      left: 0;
      display: block;
      width: 4px;
      height: 5px;
      border: 0;
      border-left: 1px solid currentColor;
      content: '';
      opacity: 0.5;
    }

    &:after {
      position: absolute;
      top: 0;
      left: 50%;
      content: attr(data-label);
      text-align: center;
      font-size: 12px;
      transform: translate(-50%, 14px);
    }

    .range-display--compact:not(.range-display--vertical) & {
      &:after {
        top: 4px;
      }

      &:not(:first-child):not(:last-child):not(:nth-child(6)) {
        &::after {
          display: none;
        }
      }
    }

    .range-display--inline:not(.range-display--vertical) & {
      &:not(:first-child):not(:last-child):not(:nth-child(6)) {
        &::after,
        &::before {
          display: none;
        }
      }

      &:first-child,
      &:last-child,
      &:nth-child(6) {
        &::before {
          height: 3px;
        }

        &::after {
          font-size: 10px;
        }
      }

      &:first-child::after {
        transform: translate(0, 5px);
      }

      &:nth-child(6)::after {
        transform: translate(-50%, 5px);
      }

      &:last-child::after {
        transform: translate(-100%, 5px);
      }
    }
  }

  &--vertical {
    display: flex;
    flex-direction: column;
    height: 100%;
    align-items: center;
    min-width: 300px;

    .range-display {
      display: flex;
      flex-direction: column;
      flex-grow: 1;
      margin: 0 105px;
      padding: 38px 32px 34px 32px;
      min-width: unset;
      min-height: 240px;
      width: 80px;

      &__range {
        top: 38px;
        right: 32px;
        bottom: 34px;
        left: 28px;
        flex-direction: column;
        width: 6px;
        height: unset;
        border-top: 0;
        border-right: 1px dotted currentColor;
        border-bottom: 0;
        border-radius: 0;
        margin-left: -2px;

        &__unit {
          top: unset;
          bottom: -24px;
        }

        &__max,
        &__min {
          position: absolute;
          top: unset;
          left: -4px;
          max-width: 100%;
          width: 8px;
          height: unset;
          border-radius: 0;
        }

        &__max {
          top: calc(100% - var(--range-r-max));
          left: unset;
          height: calc(var(--range-r-max) - var(--range-r-min));
          background-color: var(--input-validation-error, @status-danger);
        }

        &__min {
          top: calc(100% - var(--range-y-max));
          left: unset;
          height: calc(var(--range-y-max) - var(--range-y-min));
          border-top: 1px solid @component-background-default;
          border-right: unset;
        }

        &__target {
          top: unset;
          left: -2px;
          width: unset;
          height: calc(100% - var(--measurement-target));
          z-index: 0;
          &:before {
            top: unset;
            right: unset;
            bottom: 0;
            left: 0;
            width: 56px;
            height: 2px;
            content: '';
            transform: translate(0, 50%);
          }

          &:after {
            right: unset;
            bottom: 0;
            transform: translate(56px, 50%);
          }
        }

        &__current {
          top: unset;
          bottom: 0;
          left: 6px;
          width: 12px;
          height: var(--measurement-current);
          border-top: unset;
          border-left: 4px solid var(--brand-light, @brand-primary-light);
          background-color: transparent;
          opacity: 1;

          &:before {
            top: 0;
            right: unset;
            bottom: unset;
            left: -8px;
            display: flex;
            flex-direction: column;
            width: 32px;
            height: 2px;
            transform: translate(-20px, -50%);
            border-top: 1px dashed @tooltip-background-default;
            border-left: 0;
          }

          &:after {
            right: unset;
            left: -30px;
            margin-left: 0;
            transform: translate(-100%, -50%);
            top: unset;
          }
        }
      }

      &__ruler {
        position: relative;
        flex-flow: column-reverse nowrap;
        flex-grow: 1;
        justify-content: space-between;
        width: 8px;
        border-top: 0;
        border-left: 0;
      }

      &__tick {
        position: relative;

        &:before {
          position: absolute;
          top: 0;
          left: 0;
          display: block;
          width: 4px;
          height: 5px;
          border: 0;
          border-top: 1px solid currentColor;
          content: '';
        }

        &:after {
          position: absolute;
          top: 0;
          left: 50%;
          content: attr(data-label);
          text-align: center;
          font-size: 12px;
          transform: translate(4px, -50%);
        }
      }
    }
  }
}
