@import "mixins/mixins";
@import "common/var";


@include b(switch) {
  display: inline-flex;
  align-items: center;
  position: relative;
  font-size: $switch-font-size;
  height: $switch-height;
  line-height: $switch-height;
  vertical-align: middle;

  @include pf(disabled) {
    & .#{$namespace}-switch_core,
    & .#{$namespace}-switch_label {
      cursor: not-allowed;
    }
  }

  @include e(label) {
    transition: $all-transition;
    height: $switch-height;
    display: inline-block;
    font-size: $switch-font-size;
    font-weight: 500;
    cursor: pointer;
    vertical-align: middle;
    color: $text-color-default;

    @include pf(active) {
      color: $primary-color;
    }

    @include mf(left) {
      margin-right: 10px;
    }
    @include mf(right) {
      margin-left: 10px;
    }

    & * {
      line-height: 1;
      font-size: $switch-font-size;
      display: inline-block;
    }
  }

  @include e(input) {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    margin: 0;
  }

  @include e(core) {
    margin: 0;
    display: inline-block;
    position: relative;
    width: $switch-width;
    height: $switch-height;
    border: 1px solid $switch-off-color;
    outline: none;
    border-radius: $switch-core-border-radius;
    box-sizing: border-box;
    background: $switch-off-color;
    cursor: pointer;
    transition: $bg-border-transition;
    vertical-align: middle;

    .#{$namespace}-switch_action {
      position: absolute;
      top: 1px;
      left: 1px;
      border-radius: 100%;
      transition: $all-transition;
      width: $switch-button-size;
      height: $switch-button-size;
      background-color: $color-white;
      display: flex;
      justify-content: center;
      align-items: center;
      color: $switch-off-color;
    }
  }

  @include pf(checked) {
    .#{$namespace}-switch_core {
      border-color: $switch-on-color;
      background-color: $switch-on-color;

      .#{$namespace}-switch_action {
        left: 100%;
        margin-left: -$switch-button-size - 1px;
        color: $switch-on-color;
      }
    }
  }

  @include pf(disabled) {
    opacity: .6;
  }

  @include mf(wide) {
    .#{$namespace}-switch_label {
      &.#{$namespace}-switch_label-left {
        span {
          left: 10px;
        }
      }

      &.#{$namespace}-switch_label-right {
        span {
          right: 10px;
        }
      }
    }
  }
  & .label-fade-enter,
  & .label-fade-leave-active {
    opacity: 0;
  }

}
