$class-prefix-switch: 'au-switch';

$--width: 54px;
$--height: 30px;
$--border-width: 20px;

@keyframes loading-rotate {
  100% {
    transform: rotate(1turn);
  }
}

.#{$class-prefix-switch} {
  width: 54px;
  height: 30px;
  border-width: 20px;
  display: inline-block;
  vertical-align: middle;
  box-sizing: border-box;
  position: relative;
  align-self: center;
  cursor: pointer;
  &-checkbox {
    min-width: 54px;
    height: 30px;
    box-sizing: border-box;
    border-radius: 31px;
    background: #ccc;
    z-index: 0;
    overflow: hidden;
    line-height: 30px;

    &:before {
      content: ' ';
      position: absolute;
      left: 1px;
      top: 1px;
      width: 52px;
      height: 28px;
      border-radius: 15px;
      box-sizing: border-box;
      background: #fff;
      z-index: 1;
      transition: all 200ms;
      transform: scale(1);
    }
  }

  &-handle {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 26px;
    height: 26px;
    border-radius: 26px;
    background: #fff;
    position: absolute;
    z-index: 2;
    top: 2px;
    left: 1px;
    transition: all .2s;
    box-shadow: 0 0 2px 0 rgba(0,0,0,.2), 0 2px 11.5px 0 rgba(0,0,0,.08), -1px 2px 2px 0 rgba(0,0,0,.1);
  }

  &-inner {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 8px 0 28px;
    height: 100%;
    color: #aaa;
    transition: margin .2s;
    font-size: 15px;
    > * {
      color: #aaa !important;
    }
    .au-icon-model {
      font-size: 12px;
    }
  }

  /* 选中状态 */
  &.#{$class-prefix-switch}-checked {
    .#{$class-prefix-switch}-checkbox {
      background-color: #0046C7;
      &:before {
        transform: scale(0);
      }
    }
    .#{$class-prefix-switch}-handle {
      left: 27px;
    }

    .#{$class-prefix-switch}-inner {
      margin: 0 0 0 -18px;
      color: #fff;
      > * {
        color: #fff !important;
      }
    }
  }

  /* 禁用状态 */
  &.#{$class-prefix-switch}-disabled {
    cursor: not-allowed;
    opacity: 0.4;
    .#{$class-prefix-switch}-checkbox::before {
      background-color: #D9D9D9;
    }
    // &.#{$class-prefix-switch}-checked {
      // .#{$class-prefix-switch}-checkbox::before {
      //   background-color: #A0CBFA;
      // }
    // }
  }

  /* loading图标 */
  &-spin-icon {
    width: 14px;
    height: 14px;
    animation: loading-rotate 1s linear infinite;
  }
}

