@use '../abstracts/variables';
@use '../abstracts/mixins';

.toggle {
  align-items: center;
  cursor: pointer;
  display: inline-flex;
  font-size: 15px;
  line-height: 20px;

  .label {
    margin-left: 64px;
  }

  > input {
    margin-left: 6px;
    position: absolute;
    height: 0;
    width: 0;
  }

  .toggle-switch {
    @include mixins.input-transition-long;
    display: inline-block;
    background: variables.$white;
    border: 1px solid variables.$grey-20;
    border-radius: 16px;
    margin-right: 12px;
    user-select: none;
    position: absolute;
    height: 28px;
    width: 52px;
    &:before {
      @include mixins.input-transition-long;
      content: '';
      position: absolute;
      width: 24px;
      height: 24px;
      border-radius: 100%;
      background: variables.$grey-20;
      top: 1px;
      left: 1px;
    }
  }

  input:checked + .toggle-switch {
    border: 1px solid variables.$primary;
    background-color: variables.$primary;
    &:before {
      background-color: variables.$white;
      transform: translateX(24px);
    }
  }

  &.disabled {
    cursor: not-allowed;
    .toggle-switch {
      border-color: variables.$inactive;
      background-color: variables.$inactive;
      &:before {
        background-color: variables.$secondary-background;
      }
    }
  }

  &.disabled input:checked ~ .toggle-switch {
    border-color: variables.$inactive;
    background-color: variables.$inactive;
    &:before {
      background-color: variables.$secondary-background;
      transform: translateX(24px);
    }
  }

  &:focus,
  &.hovered,
  &.active {
    .toggle-switch {
      background-color: variables.$secondary-background;
    }
  }
}
