@import '../common/style/var.less';

.van-switch {
  position: relative;
  display: inline-block;
  box-sizing: content-box;
  width: var(--switch-width, @switch-width);
  height: var(--switch-height, @switch-height);
  background-color: var(--switch-background-color, @switch-background-color);
  border: var(--switch-border, @switch-border);
  border-radius: var(--switch-node-size, @switch-node-size);
  transition: background-color
    var(--switch-transition-duration, @switch-transition-duration);

  &__node {
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 100%;
    z-index: var(--switch-node-z-index, @switch-node-z-index);
    width: var(--switch-node-size, @switch-node-size);
    height: var(--switch-node-size, @switch-node-size);
    background-color: var(
      --switch-node-background-color,
      @switch-node-background-color
    );
    box-shadow: var(--switch-node-box-shadow, @switch-node-box-shadow);
    transition: var(--switch-transition-duration, @switch-transition-duration)
      cubic-bezier(0.3, 1.05, 0.4, 1.05);
  }

  &__loading {
    position: absolute !important;
    top: 25%;
    left: 25%;
    width: 50%;
    height: 50%;
  }

  &--on {
    background-color: var(
      --switch-on-background-color,
      @switch-on-background-color
    );

    .van-switch__node {
      transform: translateX(
        calc(
          var(--switch-width, @switch-width) -
            var(--switch-node-size, @switch-node-size)
        )
      );
    }
  }

  &--disabled {
    opacity: var(--switch-disabled-opacity, @switch-disabled-opacity);
  }
}
