$range-nav-height: 5rem !default;
$range-nav-compact-height: 1rem !default;
$range-nav-border-radius: var(--rz-border-radius) !default;
$range-nav-border: var(--rz-border-width) solid var(--rz-chart-axis-color) !default;
$range-nav-shade-background-color: var(--rz-base-background-color) !default;
$range-nav-shade-opacity: 0.7 !default;
$range-nav-compact-background-color: var(--rz-base-background-color) !default;
$range-nav-compact-border-radius: var(--rz-border-radius) !default;
$range-nav-compact-window-background-color: var(--rz-secondary-lighter) !default;
$range-nav-handle-width: 0.5rem !default;
$range-nav-handle-border-radius: var(--rz-border-radius) !default;
$range-nav-handle-background-color: var(--rz-base-400) !default;
$range-nav-handle-hover-background-color: var(--rz-base-500) !default;
$range-nav-handle-height: 1.5rem !default;
$range-nav-handle-shadow: none !default;
$range-nav-handle-hover-shadow: none !default;

.rz-range-nav {
  position: relative;
  overflow: visible;
  height: var(--rz-range-nav-height);
  border: var(--rz-range-nav-border);
  border-radius: var(--rz-range-nav-border-radius);

  svg {
    display: block;
    border-radius: var(--rz-range-nav-border-radius);

    [dir="rtl"] & {
      transform: scaleX(-1);
    }
  }
}

.rz-range-nav-shade {
  position: absolute;
  inset-block-start: 0;
  inset-block-end: 0;
  background: var(--rz-range-nav-shade-background-color);
  opacity: var(--rz-range-nav-shade-opacity);
  pointer-events: none;
  z-index: 1;

  &-start {
    inset-inline-start: 0;
    border-start-start-radius: var(--rz-range-nav-border-radius);
    border-end-start-radius: var(--rz-range-nav-border-radius);
  }

  &-end {
    inset-inline-end: 0;
    border-start-end-radius: var(--rz-range-nav-border-radius);
    border-end-end-radius: var(--rz-range-nav-border-radius);
  }
}

.rz-range-nav-window {
  position: absolute;
  inset-block-start: 0;
  inset-block-end: 0;
  border: var(--rz-range-nav-border);
  border-width: 0 var(--rz-border-width);
  background: transparent;
  cursor: grab;
  box-sizing: border-box;
  z-index: 2;

  &:active {
    cursor: grabbing;
  }
}

.rz-range-nav-handle {
  position: absolute;
  inset-block-start: 0;
  inset-block-end: 0;
  width: var(--rz-range-nav-handle-width);
  cursor: ew-resize;
  z-index: 3;

  &::before {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: var(--rz-range-nav-handle-height);
    inset-inline-start: 0;
    inset-inline-end: 0;
    background: var(--rz-range-nav-handle-background-color);
    box-shadow: var(--rz-range-nav-handle-shadow);
    transition: background 0.15s, box-shadow 0.15s;
  }

  &:hover::before,
  &:active::before {
    background: var(--rz-range-nav-handle-hover-background-color);
    box-shadow: var(--rz-range-nav-handle-hover-shadow);
  }

  &-start {
    inset-inline-start: calc(var(--rz-range-nav-handle-width) / -2);

    &::before {
      border-radius: var(--rz-range-nav-handle-border-radius);
    }
  }

  &-end {
    inset-inline-end: calc(var(--rz-range-nav-handle-width) / -2);

    &::before {
      border-radius: var(--rz-range-nav-handle-border-radius);
    }
  }
}

.rz-range-nav-label {
  position: absolute;
  bottom: 100%;
  white-space: nowrap;
  background: var(--rz-chart-tooltip-background);
  color: var(--rz-chart-tooltip-color);
  font-size: var(--rz-chart-tooltip-font-size);
  line-height: 1;
  box-shadow: 0 6px 14px 0 rgba(0, 0, 0, 0.15);
  padding: 0.5rem;
  border-radius: var(--rz-chart-tooltip-border-radius);
  margin-bottom: 0.25rem;
  pointer-events: none;
  z-index: 4;

  &::after {
    content: '';
    position: absolute;
    top: 100%;
    border: 4px solid transparent;
    border-top-color: var(--rz-chart-tooltip-background);
  }

  &-start {
    inset-inline-end: 0;
    inset-inline-start: auto;

    &::after {
      inset-inline-end: max(4px, calc(var(--rz-range-nav-handle-width) / 2 - 4px));
    }
  }

  &-end {
    inset-inline-start: 0;
    inset-inline-end: auto;

    &::after {
      inset-inline-start: max(4px, calc(var(--rz-range-nav-handle-width) / 2 - 4px));
    }
  }
}

.rz-range-nav-axis {
  position: absolute;
  inset-inline-start: 0;
  inset-inline-end: 0;
  bottom: 0;
  height: 1.5rem;
  pointer-events: none;
  z-index: 0;
}

.rz-range-nav-tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);

  &-first {
    transform: none;
  }

  &-last {
    transform: translateX(-100%);
  }
}

.rz-range-nav-tick-mark {
  width: 1px;
  height: 6px;
  background: var(--rz-chart-axis-color);
  margin: 0 auto;
}

.rz-range-nav-tick-label {
  font-size: var(--rz-chart-axis-font-size);
  line-height: 1.2;
  color: var(--rz-chart-axis-label-color);
  white-space: nowrap;
  text-align: center;
}

.rz-range-nav-has-axis {
  padding-bottom: 1.5rem;

  .rz-range-nav-shade {
    bottom: 1.5rem;
  }

  .rz-range-nav-window {
    bottom: 1.5rem;
  }
}

/* Compact Range Navigator */
.rz-range-nav-compact {
  height: var(--rz-range-nav-compact-height);
  background: var(--rz-range-nav-compact-background-color);
  border-radius: var(--rz-range-nav-compact-border-radius);

  .rz-range-nav-shade {
    background: transparent;
    opacity: 1;
  }

  .rz-range-nav-window {
    border: none;
    background: var(--rz-range-nav-compact-window-background-color);
    border-radius: var(--rz-range-nav-compact-border-radius);
    opacity: 0.85;
  }

}

.rz-range-nav-compact.rz-range-nav-has-axis {
  padding-bottom: 0;
  margin-bottom: 1.5rem;

  .rz-range-nav-shade {
    bottom: 0;
  }

  .rz-range-nav-window {
    bottom: 0;
  }

  .rz-range-nav-axis {
    top: 100%;
    bottom: auto;
  }
}
