@import './../theme/vars.scss';

$switch-prefix-cls: amos-switch;
$switch-duration: 0.3s;

.#{$switch-prefix-cls} {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
  line-height: 20px;
  vertical-align: middle;
  cursor: pointer;
  background-color: $color-grey;
  border: 1px solid $color-grey;
  border-radius: 20px;
  box-sizing: border-box;
  transition: all $switch-duration $ease-in-out-circ;
  user-select: none;

  &-inner {
    position: absolute;
    right: 6px;
    font-size: 12px;
    color: $color-white;
    text-align: right;
  }

  &::after {
    position: absolute;
    top: 1px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    background-color: $color-white;
    border-radius: 18px;
    content: ' ';
    transition: left $switch-duration $ease-in-out-circ, width $switch-duration $ease-in-out-circ;
  }

  &:active::after {
    width: 24px;
  }

  &:focus {
    outline: 0;
    // box-shadow: 0 0 0 2px rgba($primary-color, 20%);
  }

  &:focus:hover {
    box-shadow: none;
  }

  &-small {
    width: 28px;
    height: 14px;
    line-height: 12px;

    &::after {
      top: 0;
      width: 12px;
      height: 12px;
    }

    &:active::after {
      width: 16px;
    }
  }

  &-small.#{$switch-prefix-cls}-checked::after {
    right: 0;
  }

  &-small:active.#{$switch-prefix-cls}-checked::after {
    right: 0;
  }

  &-checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);

    .#{$switch-prefix-cls}-inner {
      right: inherit;
      left: 6px;
      text-align: left;
    }

    &::after {
      right: 0;
    }

    &:active::after {
      right: 0;
    }
  }

  &-disabled {
    color: $switch-color-disable;
    cursor: not-allowed;
    background: $switch-bg-disable;
    border-color: $switch-bg-disable;

    &::after {
      cursor: not-allowed;
      background: $color-grey;
    }

    .#{$switch-prefix-cls}-inner {
      color: $color-grey;
    }
  }
}
