@use '../colors';

.root {
  position: relative;
  display: inline-block;
  user-select: none;
  vertical-align: -2px;
}

.input {
  position: absolute;
  display: block;
  opacity: 0;
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  &:not(:checked) + .switch {
    --toggle-slider-position: 2px;
  }
  &:checked + .switch {
    --toggle-slider-position: calc(100% - 22px);
  }
  &:not(:checked):not(:disabled) + .switch {
    --toggle-primary-color: #{colors.$basic-gray12};
  }
  &:checked:not(:disabled) + .switch {
    --toggle-primary-color: #{colors.$basic-blue};
  }
  &:not(:checked):disabled + .switch {
    --toggle-primary-color: #{colors.$basic-gray4};
  }
  &:checked:disabled + .switch {
    --toggle-primary-color: #{colors.$basic-gray24};
  }
  &:disabled {
    cursor: default;
  }
}

.switch {
  position: relative;
  display: block;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: var(--toggle-primary-color);
  transition: background 0.16s ease-in-out;
  pointer-events: none;
  &::after {
    content: '';
    position: absolute;
    top: 2px;
    left: var(--toggle-slider-position);
    display: block;
    width: 20px;
    height: 20px;
    background: #fff;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    transition: left 0.32s ease-in-out;
  }
}
