@use 'scss/variables' as *;
@use 'scss/mixins' as *;

@include keyframes(checkScale) {
  0% {
    transform: scale(0);
    opacity: 0;
  }

  50% {
    transform: scale(1.1);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.checkbox-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  cursor: pointer;
  padding: 8px 0;

  &.disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  &:hover:not(.disabled) .checkbox-label {
    @include themed {
      color: t($link);
    }
  }

  .checkbox-label {
    flex: 1;
    transition: color 0.2s ease;
    pointer-events: none;

    @include themed {
      color: t($color);
    }
  }

  .checkbox-box {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    transition: all 0.2s ease;
    cursor: pointer;
    flex-shrink: 0;
    pointer-events: none;

    @include themed {
      border: 2px solid t($modal-sidebarActive);
      background: t($modal-sidebar);
      color: t($color);

      &:hover:not(.disabled) {
        border-color: t($color);
        transform: scale(1.05);
      }
    }

    &:active:not(.disabled) {
      transform: scale(0.95);

      @include themed {
        box-shadow: 0 0 0 4px rgba(255, 92, 37, 0.1);
      }
    }

    &.checked {
      @include themed {
        background: t($link);
        border-color: t($link);
      }

      svg {
        @include animation(checkScale 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55));
      }
    }

    svg {
      font-size: 18px;
      color: white;
    }
  }

  .checkbox-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    margin: 0;

    &:focus-visible + .checkbox-box {
      @include themed {
        box-shadow: 0 0 0 3px t($link);
      }
    }

    &:disabled {
      cursor: not-allowed;
    }
  }
}
