handle negative margin and min padding correctly