@import '../../style/mixins';
@import '../../style/themes/default';

@switchPrefixCls: am-switch;

.@{switchPrefixCls} {
  display: inline-block;
  vertical-align: middle;
  box-sizing: border-box;
  position: relative;
  cursor: pointer;
  .align-self(center);
  .checkbox {
    width: 102px;
    height: 62px;
    border-radius: 62px;
    box-sizing: border-box;
    background: #e5e5e5;
    z-index: 0;
    margin: 0;
    padding: 0;
    appearance: none;
    border: 0;
    cursor: pointer;
    position: relative;
    transition: all 300ms;
    &:before {
      content: ' ';
      position: absolute;
      left: 3px;
      top: 3px;
      width: 96px;
      height: 56px;
      border-radius: 56px;
      box-sizing: border-box;
      background: @fill-base;
      z-index: 1;
      transition: all 200ms;
      .transform(scale(1));
    }
    &:after {
      content: ' ';
      height: 56px;
      width: 56px;
      border-radius: 56px;
      background: @fill-base;
      position: absolute;
      z-index: 2;
      left: 3px;
      top: 3px;
      .transform(translateX(0px));
      transition: all 200ms;
      box-shadow: 4px 4px 8px @color-shadow;
    }
  }
  input[type="checkbox"] {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    border: 0 none;
    appearance: none;
    &:checked {
      &+ .checkbox {
        background: @switch-fill;
        &:before {
          .transform(scale(0));
        }
        &:after {
          .transform(translateX(40px));
        }
      }
    }
    &:disabled {
      &+ .checkbox {
        opacity: @opacity-disabled;
      }
    }
  }
  &&-android {
    margin-right: @v-spacing-sm;
    .checkbox {
      width: 210px;
      height: 66px;
      border-radius: 10px;
      background: #A7AAA6;
      &:before {
        display: none;
      }
      &:after {
        width: 102px;
        height: 60px;
        border-radius: 7px;
        box-shadow: none;
      }
    }
    input[type="checkbox"] {
      &:checked {
        &+ .checkbox {
          background: @switch-fill-android;
          &:before {
            .transform(scale(0));
          }
          &:after {
            .transform(translateX(102px));
          }
        }
      }
    }
  }
}
