/**
* c-switch
*/
@import url('../../styles/variables.css');

.c-switch {
  display: inline-block;
  position: relative;
  vertical-align: middle;
}

.c-switch__checkbox {
  position: absolute;
  width: 0;
  height: 0;
  -webkit-appearance: none;
  margin: 0;
  opacity: 0;
}

.c-switch__layoutbox {
  position: relative;
  width: 40px;
  height: 20px;
  border-radius: 10px;
  cursor: pointer;
  background-color: color(var(--gray) l(+30%));
  border: 2px solid color(var(--gray) l(+30%));
  transition: all 0.2s linear;

  &::after {
    position: absolute;
    content: "";
    width: 16px;
    height: 16px;
    top: 0;
    left: 0;
    background: #fff;
    border-radius: 10px;
    transition: all 0.2s linear;
  }
}

.c-switch__innerbox {
  position: absolute;
  display: flex;
  align-items: center;
  height: 16px;
  left: 100%;
  margin-left: -16px;
  color: #fff;
}

.c-switch__checkbox:checked + .c-switch__layoutbox {
  background-color: var(--primary-color);
  border: 2px solid var(--primary-color);

  & .c-switch__innerbox {
    left: 2px;
    margin-left: 0;
  }

  &::after {
    left: 100%;
    margin-left: -16px;
  }
}

.c-switch__checkbox:disabled + .c-switch__layoutbox {
  opacity: 0.65;
  cursor: not-allowed;
}

.c-switch.is-sm {
  & .c-switch__layoutbox {
    width: 30px;
    height: 14px;
    border-radius: 7px;

    &::after {
      width: 10px;
      height: 10px;
    }
  }

  & .c-switch__checkbox:checked + .c-switch__layoutbox::after {
    margin-left: -10px;
  }
}
